Composer extensions

This commit is contained in:
Matteo Gallo
2026-07-03 20:05:15 +02:00
parent 5ca4743197
commit d8a4481a03
1747 changed files with 3503 additions and 194889 deletions

View File

@@ -0,0 +1,20 @@
root = true
[{*.rst,*.rst.txt}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 3
max_line_length = 80
# MD-Files
[*.md]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
max_line_length = 80

View File

@@ -0,0 +1,41 @@
filter:
excluded_paths:
- 'Documentation/*'
- 'Tests/*'
paths:
- 'Classes/*'
tools:
external_code_coverage:
timeout: 2400
runs: 7
php_cpd:
enabled: true
php_code_sniffer:
enabled: true
config:
standard: PSR2
php_cs_fixer:
enabled: true
php_hhvm:
enabled: true
config:
use_undeclared_constant: false
php_mess_detector:
enabled: true
config:
controversial_rules:
superglobals: false
php_pdepend:
enabled: true
php_analyzer:
enabled: true
sensiolabs_security_checker: true

View File

@@ -1,34 +0,0 @@
<!--
Functional test suites setup
Functional tests should extend from \TYPO3\TestingFramework\Core\Tests\FunctionalTestCase,
take a look at this class for further documentation on how to run the suite.
TYPO3 CMS functional test suite also needs phpunit bootstrap code, the
file is located next to this .xml as FunctionalTestsBootstrap.php
-->
<phpunit
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="Core tests">
<directory>../Tests/Functional/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../Classes/</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,34 +0,0 @@
<!--
Functional test suites setup
Functional tests should extend from \TYPO3\TestingFramework\Core\Tests\FunctionalTestCase,
take a look at this class for further documentation on how to run the suite.
TYPO3 CMS functional test suite also needs phpunit bootstrap code, the
file is located next to this .xml as FunctionalTestsBootstrap.php
-->
<phpunit
backupGlobals="true"
bootstrap="../../../../../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="Core tests">
<directory>../../Tests/Functional/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../../Classes/</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,27 +0,0 @@
<phpunit
backupGlobals="true"
bootstrap="../../../../../../vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
convertDeprecationsToExceptions="false"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="Core tests">
<directory>../../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../../Classes/</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,28 +0,0 @@
<phpunit
backupGlobals="true"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
convertDeprecationsToExceptions="false"
beStrictAboutTestsThatDoNotTestAnything="false"
>
<testsuites>
<testsuite name="tests">
<directory>../Tests/Unit/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>../Classes/</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,4 +0,0 @@
"pages"
,"uid","pid","title"
,7,1,"Storage"
,9,1,"Single pid"
1 pages
2 uid pid title
3 7 1 Storage
4 9 1 Single pid

View File

@@ -1,13 +0,0 @@
<?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>

View File

@@ -1,18 +0,0 @@
"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
1 sys_category
2 uid pid title parent deleted hidden
3 1 1 City 0 0 0
4 2 1 Person 0 0 0
5 20 1 Bond 2 0 0
6 21 1 blofeld 20 0 0
7 211 1 blofeld 1 21 0 0
8 212 1 blofeld 2 21 0 0
9 30 1 Band 2 0 0
10 31 1 Beatles 30 0 0
11 32 1 george 30 0 0
12 3 1 rom 1 0 0
13 4 1 paris 1 0 0
14 5 1 wien 1 0 0
15 6 1 hamburg 1 1 0
16 7 1 mailand 1 0 1
17 8 1 moskau 1 0 0

View File

@@ -1,100 +0,0 @@
<?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>

View File

@@ -1,49 +0,0 @@
"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.

View File

@@ -1,251 +0,0 @@
<?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>

View File

@@ -1,206 +0,0 @@
<?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;
}
}

View File

@@ -1,63 +0,0 @@
<?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);
}
}

View File

@@ -1,78 +0,0 @@
<?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);
}
}

View File

@@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\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\Command\GeocodeCommand;
use FriendsOfTYPO3\TtAddress\Service\GeocodeService;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use TYPO3\TestingFramework\Core\BaseTestCase;
class GeocodeCommandTest extends BaseTestCase
{
/**
* @test
*/
public function configurationIsProperlyConfigured()
{
$subject = $this->getAccessibleMock(GeocodeCommand::class, ['addArgument'], [], '', false);
$subject->_call('configure');
$this->assertEquals('Geocode tt_address records', $subject->getDescription());
}
/**
* @test
*/
public function geocodeServiceIsReturned()
{
$subject = $this->getAccessibleMock(GeocodeCommand::class, null, [], '', false);
$service = $subject->_call('getGeocodeService', '123');
$this->assertEquals(GeocodeService::class, get_class($service));
}
/**
* @test
*/
public function geocodingIsCalled()
{
$geocodeService = $this->getAccessibleMock(GeocodeService::class, ['calculateCoordinatesForAllRecordsInTable'], [], '', false);
$geocodeService->expects($this->once())->method('calculateCoordinatesForAllRecordsInTable');
$subject = $this->getAccessibleMock(GeocodeCommand::class, ['getGeocodeService'], [], '', false);
$subject->expects($this->once())->method('getGeocodeService')->willReturn($geocodeService);
$input = $this->getAccessibleMock(StringInput::class, ['getArgument'], [], '', false);
$input->expects($this->once())->method('getArgument')->willReturn('123');
$output = $this->getAccessibleMock(ConsoleOutput::class, null, []);
$subject->_call('execute', $input, $output);
}
}

View File

@@ -1,142 +0,0 @@
<?php
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Controller;
/**
* 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\Controller\AddressController;
use FriendsOfTYPO3\TtAddress\Domain\Model\Dto\Demand;
use FriendsOfTYPO3\TtAddress\Domain\Model\Dto\Settings;
use FriendsOfTYPO3\TtAddress\Domain\Repository\AddressRepository;
use TYPO3\CMS\Core\Pagination\PaginatorInterface;
use TYPO3\CMS\Core\Pagination\SimplePagination;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\TestingFramework\Core\BaseTestCase;
class AddressControllerPaginationTest extends BaseTestCase
{
protected function setUp(): void
{
$GLOBALS['TSFE'] = $this->getAccessibleMock(TypoScriptFrontendController::class, ['addCacheTags'], [], '', false);
}
/**
* @test
*/
public function listActionUsesNewPaginationWithArrayRecords()
{
if (!class_exists(SimplePagination::class)) {
$this->markTestSkipped('Ignore test as new pagination is not available');
}
$settings = [
'singlePid' => 0,
'singleRecords' => 1,
'paginate' => [
'itemsPerPage' => 3
]
];
$demand = new Demand();
$demand->setSingleRecords('134');
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, ['getAddressesByCustomSorting'], [], '', false);
$rows = [];
for ($i = 1; $i <= 10; $i++) {
$rows[] = [
'uid' => $i,
'title' => 'record #' . $i
];
}
$assignments = [
'demand' => $demand,
'addresses' => $rows,
'contentObjectData' => [],
];
$mockedRepository->expects($this->once())->method('getAddressesByCustomSorting')->willReturn($rows);
$mockedRequest = $this->getAccessibleMock(Request::class, ['hasArgument', 'getArgument'], [], '', false);
$mockedRequest->expects($this->once())->method('hasArgument')->with('currentPage')->willReturn(true);
$mockedRequest->expects($this->once())->method('getArgument')->with('currentPage')->willReturn(2);
$mockedView = $this->getAccessibleMock(TemplateView::class, ['assignMultiple', 'assign'], [], '', false);
$mockedView->expects($this->once())->method('assignMultiple')->with($assignments);
$mockedView->expects($this->any())->method('assign')
->withConsecutive(
['newPagination', true],
['pagination'] // the result can't be mocked, therefore just testing if it exists
);
$mockContentObject = $this->createMock(ContentObjectRenderer::class);
$mockConfigurationManager = $this->createMock(ConfigurationManager::class);
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);
$subject = $this->getAccessibleMock(AddressController::class, ['createDemandFromSettings', 'htmlResponse'], [], '', false);
$subject->expects($this->once())->method('createDemandFromSettings')->willReturn($demand);
$subject->expects($this->once())->method('htmlResponse');
$subject->_set('settings', $settings);
$subject->_set('view', $mockedView);
$subject->_set('request', $mockedRequest);
$subject->_set('addressRepository', $mockedRepository);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->listAction();
}
/**
* @test
*/
public function paginationIsCorrectlyTriggered()
{
if (!class_exists(SimplePagination::class)) {
$this->markTestSkipped('Ignore test as new pagination is not available');
}
$settings = [
'singlePid' => 0,
'singleRecords' => 1,
'paginate' => [
'itemsPerPage' => 3
]
];
$rows = [];
for ($i = 1; $i <= 10; $i++) {
$rows[] = [
'uid' => $i,
'title' => 'record #' . $i
];
}
$mockedRequest = $this->getAccessibleMock(Request::class, ['hasArgument', 'getArgument'], [], '', false);
$mockedRequest->expects($this->once())->method('hasArgument')->with('currentPage')->willReturn(true);
$mockedRequest->expects($this->once())->method('getArgument')->with('currentPage')->willReturn(2);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('settings', $settings);
$subject->_set('request', $mockedRequest);
/** @var PaginatorInterface $paginator */
$paginator = $subject->_call('getPaginator', $rows);
$this->assertEquals($paginator->getPaginatedItems(), array_splice($rows, 3, 3));
}
protected function getMockedSettings()
{
$mockedSettings = $this->getAccessibleMock(Settings::class, ['getSettings'], [], '', false);
$mockedSettings->expects($this->any())->method('getSettings')->willReturn([]);
return $mockedSettings;
}
}

View File

@@ -1,392 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Controller;
/**
* 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\Controller\AddressController;
use FriendsOfTYPO3\TtAddress\Database\QueryGenerator;
use FriendsOfTYPO3\TtAddress\Domain\Model\Address;
use FriendsOfTYPO3\TtAddress\Domain\Model\Dto\Demand;
use FriendsOfTYPO3\TtAddress\Domain\Model\Dto\Settings;
use FriendsOfTYPO3\TtAddress\Domain\Repository\AddressRepository;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\View\TemplateView;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\TestingFramework\Core\BaseTestCase;
class AddressControllerTest extends BaseTestCase
{
use ProphecyTrait;
protected function setUp(): void
{
$GLOBALS['TSFE'] = $this->getAccessibleMock(TypoScriptFrontendController::class, ['addCacheTags'], [], '', false);
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider dotIsRemovedFromEndDataProvider
*/
public function dotIsRemovedFromEnd($given, $expected)
{
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$this->assertEquals($expected, $subject->_call('removeDotAtTheEnd', $given));
}
public function dotIsRemovedFromEndDataProvider(): array
{
return [
'empty string' => ['', ''],
'dot at end' => ['foBar.', 'foBar'],
];
}
/**
* @test
*/
public function dotsAreRemovedFromArray()
{
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$given = [
'example' => 'some string',
'example2' => '123',
'example with dot.' => 'bla',
'array' => [
'sub' => 'string',
'sub-with-dot.' => 'stringvalue',
],
];
$expected = [
'example' => 'some string',
'example2' => '123',
'example with dot' => 'bla',
'array' => [
'sub' => 'string',
'sub-with-dot' => 'stringvalue',
],
];
$this->assertEquals($expected, $subject->_call('removeDots', $given));
}
/**
* @test
*/
public function initializeActionWorks()
{
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->initializeAction();
$expected = new QueryGenerator();
$this->assertEquals($expected, $subject->_get('queryGenerator'));
}
/**
* @test
*/
public function injectAddressRepositoryWorks()
{
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, null, [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->injectAddressRepository($mockedRepository);
$this->assertEquals($mockedRepository, $subject->_get('addressRepository'));
}
/**
* @test
*/
public function pidListIsReturned()
{
$mockedQueryGenerator = $this->getAccessibleMock(QueryGenerator::class, ['getTreeList'], [], '', false);
$mockedQueryGenerator->expects($this->any())->method('getTreeList')
->withConsecutive([123, 3], [456, 3])
->willReturnOnConsecutiveCalls('7,8,9', '');
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('queryGenerator', $mockedQueryGenerator);
$subject->_set('settings', [
'pages' => '123,456',
'recursive' => 3,
]);
$this->assertEquals(['123', '456', '7', '8', '9'], $subject->_call('getPidList'));
}
/**
* @test
*/
public function settingsAreProperlyInjected()
{
$this->markTestSkipped('Skipped until fixed');
$mockedConfigurationManager = $this->getAccessibleMock(ConfigurationManager::class, ['getConfiguration'], [], '', false);
$mockedConfigurationManager->expects($this->any())->method('getConfiguration')
->withConsecutive([ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT], [ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS])
->willReturnOnConsecutiveCalls(
[
'plugin.' => [
'tx_ttaddress.' => [
'settings' => [
'orderByAllowed' => 'sorting',
'overrideFlexformSettingsIfEmpty' => 'key4,key5,key6',
'key2' => 'abc',
'key4' => 'fo',
'key5' => '',
],
],
],
],
[
'key1' => 'value1',
'orderByAllowed' => 'custom',
'key2' => '',
'key3' => '',
'key4' => '',
'key5' => '',
]
);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$expectedSettings = [
'key1' => 'value1',
'orderByAllowed' => 'sorting',
'key2' => '',
'key3' => '',
'key4' => 'fo',
'key5' => '',
];
$subject->injectConfigurationManager($mockedConfigurationManager);
$this->assertEquals($expectedSettings, $subject->_get('settings'));
}
/**
* @test
*/
public function demandIsCreated()
{
$demand = new Demand();
$subject = $this->getAccessibleMock(AddressController::class, ['getPidList'], [], '', false);
$subject->expects($this->any())->method('getPidList')->willReturn(['123', '456']);
$subject->_set('settings', [
'pages' => '123,456',
'singleRecords' => '7,4',
'recursive' => 3,
'groups' => '4,5,6',
'groupsCombination' => 1,
]);
$expected = new Demand();
$expected->setPages(['123', '456']);
$expected->setSingleRecords('7,4');
$expected->setCategoryCombination('or');
$expected->setCategories('4,5,6');
$this->assertEquals($expected, $subject->_call('createDemandFromSettings'));
}
/**
* @test
*/
public function showActionFillsView()
{
$address = new Address();
$address->setLastName('Doe');
$assigned = [
'address' => $address,
'contentObjectData' => [],
];
$mockedView = $this->getAccessibleMock(TemplateView::class, ['assignMultiple'], [], '', false);
$mockedView->expects($this->once())->method('assignMultiple')->with($assigned);
$mockContentObject = $this->createMock(ContentObjectRenderer::class);
$mockConfigurationManager = $this->createMock(ConfigurationManager::class);
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);
$subject = $this->getAccessibleMock(AddressController::class, ['redirectToUri', 'htmlResponse'], [], '', false);
$subject->_set('view', $mockedView);
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->expects($this->once())->method('htmlResponse');
$subject->showAction($address);
}
/**
* @test
*/
public function listActionFillsViewForSingleRecords()
{
$settings = [
'singlePid' => 0,
'singleRecords' => 1,
];
$demand = new Demand();
$demand->setSingleRecords('134');
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, ['getAddressesByCustomSorting'], [], '', false);
$mockedRepository->expects($this->once())->method('getAddressesByCustomSorting')->willReturn(['dummy return single']);
$assignments = [
'demand' => $demand,
'addresses' => ['dummy return single'],
'contentObjectData' => []
];
$mockedView = $this->getAccessibleMock(TemplateView::class, ['assignMultiple', 'assign'], [], '', false);
$mockedView->expects($this->once())->method('assignMultiple')->with($assignments);
$mockConfigurationManager = $this->createMock(ConfigurationManager::class);
$mockContentObject = $this->createMock(ContentObjectRenderer::class);
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);
$mockedRequest = $this->getAccessibleMock(Request::class, ['hasArgument', 'getArgument'], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, ['createDemandFromSettings', 'htmlResponse'], [], '', false);
$subject->expects($this->once())->method('createDemandFromSettings')->willReturn($demand);
$subject->expects($this->once())->method('htmlResponse');
$subject->_set('settings', $settings);
$subject->_set('view', $mockedView);
$subject->_set('request', $mockedRequest);
$subject->_set('addressRepository', $mockedRepository);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->listAction();
}
/**
* @test
*/
public function listActionFillsViewForDemand()
{
$settings = [
'singleRecords' => 1,
];
$demand = new Demand();
$demand->setPages(['12']);
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, ['findByDemand'], [], '', false);
$mockedRepository->expects($this->once())->method('findByDemand')->willReturn(['dummy return']);
$mockContentObject = $this->createMock(ContentObjectRenderer::class);
$mockConfigurationManager = $this->createMock(ConfigurationManager::class);
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);
$assignments = [
'demand' => $demand,
'addresses' => ['dummy return'],
'contentObjectData' => [],
];
$mockedRequest = $this->getAccessibleMock(Request::class, ['hasArgument', 'getArgument'], [], '', false);
$mockedView = $this->getAccessibleMock(TemplateView::class, ['assignMultiple', 'assign'], [], '', false);
$mockedView->expects($this->once())->method('assignMultiple')->with($assignments);
$subject = $this->getAccessibleMock(AddressController::class, ['createDemandFromSettings', 'htmlResponse'], [], '', false);
$subject->expects($this->once())->method('createDemandFromSettings')->willReturn($demand);
$subject->expects($this->any())->method('htmlResponse');
$subject->_set('settings', $settings);
$subject->_set('view', $mockedView);
$subject->_set('request', $mockedRequest);
$subject->_set('addressRepository', $mockedRepository);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->listAction();
}
/**
* @test
*/
public function overrideDemandMethodIsCalledIfEnabled()
{
$mockedRequest = $this->getAccessibleMock(Request::class, ['hasArgument', 'getArgument'], [], '', false);
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, ['getAddressesByCustomSorting', 'findByDemand'], [], '', false);
$mockedRepository->expects($this->any())->method('findByDemand')->willReturn([]);
$mockedView = $this->getAccessibleMock(TemplateView::class, ['assignMultiple', 'assign'], [], '', false);
$mockedView->expects($this->once())->method('assignMultiple');
$mockContentObject = $this->createMock(ContentObjectRenderer::class);
$mockConfigurationManager = $this->createMock(ConfigurationManager::class);
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);
$subject = $this->getAccessibleMock(AddressController::class, ['overrideDemand', 'createDemandFromSettings', 'htmlResponse'], [], '', false);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->expects($this->any())->method('overrideDemand');
$subject->expects($this->any())->method('htmlResponse');
$demand = new Demand();
$subject->expects($this->any())->method('createDemandFromSettings')->willReturn($demand);
$settings = [
'allowOverride' => true,
];
$subject->_set('settings', $settings);
$subject->_set('addressRepository', $mockedRepository);
$subject->_set('view', $mockedView);
$subject->_set('request', $mockedRequest);
$subject->listAction(['not', 'empty']);
}
/**
* @test
* @dataProvider overrideDemandWorksDataProvider
*/
public function overrideDemandWorks(Demand $demandIn, Demand $demandOut, array $override)
{
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$this->assertEquals($demandOut, $subject->_call('overrideDemand', $demandIn, $override));
}
public function overrideDemandWorksDataProvider(): array
{
$data = [];
// simple override + skipped field including different case
$demand1In = new Demand();
$demand1In->setCategories('12,34');
$demand1In->setSortBy('uid');
$demand1Out = clone $demand1In;
$demand1Out->setCategories('56');
$demand1Out->setSortBy('title');
$data['skipSimple'] = [$demand1In, $demand1Out, ['categories' => '56', 'sortby' => 'title']];
// not existing field
$demand2In = new Demand();
$demand2In->setCategories('7');
$demand2Out = clone $demand2In;
$data['ignoreNotExisting'] = [$demand2In, $demand2Out, ['categoriesX' => '56', 'ysortby' => 'title']];
return $data;
}
protected function getMockedSettings()
{
$mockedSettings = $this->getAccessibleMock(Settings::class, ['getSettings'], [], '', false);
$mockedSettings->expects($this->any())->method('getSettings')->willReturn([]);
return $mockedSettings;
}
}

