Commit a5aff0c1 authored by Dainis Abols's avatar Dainis Abols
Browse files

Fixed hardcoded Contacts urls

parent 407b4427
......@@ -77,7 +77,7 @@ class ContactsController extends ActionController
];
}
} else {
$data = $ContactsModel->getContactsModel($request, $alphabet)->getDataList();
$data = $ContactsModel->getContactsModel($request, $alphabet)->getDataList();
if (!empty($data['data'])) {
$data['data'] = array_values($data['data']);
}
......
......@@ -245,20 +245,27 @@ class Contact
// Add main data
$contact->setId($item['id']);
empty($item['name']) ? $contact->setName('-') : $contact->setName($item['name']);
empty($item['surname']) ? $contact->setSurname('-') : $contact->setSurname($item['surname']);
empty($item['name']) || empty($item['surname']) ? $contact->setFullName('-') : $contact->setFullName($item['name'].' '.$item['surname']);
empty($item['email']) ? $contact->setEmail('-') : $contact->setEmail($item['email']);
empty($item['phone']) ? $contact->setPhone('-') : $contact->setPhone($item['phone']);
if (!empty($item['email'])) {
$contact->setEmail($item['email']);
}
if (!empty($item['name'])) {
$contact->setName($item['name'].' ');
}
if (!empty($item['surname'])) {
$contact->setSurname($item['surname'].' ');
}
if (!empty($item['name']) || !empty($item['surname'])) {
$contact->setFullName($item['name'].' '.$item['surname']);
}
if (!empty($item['phone'])) {
$contact->setPhone($item['phone']);
}
$contact->createPublicUrl();
// Add unit info
if ($item['units']['numFound']) {
// Add units and childs
if (!empty($item['units']['numFound'])) {
$contact->addUnitList($item['units']['docs']);
}
// Add childs
if (!empty($item['_childDocuments_'])) {
$contact->addChilds($item['_childDocuments_']);
}
......
......@@ -19,19 +19,23 @@ class ListAddressTest extends UnitTestCase
protected $resetSingletonInstances = true;
/**
* Public API URL
* LocalConfiguration file name and relative location
*
* @var string
*/
private string $url = 'https://typo3-dev2.lu.lv/contacts';
private string $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
/**
* @test
*/
public function testList()
public function testSearch()
{
// Read settings
$conf = @include $this->LocalConfiguration;
$testUrl = @$conf['EXTENSIONS']['lu_contacts']['testAPIUrl'];
// Read url
$url = $this->url.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=address';
$url = $testUrl.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=address';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
......
......@@ -19,19 +19,23 @@ class ListSurnameTest extends UnitTestCase
protected $resetSingletonInstances = true;
/**
* Public API URL
* LocalConfiguration file name and relative location
*
* @var string
*/
private string $url = 'https://typo3-dev2.lu.lv/contacts';
private string $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
/**
* @test
*/
public function testList()
public function testSearch()
{
// Read settings
$conf = @include $this->LocalConfiguration;
$testUrl = @$conf['EXTENSIONS']['lu_contacts']['testAPIUrl'];
// Read url
$url = $this->url.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=surname';
$url = $testUrl.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=surname';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
......
......@@ -19,19 +19,23 @@ class ListUnitsTest extends UnitTestCase
protected $resetSingletonInstances = true;
/**
* Public API URL
* LocalConfiguration file name and relative location
*
* @var string
*/
private string $url = 'https://typo3-dev2.lu.lv/contacts';
private string $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
/**
* @test
*/
public function testList()
public function testSearch()
{
// Read settings
$conf = @include $this->LocalConfiguration;
$testUrl = @$conf['EXTENSIONS']['lu_contacts']['testAPIUrl'];
// Read url
$url = $this->url.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=unit&tx_lucontacts_pi1[unit]=LUD030000000';
$url = $testUrl.'?tx_lucontacts_pi1[action]=list&tx_lucontacts_pi1[listType]=unit&tx_lucontacts_pi1[unit]=LUD030000000';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment