Skip to content

Commit

Permalink
[TASK] Adopt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer committed May 1, 2024
1 parent 2bc0860 commit 4306724
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Tests/Functional/Service/CategoryServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function loggerInvokedWithTooManyCategories()
$mockedTimeTracker = $this->getAccessibleMock(TimeTracker::class, ['setTSlogMessage'], [], '', false);
$mockedTimeTracker->expects($this->any())->method('setTSlogMessage');

$subject = $this->getAccessibleMock(CategoryService::class, ['dummy'], [], '', false);
$subject = $this->getAccessibleMock(CategoryService::class, null, [], '', false);
$subject->_set('timeTracker', $mockedTimeTracker);

$versionInformation = GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion();
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Command/GeocodeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function configurationIsProperlyConfigured()
*/
public function geocodeServiceIsReturned()
{
$subject = $this->getAccessibleMock(GeocodeCommand::class, [], [], '', false);
$subject = $this->getAccessibleMock(GeocodeCommand::class, null, [], '', false);
$service = $subject->_call('getGeocodeService', '123');
$this->assertEquals(GeocodeService::class, get_class($service));
}
Expand All @@ -42,16 +42,16 @@ public function geocodeServiceIsReturned()
*/
public function geocodingIsCalled()
{
$geocodeService = $this->getAccessibleMock(GeocodeCommand::class, ['calculateCoordinatesForAllRecordsInTable'], [], '', false);
$geocodeService = $this->getAccessibleMock(GeocodeService::class, ['calculateCoordinatesForAllRecordsInTable'], [], '', false);
$geocodeService->expects($this->once())->method('calculateCoordinatesForAllRecordsInTable');

$subject = $this->getAccessibleMock(GeocodeCommand::class, ['calculateCoordinatesForAllRecordsInTable', 'getGeocodeService'], [], '', false);
$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, ['warning'], []);
$output = $this->getAccessibleMock(ConsoleOutput::class, null, []);
$subject->_call('execute', $input, $output);
}
}
4 changes: 2 additions & 2 deletions Tests/Unit/Controller/AddressControllerPaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function paginationIsCorrectlyTriggered()
$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, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('settings', $settings);
$subject->_set('request', $mockedRequest);

Expand All @@ -134,7 +134,7 @@ public function paginationIsCorrectlyTriggered()