View File

@@ -1,540 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Domain\Model;
/**
* 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 TYPO3\CMS\Extbase\Domain\Model\Category;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\TestingFramework\Core\BaseTestCase;
class AddressTest extends BaseTestCase
{
/** @var Address */
protected $subject;
public function setup(): void
{
$this->subject = new Address();
}
/**
* @test
*/
public function genderCanBeSet()
{
$value = 'm';
$this->subject->setGender($value);
$this->assertEquals($value, $this->subject->getGender());
}
/**
* @test
*/
public function nameCanBeSet()
{
$value = 'Max Mustermann';
$this->subject->setName($value);
$this->assertEquals($value, $this->subject->getName());
}
/**
* @test
*/
public function firstNameCanBeSet()
{
$value = 'Max';
$this->subject->setFirstName($value);
$this->assertEquals($value, $this->subject->getFirstName());
}
/**
* @test
*/
public function middleNameCanBeSet()
{
$value = 'J.';
$this->subject->setMiddleName($value);
$this->assertEquals($value, $this->subject->getMiddleName());
}
/**
* @test
*/
public function lastNameCanBeSet()
{
$value = 'Mustermann';
$this->subject->setLastName($value);
$this->assertEquals($value, $this->subject->getLastName());
}
/**
* @test
*/
public function birthdayCanBeSet()
{
$value = new \DateTime();
$this->subject->setBirthday($value);
$this->assertEquals($value, $this->subject->getBirthday());
}
/**
* @test
*/
public function titleCanBeSet()
{
$value = 'dr.';
$this->subject->setTitle($value);
$this->assertEquals($value, $this->subject->getTitle());
}
/**
* @test
*/
public function addressCanBeSet()
{
$value = 'Dummystreet 134';
$this->subject->setAddress($value);
$this->assertEquals($value, $this->subject->getAddress());
}
/**
* @test
*/
public function latitudeCanBeSet()
{
$value = 123.121221;
$this->subject->setLatitude($value);
$this->assertEquals($value, $this->subject->getLatitude());
}
/**
* @test
*/
public function longitudeCanBeSet()
{
$value = 10.1291;
$this->subject->setLongitude($value);
$this->assertEquals($value, $this->subject->getLongitude());
}
/**
* @test
*/
public function buildingCanBeSet()
{
$value = 'building 1';
$this->subject->setBuilding($value);
$this->assertEquals($value, $this->subject->getBuilding());
}
/**
* @test
*/
public function roomCanBeSet()
{
$value = 'room 1';
$this->subject->setRoom($value);
$this->assertEquals($value, $this->subject->getRoom());
}
public function telephoneFormatDataProvider()
{
return [
'phone number' => ['0122333', '0122333'],
'phone number with spaces' => [' 0 122 333 ', '0122333'],
'phone number with dashes' => ['0122-333-4444', '01223334444'],
'phone number with slash' => ['0122/333', '0122333'],
'phone number with invalid chars' => ['!0"1§2$2%/&3/3(3)', '0122333'],
'phone number with allowed special chars' => ['#06*', '#06*'],
'phone number with brackets in front' => ['(0)22333', '022333'],
'phone number with brackets in middle' => ['+49(0)22333', '+4922333'],
'phone number with number in brackets' => ['+49 (122) 333', '+49122333'],
'phone number with letters' => ['tel: +49 122 333', '+49122333'],
];
}
/**
* @test
*/
public function phoneCanBeSet()
{
$value = '+43129';
$this->subject->setPhone($value);
$this->assertEquals($value, $this->subject->getPhone());
}
/**
* @test
* @dataProvider telephoneFormatDataProvider
*/
public function phoneWithCleanedChars($number, $expectedNumber)
{
$this->subject->setPhone($number);
self::assertSame(
$expectedNumber,
$this->subject->getCleanedPhone()
);
}
/**
* @test
*/
public function faxCanBeSet()
{
$value = '+431294';
$this->subject->setFax($value);
$this->assertEquals($value, $this->subject->getFax());
}
/**
* @test
* @dataProvider telephoneFormatDataProvider
*/
public function faxWithCleanedChars($number, $expectedNumber)
{
$this->subject->setFax($number);
self::assertSame(
$expectedNumber,
$this->subject->getCleanedFax()
);
}
/**
* @test
*/
public function mobileCanBeSet()
{
$value = '+431294111';
$this->subject->setMobile($value);
$this->assertEquals($value, $this->subject->getMobile());
}
/**
* @test
* @dataProvider telephoneFormatDataProvider
*/
public function mobileWithCleanedChars($number, $expectedNumber)
{
$this->subject->setMobile($number);
self::assertSame(
$expectedNumber,
$this->subject->getCleanedMobile()
);
}
/**
* @test
*/
public function wwwCanBeSet()
{
$value = 'www.typo3.org';
$this->subject->setWww($value);
$this->assertEquals($value, $this->subject->getWww());
}
/**
* @test
* @dataProvider simplifiedWwwIsReturnedDataProvider
*/
public function simplifiedWwwIsReturned(string $given, string $expected)
{
$this->subject->setWww($given);
$this->assertEquals($expected, $this->subject->getWwwSimplified());
}
public function simplifiedWwwIsReturnedDataProvider()
{
return [
'empty' => ['', ''],
'emptyAfterTrim' => [' ', ''],
'simpleLink' => ['www.typo3.org', 'www.typo3.org'],
'linkWithAdditionalAttributes' => ['https://typo3.com _blank', 'https://typo3.com'],
'linkWithAdditionalAttributes2' => ['https://typo3.com _blank TYPO3', 'https://typo3.com'],
];
}
/**
* @test
*/
public function slugCanBeSet()
{
$value = '/testaddress/';
$this->subject->setSlug($value);
$this->assertEquals($value, $this->subject->getSlug());
}
/**
* @test
*/
public function skypeCanBeSet()
{
$value = 'fo.com';
$this->subject->setSkype($value);
$this->assertEquals($value, $this->subject->getSkype());
}
/**
* @test
*/
public function twitterCanBeSet()
{
$value = '@georg_ringer';
$this->subject->setTwitter($value);
$this->assertEquals($value, $this->subject->getTwitter());
}
/**
* @test
*/
public function wrongTwitterHandleThrowsErrorCanBeSet()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1357530444);
$value = 'georg_ringer';
$this->subject->setTwitter($value);
$this->assertEquals($value, $this->subject->getTwitter());
}
/**
* @test
*/
public function facebookCanBeSet()
{
$value = '/fo';
$this->subject->setFacebook($value);
$this->assertEquals($value, $this->subject->getFacebook());
}
/**
* @test
*/
public function wrongFacebookHandleThrowsErrorCanBeSet()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1357530471);
$value = 'some string';
$this->subject->setFacebook($value);
$this->assertEquals($value, $this->subject->getFacebook());
}
/**
* @test
*/
public function linkedinCanBeSet()
{
$value = 'www.linkedin.com/bar';
$this->subject->setLinkedin($value);
$this->assertEquals($value, $this->subject->getLinkedin());
}
/**
* @test
*/
public function emailCanBeSet()
{
$value = 'some@example.org';
$this->subject->setEmail($value);
$this->assertEquals($value, $this->subject->getEmail());
}
/**
* @test
*/
public function companyCanBeSet()
{
$value = 'ACME';
$this->subject->setCompany($value);
$this->assertEquals($value, $this->subject->getCompany());
}
/**
* @test
*/
public function positionCanBeSet()
{
$value = 'Boss';
$this->subject->setPosition($value);
$this->assertEquals($value, $this->subject->getPosition());
}
/**
* @test
*/
public function cityCanBeSet()
{
$value = 'Linz';
$this->subject->setCity($value);
$this->assertEquals($value, $this->subject->getCity());
}
/**
* @test
*/
public function zipCanBeSet()
{
$value = '30210';
$this->subject->setZip($value);
$this->assertEquals($value, $this->subject->getZip());
}
/**
* @test
*/
public function regionCanBeSet()
{
$value = 'OOE';
$this->subject->setRegion($value);
$this->assertEquals($value, $this->subject->getRegion());
}
/**
* @test
*/
public function countryCanBeSet()
{
$value = 'AT';
$this->subject->setCountry($value);
$this->assertEquals($value, $this->subject->getCountry());
}
/**
* @test
*/
public function descriptionCanBeSet()
{
$value = 'lorem ipsum';
$this->subject->setDescription($value);
$this->assertEquals($value, $this->subject->getDescription());
}
/**
* @test
*/
public function imagesCanBeSet()
{
$value = new ObjectStorage();
$item = new FileReference();
$item->setPid(123);
$value->attach($item);
$this->subject->setImage($value);
$this->assertEquals($value, $this->subject->getImage());
}
/**
* @test
*/
public function imagesCanBeAttached()
{
$value = new ObjectStorage();
$item = new FileReference();
$item->setPid(123);
$value->attach($item);
$item2 = new FileReference();
$item2->setPid(345);
$this->subject->setImage($value);
$this->subject->addImage($item2);
$this->assertEquals(2, $this->subject->getImage()->count());
}
/**
* @test
*/
public function firstImageCanBeRetrieved()
{
$value = new ObjectStorage();
$item = new FileReference();
$item->setPid(123);
$value->attach($item);
$item2 = new FileReference();
$item2->setPid(345);
$this->subject->setImage($value);
$this->assertEquals($item, $this->subject->getFirstImage());
}
/**
* @test
*/
public function firstImageIsNullIfNoImages()
{
$value = new ObjectStorage();
$this->subject->setImage($value);
$this->assertNull($this->subject->getFirstImage());
}
/**
* @test
*/
public function imagesCanBeRemoved()
{
$value = new ObjectStorage();
$item = new FileReference();
$item->setPid(123);
$value->attach($item);
$item2 = new FileReference();
$item2->setPid(345);
$value->attach($item2);
$this->subject->setImage($value);
$this->subject->removeImage($item2);
$this->assertEquals(1, $this->subject->getImage()->count());
}
/**
* @test
*/
public function categoriesCanBeSet()
{
$value = new ObjectStorage();
$item = new Category();
$item->setPid(456);
$value->attach($item);
$this->subject->setCategories($value);
$this->assertEquals($value, $this->subject->getCategories());
}
/**
* @test
* @dataProvider fullNameDataProvider
*/
public function fullNameIsReturned(string $expected, array $nameParts): void
{
$this->subject->setTitle($nameParts[0]);
$this->subject->setFirstName($nameParts[1]);
$this->subject->setLastName($nameParts[2]);
$this->subject->setTitleSuffix($nameParts[3]);
$this->assertEquals($expected, $this->subject->getFullName());
}
public function fullNameDataProvider(): array
{
return [
'simple name' => ['John Doe', ['', 'John', 'Doe', '']],
'name with title' => ['Dr. Jane Doe', ['Dr.', 'Jane', 'Doe', '']],
'name with title and 2nd title' => ['Dr. Max Mustermann, Junior', ['Dr.', 'Max', 'Mustermann', 'Junior']],
];
}
}

