Initial commit - Typo3 11.5.41
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
"pages"
|
||||
,"uid","pid","title"
|
||||
,7,1,"Storage"
|
||||
,9,1,"Single pid"
|
||||
|
13
typo3conf/ext/tt_address/Tests/Functional/Fixtures/pages.xml
Normal file
13
typo3conf/ext/tt_address/Tests/Functional/Fixtures/pages.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<pages>
|
||||
<uid>7</uid>
|
||||
<pid>1</pid>
|
||||
<title>Storage</title>
|
||||
</pages>
|
||||
<pages>
|
||||
<uid>9</uid>
|
||||
<pid>1</pid>
|
||||
<title>Single Pid</title>
|
||||
</pages>
|
||||
</dataset>
|
||||
@@ -0,0 +1,18 @@
|
||||
"sys_category"
|
||||
,"uid","pid","title","parent","deleted","hidden"
|
||||
,1,1,"City",0,0,0
|
||||
,2,1,"Person",0,0,0
|
||||
,20,1,"Bond",2,0,0
|
||||
,21,1,"blofeld",20,0,0
|
||||
,211,1,"blofeld 1",21,0,0
|
||||
,212,1,"blofeld 2",21,0,0
|
||||
,30,1,"Band",2,0,0
|
||||
,31,1,"Beatles",30,0,0
|
||||
,32,1,"george",30,0,0
|
||||
,3,1,"rom",1,0,0
|
||||
,4,1,"paris",1,0,0
|
||||
,5,1,"wien",1,0,0
|
||||
,6,1,"hamburg",1,1,0
|
||||
,7,1,"mailand",1,0,1
|
||||
,8,1,"moskau",1,0,0
|
||||
|
||||
|
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<sys_category>
|
||||
<uid>1</uid>
|
||||
<pid>1</pid>
|
||||
<title>City</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>2</uid>
|
||||
<pid>1</pid>
|
||||
<title>Person</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>20</uid>
|
||||
<pid>1</pid>
|
||||
<title>Bond</title>
|
||||
<parent>2</parent>
|
||||
</sys_category>
|
||||
|
||||
<sys_category>
|
||||
<uid>21</uid>
|
||||
<pid>1</pid>
|
||||
<title>blofeld</title>
|
||||
<parent>20</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>211</uid>
|
||||
<pid>1</pid>
|
||||
<title>blofeld 1</title>
|
||||
<parent>21</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>212</uid>
|
||||
<pid>1</pid>
|
||||
<title>blofeld 2</title>
|
||||
<parent>21</parent>
|
||||
</sys_category>
|
||||
|
||||
<sys_category>
|
||||
<uid>30</uid>
|
||||
<pid>1</pid>
|
||||
<title>Band</title>
|
||||
<parent>2</parent>
|
||||
</sys_category>
|
||||
|
||||
<sys_category>
|
||||
<uid>31</uid>
|
||||
<pid>1</pid>
|
||||
<title>beatles</title>
|
||||
<parent>30</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>32</uid>
|
||||
<pid>1</pid>
|
||||
<title>george</title>
|
||||
<parent>30</parent>
|
||||
</sys_category>
|
||||
|
||||
|
||||
<sys_category>
|
||||
<uid>3</uid>
|
||||
<pid>1</pid>
|
||||
<title>Rom</title>
|
||||
<parent>1</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>4</uid>
|
||||
<pid>1</pid>
|
||||
<title>Paris</title>
|
||||
<parent>1</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>5</uid>
|
||||
<pid>1</pid>
|
||||
<title>Wien</title>
|
||||
<parent>1</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>6</uid>
|
||||
<pid>1</pid>
|
||||
<title>Hamburg</title>
|
||||
<parent>1</parent>
|
||||
<deleted>1</deleted>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>7</uid>
|
||||
<pid>1</pid>
|
||||
<title>Mailand</title>
|
||||
<parent>1</parent>
|
||||
<hidden>1</hidden>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>8</uid>
|
||||
<pid>1</pid>
|
||||
<title>Moskau</title>
|
||||
<parent>1</parent>
|
||||
</sys_category>
|
||||
</dataset>
|
||||
@@ -0,0 +1,49 @@
|
||||
"pages"
|
||||
,"uid","pid","sorting","title"
|
||||
,1,0,128,"Root"
|
||||
,2,1,128,"Sub"
|
||||
,3,2,128,"Sub II"
|
||||
"tt_address"
|
||||
,"uid","pid","first_name","last_name","categories","longitude", "latitude","city","address","country"
|
||||
,1,1,"John","Doe",2,"0.0","0.0","","",""
|
||||
,2,1,"Jane","Doe",0,"0.0","0.0","","",""
|
||||
,3,1,"Max","Mustermann",0,"0.0","0.0","","",""
|
||||
,4,1,"Maria","Musterfrau",0,"0.0","0.0","","",""
|
||||
,5,2,"Auric","Goldfinger",0,"0.0","0.0","","",""
|
||||
,6,2,"Ernst","Blofeld",0,"0.0","0.0","","",""
|
||||
,7,3,"Maximilian","Zargo",0,"0.0","0.0","","",""
|
||||
,8,21,"John","Zane",3,"0.0","0.0","","",""
|
||||
,12,25,"","",0,0.0,"12.12","","","",
|
||||
,13,25,"","",0,"12.12","0.0","","",""
|
||||
,14,25,"","",0,"12.12", "11.12","","",""
|
||||
,21,100,"","",0,"0.0","0.0","Linz","Dummystr","AT"
|
||||
,22,100,"","",0,"0.0","0.0","Linz","Dummystr 2","AT"
|
||||
,23,100,"","",0,"0.0","0.0","Linz","Dummystr 2","AT"
|
||||
,24,100,"","",0,"19.0000", "49.0000","Linz","Dummystr 2","AT"
|
||||
"sys_category"
|
||||
,"uid","pid","title","parent"
|
||||
,1,1,"Madrid",0
|
||||
,2,1,"Kiev",0
|
||||
,3,1,"Rom",0
|
||||
,4,1,"Paris",0
|
||||
,5,1,"Wien",0
|
||||
,6,1,"Hamburg",0
|
||||
,7,1,"Mailand",0
|
||||
,8,1,"Moskau",0
|
||||
,10,1,"Madrid sub",1
|
||||
,11,1,"Madrid sub sub",10
|
||||
"sys_category_record_mm"
|
||||
,"tablenames","fieldname","uid_local","uid_foreign"
|
||||
,"tt_address","categories",1,1
|
||||
,"tt_address","categories",2,1
|
||||
,"tt_address","categories",3,3
|
||||
,"tt_address","categories",3,4
|
||||
,"tt_address","categories",4,4
|
||||
,"tt_address","categories",5,5
|
||||
,"tt_address","categories",5,6
|
||||
,"tt_address","categories",1,6
|
||||
,"tt_address","categories",5,2
|
||||
,"tt_address","categories",6,2
|
||||
,"tt_address","categories",6,7
|
||||
,"tt_address","categories",7,7
|
||||
,"tt_address","categories",11,8
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 2.
|
@@ -0,0 +1,251 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<tt_address>
|
||||
<uid>1</uid>
|
||||
<pid>1</pid>
|
||||
<first_name>John</first_name>
|
||||
<last_name>Doe</last_name>
|
||||
<categories>2</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>2</uid>
|
||||
<pid>1</pid>
|
||||
<first_name>Jane</first_name>
|
||||
<last_name>Doe</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>3</uid>
|
||||
<pid>1</pid>
|
||||
<first_name>Max</first_name>
|
||||
<last_name>Mustermann</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>4</uid>
|
||||
<pid>1</pid>
|
||||
<first_name>Maria</first_name>
|
||||
<last_name>Musterfrau</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>5</uid>
|
||||
<pid>2</pid>
|
||||
<first_name>Auric</first_name>
|
||||
<last_name>Goldfinger</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>6</uid>
|
||||
<pid>2</pid>
|
||||
<first_name>Ernst</first_name>
|
||||
<middle_name>Stravo</middle_name>
|
||||
<last_name>Blofeld</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>7</uid>
|
||||
<pid>3</pid>
|
||||
<first_name>Maximilian</first_name>
|
||||
<last_name>Zargo</last_name>
|
||||
<categories>0</categories>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>8</uid>
|
||||
<pid>21</pid>
|
||||
<first_name>John</first_name>
|
||||
<last_name>Zane</last_name>
|
||||
<categories>3</categories>
|
||||
</tt_address>
|
||||
|
||||
<!-- Coordinates-->
|
||||
<tt_address>
|
||||
<uid>12</uid>
|
||||
<pid>25</pid>
|
||||
<latitude>12.12</latitude>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>13</uid>
|
||||
<pid>25</pid>
|
||||
<longitude>12.12</longitude>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>14</uid>
|
||||
<pid>25</pid>
|
||||
<latitude>11.12</latitude>
|
||||
<longitude>12.12</longitude>
|
||||
</tt_address>
|
||||
|
||||
<!-- for geocoding-->
|
||||
<tt_address>
|
||||
<uid>21</uid>
|
||||
<pid>100</pid>
|
||||
<city>Linz</city>
|
||||
<address>Dummystr</address>
|
||||
<country>AT</country>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>22</uid>
|
||||
<pid>100</pid>
|
||||
<city>Linz</city>
|
||||
<address>Dummystr 2</address>
|
||||
<country>AT</country>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>23</uid>
|
||||
<pid>100</pid>
|
||||
<city>Linz</city>
|
||||
<address>Dummystr 2</address>
|
||||
<country>AT</country>
|
||||
</tt_address>
|
||||
<tt_address>
|
||||
<uid>24</uid>
|
||||
<pid>100</pid>
|
||||
<city>Linz</city>
|
||||
<address>Dummystr 2</address>
|
||||
<country>AT</country>
|
||||
<latitude>19.00000</latitude>
|
||||
<longitude>49.00000</longitude>
|
||||
</tt_address>
|
||||
|
||||
<sys_category>
|
||||
<uid>1</uid>
|
||||
<pid>1</pid>
|
||||
<title>Madrid</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>2</uid>
|
||||
<pid>1</pid>
|
||||
<title>Kiev</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>3</uid>
|
||||
<pid>1</pid>
|
||||
<title>Rom</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>4</uid>
|
||||
<pid>1</pid>
|
||||
<title>Paris</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>5</uid>
|
||||
<pid>1</pid>
|
||||
<title>Wien</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>6</uid>
|
||||
<pid>1</pid>
|
||||
<title>Hamburg</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>7</uid>
|
||||
<pid>1</pid>
|
||||
<title>Mailand</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>8</uid>
|
||||
<pid>1</pid>
|
||||
<title>Moskau</title>
|
||||
<parent>0</parent>
|
||||
</sys_category>
|
||||
|
||||
<sys_category>
|
||||
<uid>10</uid>
|
||||
<pid>1</pid>
|
||||
<title>Madrid sub</title>
|
||||
<parent>1</parent>
|
||||
</sys_category>
|
||||
<sys_category>
|
||||
<uid>11</uid>
|
||||
<pid>1</pid>
|
||||
<title>Madrid sub sub</title>
|
||||
<parent>10</parent>
|
||||
</sys_category>
|
||||
|
||||
<sys_category_record_mm>
|
||||
<uid_local>1</uid_local>
|
||||
<uid_foreign>1</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>2</uid_local>
|
||||
<uid_foreign>1</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>3</uid_local>
|
||||
<uid_foreign>3</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>3</uid_local>
|
||||
<uid_foreign>4</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>4</uid_local>
|
||||
<uid_foreign>4</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>5</uid_local>
|
||||
<uid_foreign>5</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>5</uid_local>
|
||||
<uid_foreign>6</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>1</uid_local>
|
||||
<uid_foreign>6</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>5</uid_local>
|
||||
<uid_foreign>2</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>6</uid_local>
|
||||
<uid_foreign>2</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>6</uid_local>
|
||||
<uid_foreign>7</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>7</uid_local>
|
||||
<uid_foreign>7</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
<sys_category_record_mm>
|
||||
<uid_local>11</uid_local>
|
||||
<uid_foreign>8</uid_foreign>
|
||||
<tablenames>tt_address</tablenames>
|
||||
<fieldname>categories</fieldname>
|
||||
</sys_category_record_mm>
|
||||
</dataset>
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FriendsOfTYPO3\TtAddress\Tests\Functional\Repository;
|
||||
|
||||
/**
|
||||
* This file is part of the "tt_address" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FriendsOfTYPO3\TtAddress\Domain\Model\Address;
|
||||
use FriendsOfTYPO3\TtAddress\Domain\Model\Dto\Demand;
|
||||
use FriendsOfTYPO3\TtAddress\Domain\Repository\AddressRepository;
|
||||
use TYPO3\CMS\Core\Information\Typo3Version;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||
|
||||
class AddressRepositoryTest extends FunctionalTestCase
|
||||
{
|
||||
/** @var AddressRepository */
|
||||
protected $addressRepository;
|
||||
|
||||
protected array $testExtensionsToLoad = ['typo3conf/ext/tt_address'];
|
||||
|
||||
protected array $coreExtensionsToLoad = ['fluid', 'extensionmanager'];
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
|
||||
if ($versionInformation->getMajorVersion() >= 11) {
|
||||
$this->addressRepository = $this->getContainer()->get(AddressRepository::class);
|
||||
} else {
|
||||
$this->addressRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(AddressRepository::class);
|
||||
}
|
||||
|
||||
$this->importCSVDataSet(__DIR__ . '/../Fixtures/tt_address.csv');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rawQueryReturnsCorrectQuery()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages([1, 2]);
|
||||
$demand->setIgnoreWithoutCoordinates(true);
|
||||
$result = $this->addressRepository->getSqlQuery($demand);
|
||||
$time = $GLOBALS['SIM_ACCESS_TIME'];
|
||||
$sql = 'SELECT `tt_address`.* FROM `tt_address` `tt_address` WHERE (((`tt_address`.`pid` IN (1, 2)) AND ( NOT((`tt_address`.`latitude` IS NULL) OR (`tt_address`.`latitude` = 0)))) AND ( NOT((`tt_address`.`longitude` IS NULL) OR (`tt_address`.`longitude` = 0)))) AND (`tt_address`.`sys_language_uid` IN (0, -1)) AND (`tt_address`.`t3ver_oid` = 0) AND ((`tt_address`.`hidden` = 0) AND (`tt_address`.`starttime` <= ' . $time . ') AND ((`tt_address`.`endtime` = 0) OR (`tt_address`.`endtime` > ' . $time . ')) AND tt_address.deleted=0)';
|
||||
|
||||
if ((new Typo3Version())->getMajorVersion() >= 12) {
|
||||
$sql = 'SELECT `tt_address`.* FROM `tt_address` `tt_address` WHERE (((((`tt_address`.`pid` IN (1, 2)) AND ( NOT(((`tt_address`.`latitude` IS NULL) OR (`tt_address`.`latitude` = 0)))))) AND ( NOT(((`tt_address`.`longitude` IS NULL) OR (`tt_address`.`longitude` = 0)))))) AND (`tt_address`.`sys_language_uid` IN (0, -1)) AND (`tt_address`.`t3ver_oid` = 0) AND (((`tt_address`.`hidden` = 0) AND (`tt_address`.`starttime` <= ' . $time . ') AND (((`tt_address`.`endtime` = 0) OR (`tt_address`.`endtime` > ' . $time . ')))) AND tt_address.deleted=0)';
|
||||
}
|
||||
$this->assertEquals($sql, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByUid()
|
||||
{
|
||||
$address = $this->addressRepository->findByIdentifier(1);
|
||||
$this->assertEquals($address->getFirstName(), 'John');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCustomSorting()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['1', '2', '3', '23']);
|
||||
$demand->setSingleRecords('3,6,2');
|
||||
$addresses = $this->addressRepository->getAddressesByCustomSorting($demand);
|
||||
|
||||
$this->assertEquals([3, 6, 2], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCustomSortingDesc()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['1', '2', '3', '23']);
|
||||
$demand->setSortBy('');
|
||||
$demand->setSingleRecords('3,6,2');
|
||||
$demand->setSortOrder('DESC');
|
||||
$addresses = $this->addressRepository->getAddressesByCustomSorting($demand);
|
||||
|
||||
$this->assertEquals([2, 6, 3], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCustomSortingAndSortFieldDesc()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setSortBy('last_name');
|
||||
$demand->setSingleRecords('3,6,2');
|
||||
$demand->setSortOrder('DESC');
|
||||
$addresses = $this->addressRepository->getAddressesByCustomSorting($demand);
|
||||
|
||||
$this->assertEquals([3, 2, 6], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByPageAndCustomSortingDesc()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['2', '10', '', '3']);
|
||||
$demand->setSortBy('lastName');
|
||||
$demand->setSortOrder('DESC');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([7, 5, 6], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByPageAndCustomSortingAsc()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['2', '10', '', '3']);
|
||||
$demand->setSortBy('lastName');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([6, 5, 7], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCategory()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['1', '2', '3', '23']);
|
||||
$demand->setSortBy('uid');
|
||||
$demand->setCategories('5');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([2, 5, 6], $this->getListOfIds($addresses));
|
||||
|
||||
$demand->setCategories('5,6');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([2], $this->getListOfIds($addresses));
|
||||
|
||||
$demand->setCategoryCombination('or');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([2, 5, 6, 7], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCategoryWithSubCheck()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['1', '2', '3', '21', '23']);
|
||||
$demand->setSortBy('uid');
|
||||
$demand->setCategoryCombination('or');
|
||||
$demand->setCategories('1');
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([1, 6], $this->getListOfIds($addresses));
|
||||
|
||||
$demand->setIncludeSubCategories(true);
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
$this->assertEquals([1, 6, 8], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByCoordinates()
|
||||
{
|
||||
$demand = new Demand();
|
||||
$demand->setPages(['25']);
|
||||
$demand->setIgnoreWithoutCoordinates(true);
|
||||
$addresses = $this->addressRepository->findByDemand($demand);
|
||||
foreach ($addresses as $a) {
|
||||
echo $a->getUid() . ' - ' . $a->getLongitude() . '/' . $a->getLatitude() . chr(10);
|
||||
}
|
||||
$this->assertEquals([14], $this->getListOfIds($addresses));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address[] $list
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
private function getListOfIds($list, string $field = 'uid'): array
|
||||
{
|
||||
$getter = 'get' . ucfirst($field);
|
||||
$idList = [];
|
||||
foreach ($list as $address) {
|
||||
$idList[] = $address->$getter();
|
||||
}
|
||||
|
||||
return $idList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FriendsOfTYPO3\TtAddress\Tests\Functional\Service;
|
||||
|
||||
/**
|
||||
* This file is part of the "tt_address" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use FriendsOfTYPO3\TtAddress\Service\CategoryService;
|
||||
use TYPO3\CMS\Core\Cache\CacheManager;
|
||||
use TYPO3\CMS\Core\Information\Typo3Version;
|
||||
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||
|
||||
class CategoryServiceTest extends FunctionalTestCase
|
||||
{
|
||||
/** @var CategoryService */
|
||||
protected $subject;
|
||||
|
||||
protected array $testExtensionsToLoad = ['typo3conf/ext/tt_address'];
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->subject = GeneralUtility::makeInstance(CategoryService::class);
|
||||
|
||||
$this->importCSVDataSet(__DIR__ . '/../Fixtures/sys_categories.csv');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findChildCategories()
|
||||
{
|
||||
$categories = $this->subject->getChildrenCategories('2,4');
|
||||
$this->assertEquals('2,4,20,21,211,212,30,31,32', $categories);
|
||||
|
||||
$categories = $this->subject->getChildrenCategories('4,5,10919,6,7,8');
|
||||
$this->assertEquals('4,5,8', $categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function loggerInvokedWithTooManyCategories()
|
||||
{
|
||||
$mockedTimeTracker = $this->getAccessibleMock(TimeTracker::class, ['setTSlogMessage'], [], '', false);
|
||||
$mockedTimeTracker->expects($this->any())->method('setTSlogMessage');
|
||||
|
||||
$subject = $this->getAccessibleMock(CategoryService::class, null, [], '', false);
|
||||
$subject->_set('timeTracker', $mockedTimeTracker);
|
||||
|
||||
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion();
|
||||
$cacheIdentifier = $versionInformation >= 11 ? 'ttaddress_category' : 'cache_ttaddress_category';
|
||||
$subject->_set('cache', GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheIdentifier));
|
||||
|
||||
$categories = $subject->getChildrenCategories('2,4', 100000);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FriendsOfTYPO3\TtAddress\Tests\Functional\Command;
|
||||
|
||||
/**
|
||||
* This file is part of the "tt_address" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use FriendsOfTYPO3\TtAddress\Service\GeocodeService;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||
|
||||
class GeocodeServiceTest extends FunctionalTestCase
|
||||
{
|
||||
protected array $testExtensionsToLoad = ['typo3conf/ext/tt_address'];
|
||||
|
||||
protected array $coreExtensionsToLoad = ['fluid', 'extensionmanager'];
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->importCSVDataSet(__DIR__ . '/../Fixtures/tt_address.csv');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function properRecordsAreFound()
|
||||
{
|
||||
$subject = $this->getAccessibleMock(GeocodeService::class, ['getCoordinatesForAddress'], ['123']);
|
||||
$subject->expects($this->any())->method('getCoordinatesForAddress')
|
||||
->withConsecutive([], [], [])
|
||||
->willReturnOnConsecutiveCalls(
|
||||
['latitude' => 10.000, 'longitude' => 12.000],
|
||||
['latitude' => 10.000, 'longitude' => 12.000],
|
||||
[],
|
||||
['latitude' => 13.000, 'longitude' => 14.000]
|
||||
);
|
||||
|
||||
$count = $subject->calculateCoordinatesForAllRecordsInTable('pid=100');
|
||||
$this->assertEquals(3, $count);
|
||||
|
||||
$row = BackendUtility::getRecord('tt_address', 21);
|
||||
$this->assertEquals(['latitude' => $row['latitude'], 'longitude' => $row['longitude']], ['latitude' => 10.000000000000, 'longitude' => 12.000000000000]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function urlforAddressesIsBuiltCorrectly()
|
||||
{
|
||||
$result1 = ['results' => [0 => ['geometry' => ['location' => ['lat' => 11, 'lng' => '13']]]]];
|
||||
$resultEmpty = ['results' => []];
|
||||
|
||||
$subject = $this->getAccessibleMock(GeocodeService::class, ['getApiCallResult'], ['123']);
|
||||
$subject->expects($this->any())->method('getApiCallResult')
|
||||
->willReturnOnConsecutiveCalls($result1, $resultEmpty);
|
||||
|
||||
$response = $subject->getCoordinatesForAddress('DummyStr', '1', 'London', 'UK');
|
||||
$this->assertEquals($response, ['latitude' => 11, 'longitude' => '13']);
|
||||
$response2 = $subject->getCoordinatesForAddress('DummyStr', '1', 'London', 'UK');
|
||||
$response3 = $subject->getCoordinatesForAddress('DummyStr', '2', 'Vienna', 'UK');
|
||||
$response4 = $subject->getCoordinatesForAddress();
|
||||
$this->assertEquals([], $response4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findRecordsByUid()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user