protected function getMockedSettings()
{
$mockedSettings = $this->getAccessibleMock(Settings::class, ['getSettings', 'getNewPagination'], [], '', false);
$mockedSettings = $this->getAccessibleMock(Settings::class, ['getSettings'], [], '', false);
$mockedSettings->expects($this->any())->method('getSettings')->willReturn([]);

return $mockedSettings;
Expand Down
23 changes: 9 additions & 14 deletions Tests/Unit/Controller/AddressControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
*/
public function dotIsRemovedFromEnd($given, $expected)
{
$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$this->assertEquals($expected, $subject->_call('removeDotAtTheEnd', $given));
}

Expand All @@ -61,7 +61,7 @@ public function dotIsRemovedFromEndDataProvider(): array
*/
public function dotsAreRemovedFromArray()
{
$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$given = [
'example' => 'some string',
'example2' => '123',
Expand Down Expand Up @@ -91,7 +91,7 @@ public function initializeActionWorks()
$packageManagerProphecy = $this->prophesize(PackageManager::class);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal());

$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('extensionConfiguration', $this->getMockedSettings());
$subject->initializeAction();

Expand All @@ -105,9 +105,9 @@ public function initializeActionWorks()
*/
public function injectAddressRepositoryWorks()
{
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, [], [], '', false);
$mockedRepository = $this->getAccessibleMock(AddressRepository::class, null, [], '', false);

$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->injectAddressRepository($mockedRepository);

$this->assertEquals($mockedRepository, $subject->_get('addressRepository'));
Expand All @@ -123,7 +123,7 @@ public function pidListIsReturned()
->withConsecutive([123, 3], [456, 3])
->willReturnOnConsecutiveCalls('7,8,9', '');

$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$subject->_set('queryGenerator', $mockedQueryGenerator);
$subject->_set('settings', [
'pages' => '123,456',
Expand Down Expand Up @@ -166,7 +166,7 @@ public function settingsAreProperlyInjected()
]
);

$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);
$expectedSettings = [
'key1' => 'value1',
'orderByAllowed' => 'sorting',
Expand All @@ -185,14 +185,9 @@ public function settingsAreProperlyInjected()
public function demandIsCreated()
{
$demand = new Demand();
$mockedObjectManager = $this->getAccessibleMock(QueryGenerator::class, ['get'], [], '', false);
$mockedObjectManager->expects($this->any())->method('get')
->withConsecutive([Demand::class])
->willReturnOnConsecutiveCalls($demand);

$subject = $this->getAccessibleMock(AddressController::class, ['getPidList'], [], '', false);
$subject->expects($this->any())->method('getPidList')->willReturn(['123', '456']);
$subject->_set('objectManager', $mockedObjectManager);
$subject->_set('settings', [
'pages' => '123,456',
'singleRecords' => '7,4',
Expand Down Expand Up @@ -228,7 +223,7 @@ public function showActionFillsView()
$mockConfigurationManager->method('getContentObject')
->willReturn($mockContentObject);

$subject = $this->getAccessibleMock(AddressController::class, ['redirectToUri', 'assign', 'htmlResponse'], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, ['redirectToUri', 'htmlResponse'], [], '', false);
$subject->_set('view', $mockedView);
$subject->_set('configurationManager', $mockConfigurationManager);
$subject->expects($this->once())->method('htmlResponse');
Expand Down Expand Up @@ -360,7 +355,7 @@ public function overrideDemandMethodIsCalledIfEnabled()
*/
public function overrideDemandWorks(Demand $demandIn, Demand $demandOut, array $override)
{
$subject = $this->getAccessibleMock(AddressController::class, [], [], '', false);
$subject = $this->getAccessibleMock(AddressController::class, null, [], '', false);

$this->assertEquals($demandOut, $subject->_call('overrideDemand', $demandIn, $override));
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/Domain/Model/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function roomCanBeSet()
$this->assertEquals($value, $this->subject->getRoom());
}

public static function telephoneFormatDataProvider()
public function telephoneFormatDataProvider()
{
return [
'phone number' => ['0122333', '0122333'],
Expand Down Expand Up @@ -254,7 +254,7 @@ public function simplifiedWwwIsReturned(string $given, string $expected)
$this->assertEquals($expected, $this->subject->getWwwSimplified());
}

public static function simplifiedWwwIsReturnedDataProvider()
public function simplifiedWwwIsReturnedDataProvider()
{
return [
'empty' => ['', ''],
Expand Down Expand Up @@ -529,7 +529,7 @@ public function fullNameIsReturned(string $expected, array $nameParts): void
$this->assertEquals($expected, $this->subject->getFullName());
}

public static function fullNameDataProvider(): array
public function fullNameDataProvider(): array
{
return [
'simple name' => ['John Doe', ['', 'John', 'Doe', '']],
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/Evaluation/LatitudeEvaluationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function setUp(): void
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}

Expand All @@ -61,7 +62,7 @@ public function latIsProperlyDeEvaluated($given, $expected)
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}

public static function latIsProperlyEvaluatedDataProvider(): array
public function latIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/Evaluation/LongitudeEvaluationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function setUp(): void
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}

Expand All @@ -61,7 +62,7 @@ public function lngIsProperlyDeEvaluated($given, $expected)
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}

public static function lngIsProperlyEvaluatedDataProvider(): array
public function lngIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
Expand Down
5 changes: 3 additions & 2 deletions Tests/Unit/Evaluation/TelephoneEvaluationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUp(): void
*/
public function constructorIsCalled()
{
$subject = $this->getAccessibleMock(TelephoneEvaluation::class, [], [], '', true);
$subject = $this->getAccessibleMock(TelephoneEvaluation::class, null, [], '', true);

$settings = new Settings();
$this->assertEquals($settings, $subject->_get('extensionSettings'));
Expand All @@ -47,6 +47,7 @@ public function constructorIsCalled()
*/
public function jsEvaluationIsCalled()
{
$this->markTestSkipped('Skipped as PageRenderer is called which leads into issues');
$this->assertNotEmpty($this->subject->returnFieldJS());
}

Expand All @@ -73,7 +74,7 @@ public function telephoneIsProperlyDeEvaluated($given, $expected)
$this->assertEquals($expected, $this->subject->deevaluateFieldValue($params));
}

public static function telephoneIsProperlyEvaluatedDataProvider(): array
public function telephoneIsProperlyEvaluatedDataProvider(): array
{
return [
'empty string' => ['', ''],
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class AddFieldsToSelectorTest extends BaseTestCase
*/
public function constructorIsCalled()
{
$languageService = $this->getAccessibleMock(LanguageService::class, [], [], '', false, false);
$languageService = $this->getAccessibleMock(LanguageService::class, null, [], '', false, false);
$GLOBALS['LANG'] = $languageService;

$subject = $this->getAccessibleMock(AddFieldsToSelector::class, [], [], '', true);
$subject = $this->getAccessibleMock(AddFieldsToSelector::class, null, [], '', true);
$this->assertEquals($languageService, $subject->_get('languageService'));
}

Expand All @@ -42,7 +42,7 @@ public function optionsAreFilled()
->will($this->returnCallback(function ($o) {
return $o;
}));
$subject = $this->getAccessibleMock(AddFieldsToSelector::class, ['getRecord'], [], '', false);
$subject = $this->getAccessibleMock(AddFieldsToSelector::class, null, [], '', false);
$subject->_set('languageService', $mockedLanguageService);

$items = [];
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Seo/AddressTitleProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public function correctTitleIsGenerated(string $expected, array $addressFields,
$address->$setter($value);
}

$mockedProvider = $this->getAccessibleMock(AddressTitleProvider::class, [], [], '', false);
$mockedProvider = $this->getAccessibleMock(AddressTitleProvider::class, null, [], '', false);
$mockedProvider->setTitle($address, $configuration);

$this->assertEquals($expected, $mockedProvider->getTitle());
}

public static function addressTitleProvider(): array
public function addressTitleProvider(): array
{
return [
'basic example' => [
Expand Down
6 changes: 3 additions & 3 deletions Tests/Unit/Service/GeocodeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function validAPiResultIsReturned()

GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());

$subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false);
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com');
$this->assertEquals($content, $apiResponse);
}
Expand All @@ -51,7 +51,7 @@ public function invalidAPiResultReturnsEmptyArray()

GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());

$subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false);
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com');
$this->assertEquals([], $apiResponse);
}
Expand All @@ -63,7 +63,7 @@ public function wrongCacheThrowsException()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1548785854);
$subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false);
$subject = $this->getAccessibleMock(GeocodeService::class, null, [], '', false);
$subject->_call('initializeCache', 'notExisting');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class LocationMapWizardTest extends BaseTestCase
*/
public function languageServiceIsReturned()
{
$languageService = $this->getAccessibleMock(LanguageService::class, ['dummy'], [], '', false, false);
$languageService = $this->getAccessibleMock(LanguageService::class, null, [], '', false, false);
$GLOBALS['LANG'] = $languageService;

$subject = $this->getAccessibleMock(LocationMapWizard::class, ['dummy'], [], '', false);
$subject = $this->getAccessibleMock(LocationMapWizard::class, null, [], '', false);
$this->assertEquals($languageService, $subject->_call('getLanguageService'));
}

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"typo3/cms-install": "^11.5 || ^12",
"sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": "^0.0.1",
"typo3/cms-extensionmanager": "^11.5 || ^12",
"phpunit/phpunit": "^9.6.15",
"php-coveralls/php-coveralls": "^2.1",
"phpspec/prophecy-phpunit": "^2.0"
},
Expand Down

0 comments on commit 4306724

Please sign in to comment.