View File

@@ -1,104 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Domain\Model\Dto;
/**
* 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\Dto\Demand;
use TYPO3\TestingFramework\Core\BaseTestCase;
class DemandTest extends BaseTestCase
{
/** @var Demand */
protected $subject;
public function setup():void
{
$this->subject = new Demand();
}
/**
* @test
*/
public function pagesCanBeSet()
{
$value = ['123', '456'];
$this->subject->setPages($value);
$this->assertEquals($value, $this->subject->getPages());
}
/**
* @test
*/
public function sortByCanBeSet()
{
$value = 'title';
$this->subject->setSortBy($value);
$this->assertEquals($value, $this->subject->getSortBy());
}
/**
* @test
*/
public function sortOrderCanBeSet()
{
$value = 'desc';
$this->subject->setSortOrder($value);
$this->assertEquals($value, $this->subject->getSortOrder());
}
/**
* @test
*/
public function categoriesCanBeSet()
{
$value = '12,34,5';
$this->subject->setCategories($value);
$this->assertEquals($value, $this->subject->getCategories());
}
/**
* @test
*/
public function categoryCombinationCanBeSet()
{
$value = 'AND';
$this->subject->setCategoryCombination($value);
$this->assertEquals($value, $this->subject->getCategoryCombination());
}
/**
* @test
*/
public function singleRecordsCanBeSet()
{
$value = '7,6,1';
$this->subject->setSingleRecords($value);
$this->assertEquals($value, $this->subject->getSingleRecords());
}
/**
* @test
*/
public function includeSubCategoriesCanBeSet()
{
$value = true;
$this->subject->setIncludeSubCategories($value);
$this->assertEquals($value, $this->subject->getIncludeSubCategories());
}
/**
* @test
*/
public function ignoreWithoutCoordinatesCanBeSet()
{
$value = true;
$this->subject->setIgnoreWithoutCoordinates($value);
$this->assertEquals($value, $this->subject->getIgnoreWithoutCoordinates());
}
}

