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