Initial commit - Typo3 11.5.41
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user