View File

@@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Domain\Model\Dto;
/**
* 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\Dto\Settings;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class SettingsTest extends BaseTestCase
{
use ProphecyTrait;
public function setUp(): void
{
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());
}
/**
* @test
*/
public function defaultSettingsAreAvailable()
{
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['tt_address'] = [];
$subject = new Settings();
$this->assertEquals('/[^\d\+\s\-]/', $subject->getTelephoneValidationPatternForPhp());
$this->assertEquals('/[^\d\+\s\-]/g', $subject->getTelephoneValidationPatternForJs());
}
/**
* @test
*/
public function settingsAreSet()
{
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['tt_address'] = [
'storeBackwardsCompatName' => false,
'readOnlyNameField' => false,
'telephoneValidationPatternForPhp' => 'regex1',
'telephoneValidationPatternForJs' => 'regex2',
];
$subject = new Settings();
$this->assertEquals('regex1', $subject->getTelephoneValidationPatternForPhp());
$this->assertEquals('regex2', $subject->getTelephoneValidationPatternForJs());
}
}

View File

@@ -1,76 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Evaluation\LatitudeEvaluation;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class LatitudeEvaluationTest extends BaseTestCase
{
use ProphecyTrait;
/** @var LatitudeEvaluation */
protected $subject;
public function setUp(): void
{
$this->subject = new LatitudeEvaluation();
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());
}
/**
* @test
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider latIsProperlyEvaluatedDataProvider
*/
public function latitudeIsProperlyEvaluated($given, $expected)
{
$this->assertEquals($expected, $this->subject->evaluateFieldValue($given));
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider latIsProperlyEvaluatedDataProvider
*/
public function latIsProperlyDeEvaluated($given, $expected)
{
$params = ['value' => $given];
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}
public function latIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
'int' => ['12', '12.00000000'],
'too large number' => ['95.33', '90.00000000'],
'regular float' => ['13.312113', '13.31211300'],
'negative regular float' => ['-13.312113', '-13.31211300'],
'long float' => ['-11.3121131111111111212121212', '-11.31211311'],
];
}
}

View File

@@ -1,76 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Evaluation\LongitudeEvaluation;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class LongitudeEvaluationTest extends BaseTestCase
{
use ProphecyTrait;
/** @var LongitudeEvaluation */
protected $subject;
public function setUp(): void
{
$this->subject = new LongitudeEvaluation();
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());
}
/**
* @test
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider lngIsProperlyEvaluatedDataProvider
*/
public function longIsProperlyEvaluated($given, $expected)
{
$this->assertEquals($expected, $this->subject->evaluateFieldValue($given));
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider lngIsProperlyEvaluatedDataProvider
*/
public function lngIsProperlyDeEvaluated($given, $expected)
{
$params = ['value' => $given];
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}
public function lngIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
'int' => ['12', '12.00000000'],
'too large number' => ['193.33', '180.00000000'],
'regular float' => ['13.312113', '13.31211300'],
'negative regular float' => ['-13.312113', '-13.31211300'],
'long float' => ['-11.3121131111111111212121212', '-11.31211311'],
];
}
}

View File

@@ -1,86 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Dto\Settings;
use FriendsOfTYPO3\TtAddress\Evaluation\TelephoneEvaluation;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class TelephoneEvaluationTest extends BaseTestCase
{
use ProphecyTrait;
/** @var TelephoneEvaluation */
protected $subject;
public function setUp(): void
{
$this->subject = new TelephoneEvaluation();
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());
}
/**
* @test
*/
public function constructorIsCalled()
{
$subject = $this->getAccessibleMock(TelephoneEvaluation::class, null, [], '', true);
$settings = new Settings();
$this->assertEquals($settings, $subject->_get('extensionSettings'));
}
/**
* @test
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider telephoneIsProperlyEvaluatedDataProvider
*/
public function telephoneIsProperlyEvaluated($given, $expected)
{
$this->assertEquals($expected, $this->subject->evaluateFieldValue($given));
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider telephoneIsProperlyEvaluatedDataProvider
*/
public function telephoneIsProperlyDeEvaluated($given, $expected)
{
$params = ['value' => $given];
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}
public function telephoneIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
'example 1' => ['+43 699 12 54 12 1', '+43 699 12 54 12 1'],
'example 2' => ['+43 (0)699 12 54 12 1', '+43 0699 12 54 12 1'],
'example 3' => [' +43 (0)699 12 54 12 1 DW:4 ', '+43 0699 12 54 12 1 4'],
];
}
}

View File

@@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTYPO3\TtAddress\Tests\Unit\Hooks\Tca;
/**
* 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\Hooks\Tca\AddFieldsToSelector;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\TestingFramework\Core\BaseTestCase;
class AddFieldsToSelectorTest extends BaseTestCase
{
/**
* @test
*/
public function constructorIsCalled()
{
$languageService = $this->getAccessibleMock(LanguageService::class, null, [], '', false, false);
$GLOBALS['LANG'] = $languageService;
$subject = $this->getAccessibleMock(AddFieldsToSelector::class, null, [], '', true);
$this->assertEquals($languageService, $subject->_get('languageService'));
}
/**
* @test
*/
public function optionsAreFilled()
{
foreach (AddFieldsToSelector::sortFields as $sortField) {
$GLOBALS['TCA']['tt_address']['columns'][$sortField]['label'] = 'label_' . $sortField;
}
$mockedLanguageService = $this->getAccessibleMock(LanguageService::class, ['sL'], [], '', false);
$mockedLanguageService->expects($this->any())
->method('sL')
->will($this->returnCallback(function ($o) {
return $o;
}));
$subject = $this->getAccessibleMock(AddFieldsToSelector::class, null, [], '', false);
$subject->_set('languageService', $mockedLanguageService);
$items = [];
$subject->main($items);
$expected = [
'items' => [
['label_address', 'address'],
['label_birthday', 'birthday'],
['label_building', 'building'],
['label_city', 'city'],
['label_company', 'company'],
['label_country', 'country'],
['label_email', 'email'],
['label_fax', 'fax'],
['label_first_name', 'first_name'],
['label_gender', 'gender'],
['label_last_name', 'last_name'],
['label_middle_name', 'middle_name'],
['label_mobile', 'mobile'],
['label_name', 'name'],
['label_phone', 'phone'],
['label_region', 'region'],
['label_room', 'room'],
['label_title', 'title'],
['label_www', 'www'],
['label_zip', 'zip'],
['LLL:EXT:tt_address/Resources/Private/Language/ff/locallang_ff.xlf:pi1_flexform.sortBy.singleSelection', 'singleSelection'],
]
];
$this->assertEquals($expected, $items);
}
}

View File

