From 8bfd611b106307bdb88e77e56e2ace834a70bc94 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 10:27:22 +0200 Subject: [PATCH 1/7] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52698ff7..3a80db6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 continue-on-error: ${{ matrix.env.experimental == true }} strategy: From 2bc08609492ce20d24977dd4b7af98d8669f81de Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 10:44:56 +0200 Subject: [PATCH 2/7] [TASK] Test test changes --- Tests/Unit/Command/GeocodeCommandTest.php | 2 +- .../AddressControllerPaginationTest.php | 2 +- Tests/Unit/Controller/AddressControllerTest.php | 16 ++++++++-------- Tests/Unit/Domain/Model/AddressTest.php | 6 +++--- Tests/Unit/Evaluation/LatitudeEvaluationTest.php | 2 +- .../Unit/Evaluation/LongitudeEvaluationTest.php | 2 +- .../Unit/Evaluation/TelephoneEvaluationTest.php | 4 ++-- Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php | 4 ++-- Tests/Unit/Seo/AddressTitleProviderTest.php | 4 ++-- Tests/Unit/Service/GeocodeServiceTest.php | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Tests/Unit/Command/GeocodeCommandTest.php b/Tests/Unit/Command/GeocodeCommandTest.php index 80c11900..84e68f74 100644 --- a/Tests/Unit/Command/GeocodeCommandTest.php +++ b/Tests/Unit/Command/GeocodeCommandTest.php @@ -32,7 +32,7 @@ public function configurationIsProperlyConfigured() */ public function geocodeServiceIsReturned() { - $subject = $this->getAccessibleMock(GeocodeCommand::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(GeocodeCommand::class, [], [], '', false); $service = $subject->_call('getGeocodeService', '123'); $this->assertEquals(GeocodeService::class, get_class($service)); } diff --git a/Tests/Unit/Controller/AddressControllerPaginationTest.php b/Tests/Unit/Controller/AddressControllerPaginationTest.php index 998dc3b1..9da2d985 100644 --- a/Tests/Unit/Controller/AddressControllerPaginationTest.php +++ b/Tests/Unit/Controller/AddressControllerPaginationTest.php @@ -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, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $subject->_set('settings', $settings); $subject->_set('request', $mockedRequest); diff --git a/Tests/Unit/Controller/AddressControllerTest.php b/Tests/Unit/Controller/AddressControllerTest.php index de815280..2960511d 100644 --- a/Tests/Unit/Controller/AddressControllerTest.php +++ b/Tests/Unit/Controller/AddressControllerTest.php @@ -44,7 +44,7 @@ protected function setUp(): void */ public function dotIsRemovedFromEnd($given, $expected) { - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $this->assertEquals($expected, $subject->_call('removeDotAtTheEnd', $given)); } @@ -61,7 +61,7 @@ public function dotIsRemovedFromEndDataProvider(): array */ public function dotsAreRemovedFromArray() { - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $given = [ 'example' => 'some string', 'example2' => '123', @@ -91,7 +91,7 @@ public function initializeActionWorks() $packageManagerProphecy = $this->prophesize(PackageManager::class); GeneralUtility::setSingletonInstance(PackageManager::class, $packageManagerProphecy->reveal()); - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $subject->_set('extensionConfiguration', $this->getMockedSettings()); $subject->initializeAction(); @@ -105,9 +105,9 @@ public function initializeActionWorks() */ public function injectAddressRepositoryWorks() { - $mockedRepository = $this->getAccessibleMock(AddressRepository::class, ['dummy'], [], '', false); + $mockedRepository = $this->getAccessibleMock(AddressRepository::class, [], [], '', false); - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $subject->injectAddressRepository($mockedRepository); $this->assertEquals($mockedRepository, $subject->_get('addressRepository')); @@ -123,7 +123,7 @@ public function pidListIsReturned() ->withConsecutive([123, 3], [456, 3]) ->willReturnOnConsecutiveCalls('7,8,9', ''); - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $subject->_set('queryGenerator', $mockedQueryGenerator); $subject->_set('settings', [ 'pages' => '123,456', @@ -166,7 +166,7 @@ public function settingsAreProperlyInjected() ] ); - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $expectedSettings = [ 'key1' => 'value1', 'orderByAllowed' => 'sorting', @@ -360,7 +360,7 @@ public function overrideDemandMethodIsCalledIfEnabled() */ public function overrideDemandWorks(Demand $demandIn, Demand $demandOut, array $override) { - $subject = $this->getAccessibleMock(AddressController::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(AddressController::class, [], [], '', false); $this->assertEquals($demandOut, $subject->_call('overrideDemand', $demandIn, $override)); } diff --git a/Tests/Unit/Domain/Model/AddressTest.php b/Tests/Unit/Domain/Model/AddressTest.php index c75cc977..1b0a0c12 100644 --- a/Tests/Unit/Domain/Model/AddressTest.php +++ b/Tests/Unit/Domain/Model/AddressTest.php @@ -146,7 +146,7 @@ public function roomCanBeSet() $this->assertEquals($value, $this->subject->getRoom()); } - public function telephoneFormatDataProvider() + public static function telephoneFormatDataProvider() { return [ 'phone number' => ['0122333', '0122333'], @@ -254,7 +254,7 @@ public function simplifiedWwwIsReturned(string $given, string $expected) $this->assertEquals($expected, $this->subject->getWwwSimplified()); } - public function simplifiedWwwIsReturnedDataProvider() + public static function simplifiedWwwIsReturnedDataProvider() { return [ 'empty' => ['', ''], @@ -529,7 +529,7 @@ public function fullNameIsReturned(string $expected, array $nameParts): void $this->assertEquals($expected, $this->subject->getFullName()); } - public function fullNameDataProvider(): array + public static function fullNameDataProvider(): array { return [ 'simple name' => ['John Doe', ['', 'John', 'Doe', '']], diff --git a/Tests/Unit/Evaluation/LatitudeEvaluationTest.php b/Tests/Unit/Evaluation/LatitudeEvaluationTest.php index 6fe46713..f718d6e7 100644 --- a/Tests/Unit/Evaluation/LatitudeEvaluationTest.php +++ b/Tests/Unit/Evaluation/LatitudeEvaluationTest.php @@ -61,7 +61,7 @@ public function latIsProperlyDeEvaluated($given, $expected) $this->assertEquals($expected, $this->subject->deevaluateFieldValue($params)); } - public function latIsProperlyEvaluatedDataProvider(): array + public static function latIsProperlyEvaluatedDataProvider(): array { return [ 'empty string' => ['', ''], diff --git a/Tests/Unit/Evaluation/LongitudeEvaluationTest.php b/Tests/Unit/Evaluation/LongitudeEvaluationTest.php index 6fac24f8..71c13d92 100644 --- a/Tests/Unit/Evaluation/LongitudeEvaluationTest.php +++ b/Tests/Unit/Evaluation/LongitudeEvaluationTest.php @@ -61,7 +61,7 @@ public function lngIsProperlyDeEvaluated($given, $expected) $this->assertEquals($expected, $this->subject->deevaluateFieldValue($params)); } - public function lngIsProperlyEvaluatedDataProvider(): array + public static function lngIsProperlyEvaluatedDataProvider(): array { return [ 'empty string' => ['', ''], diff --git a/Tests/Unit/Evaluation/TelephoneEvaluationTest.php b/Tests/Unit/Evaluation/TelephoneEvaluationTest.php index 94664a53..802107f0 100644 --- a/Tests/Unit/Evaluation/TelephoneEvaluationTest.php +++ b/Tests/Unit/Evaluation/TelephoneEvaluationTest.php @@ -36,7 +36,7 @@ public function setUp(): void */ public function constructorIsCalled() { - $subject = $this->getAccessibleMock(TelephoneEvaluation::class, ['dummy'], [], '', true); + $subject = $this->getAccessibleMock(TelephoneEvaluation::class, [], [], '', true); $settings = new Settings(); $this->assertEquals($settings, $subject->_get('extensionSettings')); @@ -73,7 +73,7 @@ public function telephoneIsProperlyDeEvaluated($given, $expected) $this->assertEquals($expected, $this->subject->deevaluateFieldValue($params)); } - public function telephoneIsProperlyEvaluatedDataProvider(): array + public static function telephoneIsProperlyEvaluatedDataProvider(): array { return [ 'empty string' => ['', ''], diff --git a/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php b/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php index 4720a070..a20ca9ca 100755 --- a/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php +++ b/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php @@ -20,10 +20,10 @@ class AddFieldsToSelectorTest extends BaseTestCase */ public function constructorIsCalled() { - $languageService = $this->getAccessibleMock(LanguageService::class, ['dummy'], [], '', false, false); + $languageService = $this->getAccessibleMock(LanguageService::class, [], [], '', false, false); $GLOBALS['LANG'] = $languageService; - $subject = $this->getAccessibleMock(AddFieldsToSelector::class, ['dummy'], [], '', true); + $subject = $this->getAccessibleMock(AddFieldsToSelector::class, [], [], '', true); $this->assertEquals($languageService, $subject->_get('languageService')); } diff --git a/Tests/Unit/Seo/AddressTitleProviderTest.php b/Tests/Unit/Seo/AddressTitleProviderTest.php index a07fc63c..c4af7a95 100755 --- a/Tests/Unit/Seo/AddressTitleProviderTest.php +++ b/Tests/Unit/Seo/AddressTitleProviderTest.php @@ -30,13 +30,13 @@ public function correctTitleIsGenerated(string $expected, array $addressFields, $address->$setter($value); } - $mockedProvider = $this->getAccessibleMock(AddressTitleProvider::class, ['dummy'], [], '', false); + $mockedProvider = $this->getAccessibleMock(AddressTitleProvider::class, [], [], '', false); $mockedProvider->setTitle($address, $configuration); $this->assertEquals($expected, $mockedProvider->getTitle()); } - public function addressTitleProvider(): array + public static function addressTitleProvider(): array { return [ 'basic example' => [ diff --git a/Tests/Unit/Service/GeocodeServiceTest.php b/Tests/Unit/Service/GeocodeServiceTest.php index 3bfd6747..7a85193c 100644 --- a/Tests/Unit/Service/GeocodeServiceTest.php +++ b/Tests/Unit/Service/GeocodeServiceTest.php @@ -31,7 +31,7 @@ public function validAPiResultIsReturned() GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal()); - $subject = $this->getAccessibleMock(GeocodeService::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false); $apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com'); $this->assertEquals($content, $apiResponse); } @@ -51,7 +51,7 @@ public function invalidAPiResultReturnsEmptyArray() GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal()); - $subject = $this->getAccessibleMock(GeocodeService::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false); $apiResponse = $subject->_call('getApiCallResult', 'http://dummy.com'); $this->assertEquals([], $apiResponse); } @@ -63,7 +63,7 @@ public function wrongCacheThrowsException() { $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1548785854); - $subject = $this->getAccessibleMock(GeocodeService::class, ['dummy'], [], '', false); + $subject = $this->getAccessibleMock(GeocodeService::class, [], [], '', false); $subject->_call('initializeCache', 'notExisting'); } } From 4306724e779f9cb205bde46d5aa5d5d42e99f6ed Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 11:11:49 +0200 Subject: [PATCH 3/7] [TASK] Adopt tests --- .../Service/CategoryServiceTest.php | 2 +- Tests/Unit/Command/GeocodeCommandTest.php | 8 +++---- .../AddressControllerPaginationTest.php | 4 ++-- .../Unit/Controller/AddressControllerTest.php | 23 ++++++++----------- Tests/Unit/Domain/Model/AddressTest.php | 6 ++--- .../Evaluation/LatitudeEvaluationTest.php | 3 ++- .../Evaluation/LongitudeEvaluationTest.php | 3 ++- .../Evaluation/TelephoneEvaluationTest.php | 5 ++-- .../Hooks/Tca/AddFieldsToSelectorTest.php | 6 ++--- Tests/Unit/Seo/AddressTitleProviderTest.php | 4 ++-- Tests/Unit/Service/GeocodeServiceTest.php | 6 ++--- .../FieldControl/LocationMapWizardTest.php | 4 ++-- composer.json | 1 + 13 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Tests/Functional/Service/CategoryServiceTest.php b/Tests/Functional/Service/CategoryServiceTest.php index fec724c2..8e862a15 100644 --- a/Tests/Functional/Service/CategoryServiceTest.php +++ b/Tests/Functional/Service/CategoryServiceTest.php @@ -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(); diff --git a/Tests/Unit/Command/GeocodeCommandTest.php b/Tests/Unit/Command/GeocodeCommandTest.php index 84e68f74..fe6469f5 100644 --- a/Tests/Unit/Command/GeocodeCommandTest.php +++ b/Tests/Unit/Command/GeocodeCommandTest.php @@ -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)); } @@ -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); } } diff --git a/Tests/Unit/Controller/AddressControllerPaginationTest.php b/Tests/Unit/Controller/AddressControllerPaginationTest.php index 9da2d985..d0958009 100644 --- a/Tests/Unit/Controller/AddressControllerPaginationTest.php +++ b/Tests/Unit/Controller/AddressControllerPaginationTest.php @@ -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); @@ -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; diff --git a/Tests/Unit/Controller/AddressControllerTest.php b/Tests/Unit/Controller/AddressControllerTest.php index 2960511d..e466a68c 100644 --- a/Tests/Unit/Controller/AddressControllerTest.php +++ b/Tests/Unit/Controller/AddressControllerTest.php @@ -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)); } @@ -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', @@ -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(); @@ -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')); @@ -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', @@ -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', @@ -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', @@ -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'); @@ -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)); } diff --git a/Tests/Unit/Domain/Model/AddressTest.php b/Tests/Unit/Domain/Model/AddressTest.php index 1b0a0c12..c75cc977 100644 --- a/Tests/Unit/Domain/Model/AddressTest.php +++ b/Tests/Unit/Domain/Model/AddressTest.php @@ -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'], @@ -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' => ['', ''], @@ -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', '']], diff --git a/Tests/Unit/Evaluation/LatitudeEvaluationTest.php b/Tests/Unit/Evaluation/LatitudeEvaluationTest.php index f718d6e7..a5bbb9be 100644 --- a/Tests/Unit/Evaluation/LatitudeEvaluationTest.php +++ b/Tests/Unit/Evaluation/LatitudeEvaluationTest.php @@ -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()); } @@ -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' => ['', ''], diff --git a/Tests/Unit/Evaluation/LongitudeEvaluationTest.php b/Tests/Unit/Evaluation/LongitudeEvaluationTest.php index 71c13d92..ca7923e4 100644 --- a/Tests/Unit/Evaluation/LongitudeEvaluationTest.php +++ b/Tests/Unit/Evaluation/LongitudeEvaluationTest.php @@ -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()); } @@ -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' => ['', ''], diff --git a/Tests/Unit/Evaluation/TelephoneEvaluationTest.php b/Tests/Unit/Evaluation/TelephoneEvaluationTest.php index 802107f0..bdc96793 100644 --- a/Tests/Unit/Evaluation/TelephoneEvaluationTest.php +++ b/Tests/Unit/Evaluation/TelephoneEvaluationTest.php @@ -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')); @@ -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()); } @@ -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' => ['', ''], diff --git a/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php b/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php index a20ca9ca..d6a3b609 100755 --- a/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php +++ b/Tests/Unit/Hooks/Tca/AddFieldsToSelectorTest.php @@ -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')); } @@ -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 = []; diff --git a/Tests/Unit/Seo/AddressTitleProviderTest.php b/Tests/Unit/Seo/AddressTitleProviderTest.php index c4af7a95..a7e3e452 100755 --- a/Tests/Unit/Seo/AddressTitleProviderTest.php +++ b/Tests/Unit/Seo/AddressTitleProviderTest.php @@ -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' => [ diff --git a/Tests/Unit/Service/GeocodeServiceTest.php b/Tests/Unit/Service/GeocodeServiceTest.php index 7a85193c..bc3447ca 100644 --- a/Tests/Unit/Service/GeocodeServiceTest.php +++ b/Tests/Unit/Service/GeocodeServiceTest.php @@ -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); } @@ -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); } @@ -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'); } } diff --git a/Tests/UnitDeprecated/FormEngine/FieldControl/LocationMapWizardTest.php b/Tests/UnitDeprecated/FormEngine/FieldControl/LocationMapWizardTest.php index 666b6e37..c711ea1f 100755 --- a/Tests/UnitDeprecated/FormEngine/FieldControl/LocationMapWizardTest.php +++ b/Tests/UnitDeprecated/FormEngine/FieldControl/LocationMapWizardTest.php @@ -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')); } diff --git a/composer.json b/composer.json index 68f788f9..71908c50 100755 --- a/composer.json +++ b/composer.json @@ -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" }, From 6eaa7fbb119fa6093c472f89b30392df08541765 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 11:17:04 +0200 Subject: [PATCH 4/7] [TASK] Respect different query in test for v12 --- Tests/Functional/Repository/AddressRepositoryTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/Functional/Repository/AddressRepositoryTest.php b/Tests/Functional/Repository/AddressRepositoryTest.php index 5c874cc1..ae66546b 100644 --- a/Tests/Functional/Repository/AddressRepositoryTest.php +++ b/Tests/Functional/Repository/AddressRepositoryTest.php @@ -51,6 +51,10 @@ public function rawQueryReturnsCorrectQuery() $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` <= 1714554720) AND (((`tt_address`.`endtime` = 0) OR (`tt_address`.`endtime` > 1714554720)))) AND tt_address.deleted=0)'; + } $this->assertEquals($sql, $result); } From 9df05b2100757a70a8e1698edfd0ff9ff4ce7898 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 11:17:27 +0200 Subject: [PATCH 5/7] [TASK] Test more PHP versions --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a80db6f..a73bf93b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,12 @@ jobs: matrix: env: - { php: 7.4, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev } - - { php: 8.0, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev, experimental: true } - - { php: 8.1, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev, experimental: true } + - { php: 8.0, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev } + - { php: 8.1, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev } + - { php: 8.2, TYPO3_VERSION: ^11.0, TESTING_FRAMEWORK: 7.x-dev, experimental: true } - { php: 8.1, TYPO3_VERSION: ^12, TESTING_FRAMEWORK: 7.x-dev, experimental: true } + - { php: 8.2, TYPO3_VERSION: ^12, TESTING_FRAMEWORK: 7.x-dev, experimental: true } + - { php: 8.3, TYPO3_VERSION: ^12, TESTING_FRAMEWORK: 7.x-dev, experimental: true } env: ${{ matrix.env }} From 377c66adf0869026cbdb9dd7fdd198fb53d85dfd Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 11:18:14 +0200 Subject: [PATCH 6/7] [TASK] Improve .gitignore for tests --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3c7c1b6b..22548d21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ /Build/Local/report /Build/Local/.phpunit.result.cache +/Build/.phpunit.result.cache /Documentation-GENERATED-temp /tempfile.sh /out.txt +/.Build +/composer.lock From aade8e690fe3ae8f47a1f7f5edc76cefafd6c9ad Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Wed, 1 May 2024 11:19:38 +0200 Subject: [PATCH 7/7] [TASK] Don't hardcode test times --- Tests/Functional/Repository/AddressRepositoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Repository/AddressRepositoryTest.php b/Tests/Functional/Repository/AddressRepositoryTest.php index ae66546b..f34dfbb3 100644 --- a/Tests/Functional/Repository/AddressRepositoryTest.php +++ b/Tests/Functional/Repository/AddressRepositoryTest.php @@ -53,7 +53,7 @@ public function rawQueryReturnsCorrectQuery() $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` <= 1714554720) AND (((`tt_address`.`endtime` = 0) OR (`tt_address`.`endtime` > 1714554720)))) AND tt_address.deleted=0)'; + $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); }