@@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTYPO3\TtAddress\Tests\Unit\Seo;
/**
* 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\Seo\AddressTitleProvider;
use TYPO3\TestingFramework\Core\BaseTestCase;
class AddressTitleProviderTest extends BaseTestCase
{
/**
* @test
* @dataProvider addressTitleProvider
* @param string $expected
* @param string[] $addressFields
* @param array $configuration
*/
public function correctTitleIsGenerated(string $expected, array $addressFields, array $configuration): void
{
$address = new Address();
foreach ($addressFields as $fieldName => $value) {
$setter = 'set' . ucfirst($fieldName);
$address->$setter($value);
}
$mockedProvider = $this->getAccessibleMock(AddressTitleProvider::class, null, [], '', false);
$mockedProvider->setTitle($address, $configuration);
$this->assertEquals($expected, $mockedProvider->getTitle());
}
public function addressTitleProvider(): array
{
return [
'basic example' => [
'Max Mustermann',
[
'firstName' => 'Max',
'middleName' => '',
'lastName' => 'Mustermann'
],
[
'properties' => 'firstName,middleName,lastName'
]
],
'custom clue' => [
'Max - M. - Mustermann',
[
'firstName' => 'Max',
'middleName' => 'M.',
'lastName' => 'Mustermann'
],
[
'properties' => 'firstName,middleName,lastName',
'glue' => '" - "'
]
],
'empty custom clue' => [
'Max M. Mustermann',
[
'firstName' => 'Max',
'middleName' => 'M.',
'lastName' => 'Mustermann'
],
[
'properties' => 'firstName,middleName,lastName',
'glue' => ''
]
]
];
}
}

View File

@@ -1,69 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTYPO3\TtAddress\Tests\Unit\Service;
use FriendsOfTYPO3\TtAddress\Service\GeocodeService;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class GeocodeServiceTest extends BaseTestCase
{
use ProphecyTrait;
/**
* @test
*/
public function validAPiResultIsReturned()
{
$content = ['status' => 200, 'CONTENT' => 123];
$stream = $this->prophesize(StreamInterface::class);
$stream->getContents()->willReturn(json_encode($content));
$response = $this->prophesize(ResponseInterface::class);
$response->getBody()->willReturn($stream);
$requestFactory = $this->prophesize(RequestFactory::class);
$requestFactory->request(Argument::cetera())->willReturn($response);
GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com');
$this->assertEquals($content, $apiResponse);
}
/**
* @test
*/
public function invalidAPiResultReturnsEmptyArray()
{
$content = ['status' => 'OVER_QUERY_LIMIT', 'CONTENT' => 123];
$stream = $this->prophesize(StreamInterface::class);
$stream->getContents()->willReturn(json_encode($content));
$response = $this->prophesize(ResponseInterface::class);
$response->getBody()->willReturn($stream);
$requestFactory = $this->prophesize(RequestFactory::class);
$requestFactory->request(Argument::cetera())->willReturn($response);
GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com');
$this->assertEquals([], $apiResponse);
}
/**
* @test
*/
public function wrongCacheThrowsException()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1548785854);
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$subject->_call('initializeCache', 'notExisting');
}
}

View File

@@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Utility\CacheUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\TestingFramework\Core\BaseTestCase;
class CacheUtilityTest extends BaseTestCase
{
protected function setUp():void
{
$GLOBALS['TSFE'] = $this->getAccessibleMock(
TypoScriptFrontendController::class,
['addCacheTags'],
[],
'',
false
);
}
/**
* @test
*/
public function nonArrayRecordInstancesAreSkippedForCacheTags()
{
$addressRecords = ['dummy string'];
$GLOBALS['TSFE']->expects($this->once())->method('addCacheTags')->with([]);
CacheUtility::addCacheTagsByAddressRecords($addressRecords);
}
/**
* @test
*/
public function addressRecordWithLocalizedIdAddsCacheTags()
{
$addressRecord = new Address();
$addressRecord->_setProperty('uid', 42);
$addressRecord->_setProperty('_localizedUid', 43);
$addressRecords = [$addressRecord];
$GLOBALS['TSFE']->expects($this->once())->method('addCacheTags')->with(['tt_address_42', 'tt_address_43']);
CacheUtility::addCacheTagsByAddressRecords($addressRecords);
}
}

View File

@@ -1,62 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Utility\EvalcoordinatesUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;
class EvalcoordinatesUtilityTest extends BaseTestCase
{
/**
* @param $given
* @param $expected
* @test
* @dataProvider longIsProperlyEvaluatedDataProvider
*/
public function longIsProperlyEvaluated($given, $expected)
{
$this->assertEquals($expected, EvalcoordinatesUtility::formatLongitude($given));
}
public function longIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', '.00000000'],
'int' => ['12', '12.00000000'],
'too large number' => ['193.33', '180.00000000'],
'regular float' => ['13.312113', '13.31211300'],
'negative regular float' => ['-13.312113', '-13.31211300'],
'long float' => ['-11.3121131111111111212121212', '-11.31211311'],
];
}
/**
* @param $given
* @param $expected
* @test
* @dataProvider latIsProperlyEvaluatedDataProvider
*/
public function latIsProperlyEvaluated($given, $expected)
{
$this->assertEquals($expected, EvalcoordinatesUtility::formatLatitude($given));
}
public function latIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', '.00000000'],
'int' => ['12', '12.00000000'],
'too large number' => ['95.33', '90.00000000'],
'regular float' => ['13.312113', '13.31211300'],
'negative regular float' => ['-13.312113', '-13.31211300'],
'long float' => ['-11.3121131111111111212121212', '-11.31211311'],
];
}
}

View File

@@ -1,75 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\Utility;
/**
* 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\Utility\TypoScript;
use TYPO3\TestingFramework\Core\BaseTestCase;
class TypoScriptTest extends BaseTestCase
{
/**
* @test
*/
public function tsIsOverloadedCorrectly()
{
$subject = new TypoScript();
$flexforms = [
'default1' => 'value',
'default_as_array' => [
'sub' => 'value sub',
'sub_array' => [
'sub_sub' => 'sub_sub_value'
]
],
'override_empty' => '',
'override_int' => '0',
'override_not_empty' => 'content_already_here',
'override_sub' => [
'sub_empty' => '',
'sub_full' => 'sub_value',
'sub_standalone' => 'standalone'
],
];
$tsData = [
'settings' => [
'overrideFlexformSettingsIfEmpty' => 'override_empty,override_not_existing,override_int_empty,override_not_empty,override_sub.sub_empty,override_sub.sub_full,override_sub.sub_notexisting',
'override_empty' => 'a_value',
'override_not_empty' => 'new_content',
'override_int' => 'int fallback',
'override_sub' => [
'sub_empty' => 'some_value',
'sub_full' => 'sub_value_2',
'sub_standalone_2' => 'standalone'
]
]
];
$expected = [
'default1' => 'value',
'default_as_array' => [
'sub' => 'value sub',
'sub_array' => [
'sub_sub' => 'sub_sub_value'
]
],
'override_empty' => 'a_value',
'override_not_empty' => 'content_already_here',
'override_int' => '0',
'override_sub' => [
'sub_empty' => 'some_value',
'sub_full' => 'sub_value',
'sub_standalone' => 'standalone'
]
];
$this->assertEquals($expected, $subject->override($flexforms, $tsData));
}
}

View File

@@ -1,47 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\ViewHelpers;
/**
* 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\ViewHelpers\RemoveSpacesViewHelper;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\TestingFramework\Core\BaseTestCase;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
class RemoveSpacesViewHelperTest extends BaseTestCase
{
use ProphecyTrait;
/**
* @var RemoveSpacesViewHelper
*/
protected $viewHelper;
protected function setUp(): void
{
parent::setUp();
$this->viewHelper = new RemoveSpacesViewHelper();
$this->viewHelper->initializeArguments();
}
/**
* @test
*/
public function spacelessVhIsCalled()
{
$actualResult = $this->viewHelper->renderStatic(
['value' => ' +43 123 56 34 34 '],
function () {
},
$this->prophesize(RenderingContextInterface::class)->reveal()
);
$this->assertEquals('+43123563434', $actualResult);
}
}

View File

@@ -1,91 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTypo3\TtAddress\Tests\Unit\ViewHelpers;
/**
* 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\ViewHelpers\StaticGoogleMapsViewHelper;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\TestingFramework\Core\BaseTestCase;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
class StaticGoogleMapsViewHelperTest extends BaseTestCase
{
use ProphecyTrait;
/**
* @var StaticGoogleMapsViewHelper
*/
protected $viewHelper;
protected function setUp():void
{
parent::setUp();
$this->viewHelper = new StaticGoogleMapsViewHelper();
$this->viewHelper->initializeArguments();
}
/**
* @test
* @dataProvider staticGoogleMapsViewHelpersIsCalledDataProvider
*/
public function staticGoogleMapsViewHelpersIsCalled(array $parameters, $result)
{
$actualResult = $this->viewHelper->renderStatic(
$parameters,
function () {
},
$this->prophesize(RenderingContextInterface::class)->reveal()
);
$this->assertEquals($result, $actualResult);
}
public function staticGoogleMapsViewHelpersIsCalledDataProvider(): array
{
$address1 = new Address();
$address1->setLatitude(1.1);
$address1->setLongitude(1.2);
$address2 = new Address();
$address2->setLatitude(2.1);
$address2->setLongitude(2.2);
$addresses1 = new ObjectStorage();
$addresses1->attach($address1);
$addresses2 = new ObjectStorage();
$addresses2->attach($address1);
$addresses2->attach($address2);
return [
'1 address' => [
[
'parameters' => [
'key' => 'abcdefgh',
'size' => '300x400',
],
'addresses' => $addresses1
],
'https://maps.googleapis.com/maps/api/staticmap?&key=abcdefgh&size=300x400&zoom=13&markers=1.1,1.2'
],
'2 addresses' => [
[
'parameters' => [
'key' => 'abcdefgh',
'size' => '300x400',
],
'addresses' => $addresses2
],
'https://maps.googleapis.com/maps/api/staticmap?&key=abcdefgh&size=300x400&markers=1.1,1.2&markers=2.1,2.2'
]
];
}
}

View File

@@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace FriendsOfTYPO3\TtAddress\Tests\UnitDeprecated\FormEngine\FieldControl;
/**
* 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\FormEngine\FieldControl\LocationMapWizard;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\TestingFramework\Core\BaseTestCase;
class LocationMapWizardTest extends BaseTestCase
{
/**
* @test
*/
public function languageServiceIsReturned()
{
$languageService = $this->getAccessibleMock(LanguageService::class, null, [], '', false, false);
$GLOBALS['LANG'] = $languageService;
$subject = $this->getAccessibleMock(LocationMapWizard::class, null, [], '', false);
$this->assertEquals($languageService, $subject->_call('getLanguageService'));
}
/**
* @test
*/
public function properResultArrayIsReturned()
{
$languageService = $this->getAccessibleMock(LanguageService::class, ['sL'], [], '', false);
$languageService->expects($this->any())->method('sL')->willReturn('label');
$subject = $this->getAccessibleMock(LocationMapWizard::class, ['getLanguageService'], [], '', false);
$subject->expects($this->any())->method('getLanguageService')->willReturn($languageService);
$data = [
'databaseRow' => [
'latitude' => '12.1212',
'longitude' => '45.1212',
],
'parameterArray' => [
'itemFormElName' => 'elName',
],
];
$subject->_set('data', $data);
$result = $subject->render();
$this->assertEquals('location-map-wizard', $result['iconIdentifier']);
}
}

View File

@@ -1,45 +1,28 @@
<?php
/***************************************************************
* Extension Manager/Repository config file for ext "tt_address".
*
* Auto generated 15-10-2025 10:40
*
* Manual updates:
* Only the data in the array - everything else is removed by next
* writing. "version" and "dependencies" must not be touched!
***************************************************************/
$EM_CONF[$_EXTKEY] = array (
'title' => 'Address List',
'description' => 'Displays a list of addresses from an address table on the page.',
'category' => 'plugin',
'version' => '8.1.1',
'state' => 'stable',
'uploadfolder' => false,
'clearcacheonload' => true,
'author' => 'tt_address Development Team',
'author_email' => 'friendsof@typo3.org',
'author_company' => NULL,
'constraints' =>
array (
'depends' =>
array (
'typo3' => '11.5.0-12.4.99',
),
'conflicts' =>
array (
),
'suggests' =>
array (
),
),
'autoload' =>
array (
'psr-4' =>
array (
'FriendsOfTYPO3\\TtAddress\\' => 'Classes',
),
),
);
$EM_CONF[$_EXTKEY] = [
'title' => 'Address List',
'description' => 'Displays a list of addresses from an address table on the page.',
'category' => 'plugin',
'state' => 'stable',
'clearCacheOnLoad' => true,
'author' => 'tt_address Development Team',
'author_email' => 'friendsof@typo3.org',
'version' => '8.1.1',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-12.4.99',
],
'conflicts' => [
],
'suggests' => [
],
],
'autoload' => [
'psr-4' => ['FriendsOfTYPO3\\TtAddress\\' => 'Classes']
],
'autoload-dev' =>
[
'psr-4' => ['FriendsOfTYPO3\\TtAddress\\Tests\\' => 'Tests']
],
];