diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php index 6baa123938e07ecd538c4b95764a0e2de9921a0d..e91028e19f63908b7ef1c872600d2e978024706f 100644 --- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php +++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/AccessibleProxies/NormalizeCommandAccessibleProxy.php @@ -24,52 +24,52 @@ use TYPO3\CMS\Scheduler\CronCommand\NormalizeCommand; */ class NormalizeCommandAccessibleProxy extends NormalizeCommand { - public static function convertKeywordsToCronCommand($cronCommand) + public static function convertKeywordsToCronCommand($cronCommand): string { return parent::convertKeywordsToCronCommand($cronCommand); } - public static function normalizeFields($cronCommand) + public static function normalizeFields($cronCommand): string { return parent::normalizeFields($cronCommand); } - public static function normalizeMonthAndWeekdayField($expression, $isMonthField = true) + public static function normalizeMonthAndWeekdayField($expression, $isMonthField = true): string { return parent::normalizeMonthAndWeekdayField($expression, $isMonthField); } - public static function normalizeIntegerField($expression, $lowerBound = 0, $upperBound = 59) + public static function normalizeIntegerField($expression, $lowerBound = 0, $upperBound = 59): string { return parent::normalizeIntegerField($expression, $lowerBound, $upperBound); } - public static function splitFields($cronCommand) + public static function splitFields($cronCommand): array { return parent::splitFields($cronCommand); } - public static function convertRangeToListOfValues($range) + public static function convertRangeToListOfValues($range): string { return parent::convertRangeToListOfValues($range); } - public static function reduceListOfValuesByStepValue($stepExpression) + public static function reduceListOfValuesByStepValue($stepExpression): string { return parent::reduceListOfValuesByStepValue($stepExpression); } - public static function normalizeMonthAndWeekday($expression, $isMonth = true) + public static function normalizeMonthAndWeekday($expression, $isMonth = true): string { return parent::normalizeMonthAndWeekday($expression, $isMonth); } - public static function normalizeMonth($month) + public static function normalizeMonth($month): int { return parent::normalizeMonth($month); } - public static function normalizeWeekday($weekday) + public static function normalizeWeekday($weekday): int { return parent::normalizeWeekday($weekday); } diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php index 60e1d3bb62a16a501bc8fbef1b8a29b5f97ac809..c895825920da21ca4a1ba639de558653f0e8213d 100644 --- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php +++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/CronCommandTest.php @@ -28,12 +28,12 @@ class CronCommandTest extends UnitTestCase /** * @var int timestamp of 1.1.2010 0:00 (Friday), timezone UTC/GMT */ - const TIMESTAMP = 1262304000; + private const TIMESTAMP = 1262304000; /** * @var string Selected timezone backup */ - protected $timezoneBackup = ''; + protected string $timezoneBackup = ''; /** * We're fiddling with hard timestamps in the tests, but time methods in @@ -57,7 +57,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function constructorSetsNormalizedCronCommandSections() + public function constructorSetsNormalizedCronCommandSections(): void { $instance = new CronCommand('2-3 * * * *'); self::assertSame(['2,3', '*', '*', '*', '*'], $instance->getCronCommandSections()); @@ -66,7 +66,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function constructorThrowsExceptionForInvalidCronCommand() + public function constructorThrowsExceptionForInvalidCronCommand(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode(1291470170); @@ -76,7 +76,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function constructorSetsTimestampToNowPlusOneMinuteRoundedDownToSixtySeconds() + public function constructorSetsTimestampToNowPlusOneMinuteRoundedDownToSixtySeconds(): void { $instance = new CronCommand('* * * * *'); $currentTime = time(); @@ -87,7 +87,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function constructorSetsTimestampToGivenTimestampPlusSixtySeconds() + public function constructorSetsTimestampToGivenTimestampPlusSixtySeconds(): void { $instance = new CronCommand('* * * * *', self::TIMESTAMP); self::assertSame(self::TIMESTAMP + 60, $instance->getTimestamp()); @@ -96,7 +96,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function constructorSetsTimestampToGiveTimestampRoundedDownToSixtySeconds() + public function constructorSetsTimestampToGiveTimestampRoundedDownToSixtySeconds(): void { $instance = new CronCommand('* * * * *', self::TIMESTAMP + 1); self::assertSame(self::TIMESTAMP + 60, $instance->getTimestamp()); @@ -105,7 +105,7 @@ class CronCommandTest extends UnitTestCase /** * @return array */ - public static function expectedTimestampDataProvider() + public static function expectedTimestampDataProvider(): array { return [ 'every minute' => [ @@ -186,7 +186,7 @@ class CronCommandTest extends UnitTestCase /** * @return array */ - public static function expectedCalculatedTimestampDataProvider() + public static function expectedCalculatedTimestampDataProvider(): array { return [ 'every first day of month' => [ @@ -247,7 +247,7 @@ class CronCommandTest extends UnitTestCase * @param int $startTimestamp Timestamp for start of calculation * @param int $expectedTimestamp Expected result (next time of execution) */ - public function calculateNextValueDeterminesCorrectNextTimestamp($cronCommand, $startTimestamp, $expectedTimestamp) + public function calculateNextValueDeterminesCorrectNextTimestamp(string $cronCommand, int $startTimestamp, int $expectedTimestamp): void { $instance = new CronCommand($cronCommand, $startTimestamp); $instance->calculateNextValue(); @@ -261,7 +261,7 @@ class CronCommandTest extends UnitTestCase * @param int $startTimestamp Timestamp for start of calculation * @param string $expectedTimestamp Expected result (next time of execution), to be fed to strtotime */ - public function calculateNextValueDeterminesCorrectNextCalculatedTimestamp($cronCommand, $startTimestamp, $expectedTimestamp) + public function calculateNextValueDeterminesCorrectNextCalculatedTimestamp(string $cronCommand, int $startTimestamp, string $expectedTimestamp): void { $instance = new CronCommand($cronCommand, $startTimestamp); $instance->calculateNextValue(); @@ -276,7 +276,7 @@ class CronCommandTest extends UnitTestCase * @param int $firstTimestamp Timestamp of the next execution * @param int $secondTimestamp Timestamp of the further execution */ - public function calculateNextValueDeterminesCorrectNextTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp) + public function calculateNextValueDeterminesCorrectNextTimestampOnConsecutiveCall(string $cronCommand, int $startTimestamp, int $firstTimestamp, int $secondTimestamp): void { $instance = new CronCommand($cronCommand, $firstTimestamp); $instance->calculateNextValue(); @@ -291,7 +291,7 @@ class CronCommandTest extends UnitTestCase * @param string $firstTimestamp Timestamp of the next execution, to be fed to strtotime * @param string $secondTimestamp Timestamp of the further execution, to be fed to strtotime */ - public function calculateNextValueDeterminesCorrectNextCalculatedTimestampOnConsecutiveCall($cronCommand, $startTimestamp, $firstTimestamp, $secondTimestamp) + public function calculateNextValueDeterminesCorrectNextCalculatedTimestampOnConsecutiveCall(string $cronCommand, int $startTimestamp, string $firstTimestamp, string $secondTimestamp): void { $instance = new CronCommand($cronCommand, strtotime($firstTimestamp)); $instance->calculateNextValue(); @@ -301,7 +301,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function calculateNextValueDeterminesCorrectNextTimestampOnChangeToSummertime() + public function calculateNextValueDeterminesCorrectNextTimestampOnChangeToSummertime(): void { $backupTimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Berlin'); @@ -314,7 +314,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function calculateNextValueThrowsExceptionWithImpossibleCronCommand() + public function calculateNextValueThrowsExceptionWithImpossibleCronCommand(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1291501280); @@ -325,7 +325,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function getTimestampReturnsInteger() + public function getTimestampReturnsInteger(): void { $instance = new CronCommand('* * * * *'); self::assertIsInt($instance->getTimestamp()); @@ -334,7 +334,7 @@ class CronCommandTest extends UnitTestCase /** * @test */ - public function getCronCommandSectionsReturnsArray() + public function getCronCommandSectionsReturnsArray(): void { $instance = new CronCommand('* * * * *'); self::assertIsArray($instance->getCronCommandSections()); diff --git a/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php b/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php index bd58435da745f64a9064b4f9437b3c8bb43f1f92..8ca511283fd190f0d817a153bca5e2f470173542 100644 --- a/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php +++ b/typo3/sysext/scheduler/Tests/Unit/CronCommand/NormalizeCommandTest.php @@ -67,7 +67,7 @@ class NormalizeCommandTest extends UnitTestCase * @param string $expression Cron command to test * @param string $expected Expected result (normalized cron command syntax) */ - public function normalizeConvertsCronCommand($expression, $expected): void + public function normalizeConvertsCronCommand(string $expression, string $expected): void { $result = NormalizeCommand::normalize($expression); self::assertEquals($expected, $result); @@ -95,7 +95,7 @@ class NormalizeCommandTest extends UnitTestCase * @param string $keyword Cron command keyword * @param string $expectedCronCommand Expected result (normalized cron command syntax) */ - public function convertKeywordsToCronCommandConvertsValidKeywords($keyword, $expectedCronCommand): void + public function convertKeywordsToCronCommandConvertsValidKeywords(string $keyword, string $expectedCronCommand): void { $result = NormalizeCommandAccessibleProxy::convertKeywordsToCronCommand($keyword); self::assertEquals($expectedCronCommand, $result); @@ -131,7 +131,7 @@ class NormalizeCommandTest extends UnitTestCase * @param string $expression Cron command to normalize * @param string $expected Expected result (normalized cron command syntax) */ - public function normalizeFieldsConvertsField($expression, $expected): void + public function normalizeFieldsConvertsField(string $expression, string $expected): void { $result = NormalizeCommandAccessibleProxy::normalizeFields($expression); self::assertEquals($expected, $result); @@ -173,9 +173,9 @@ class NormalizeCommandTest extends UnitTestCase * @param string $expected Expected result (normalized months or weekdays) */ public function normalizeMonthAndWeekdayFieldReturnsNormalizedListForValidExpression( - $expression, - $isMonthField, - $expected + string $expression, + bool $isMonthField, + string $expected ): void { $result = NormalizeCommandAccessibleProxy::normalizeMonthAndWeekdayField($expression, $isMonthField); self::assertSame($expected, $result); @@ -204,9 +204,9 @@ class NormalizeCommandTest extends UnitTestCase * @param int $expectedExceptionCode Expected exception code from provider */ public function normalizeMonthAndWeekdayFieldThrowsExceptionForInvalidExpression( - $expression, - $isMonthField, - $expectedExceptionCode + string $expression, + bool $isMonthField, + int $expectedExceptionCode ): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); @@ -238,10 +238,10 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider normalizeIntegerFieldValidDataProvider - * @param string $expression Cron command partial integer expression + * @param string|int $expression Cron command partial integer expression * @param string $expected Expected result (normalized integer or integer list) */ - public function normalizeIntegerFieldReturnsNormalizedListForValidExpression($expression, $expected): void + public function normalizeIntegerFieldReturnsNormalizedListForValidExpression($expression, string $expected): void { $result = NormalizeCommandAccessibleProxy::normalizeIntegerField($expression); self::assertSame($expected, $result); @@ -275,10 +275,10 @@ class NormalizeCommandTest extends UnitTestCase * @param int $expectedExceptionCode Expected exception code */ public function normalizeIntegerFieldThrowsExceptionForInvalidExpressions( - $expression, - $lowerBound, - $upperBound, - $expectedExceptionCode + string $expression, + int $lowerBound, + int $upperBound, + int $expectedExceptionCode ): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); @@ -319,7 +319,7 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider invalidCronCommandFieldsDataProvider - * @param string $cronCommand Invalid cron command + * @param string|int $cronCommand Invalid cron command */ public function splitFieldsThrowsExceptionIfCronCommandDoesNotContainFiveFields($cronCommand): void { @@ -346,10 +346,10 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider validRangeDataProvider - * @param string $range Cron command range expression + * @param string|int $range Cron command range expression * @param string $expected Expected result (normalized range) */ - public function convertRangeToListOfValuesReturnsCorrectListForValidRanges($range, $expected): void + public function convertRangeToListOfValuesReturnsCorrectListForValidRanges($range, string $expected): void { $result = NormalizeCommandAccessibleProxy::convertRangeToListOfValues($range); self::assertSame($expected, $result); @@ -380,7 +380,7 @@ class NormalizeCommandTest extends UnitTestCase * @param string $range Cron command range expression (invalid) * @param int $expectedExceptionCode Expected exception code from provider */ - public function convertRangeToListOfValuesThrowsExceptionForInvalidRanges($range, $expectedExceptionCode): void + public function convertRangeToListOfValuesThrowsExceptionForInvalidRanges(string $range, int $expectedExceptionCode): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); @@ -406,7 +406,7 @@ class NormalizeCommandTest extends UnitTestCase * @param string $stepExpression Cron command step expression * @param string $expected Expected result (normalized range) */ - public function reduceListOfValuesByStepValueReturnsCorrectListOfValues($stepExpression, $expected): void + public function reduceListOfValuesByStepValueReturnsCorrectListOfValues(string $stepExpression, string $expected): void { $result = NormalizeCommandAccessibleProxy::reduceListOfValuesByStepValue($stepExpression); self::assertSame($expected, $result); @@ -437,8 +437,8 @@ class NormalizeCommandTest extends UnitTestCase * @param int $expectedExceptionCode Expected exception code */ public function reduceListOfValuesByStepValueThrowsExceptionForInvalidStepExpressions( - $stepExpression, - $expectedExceptionCode + string $stepExpression, + int $expectedExceptionCode ): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); @@ -501,10 +501,10 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider validMonthNamesDataProvider - * @param string $monthName Month name + * @param string|int $monthName Month name * @param int $expectedInteger Number of the month */ - public function normalizeMonthConvertsName($monthName, $expectedInteger): void + public function normalizeMonthConvertsName($monthName, int $expectedInteger): void { $result = NormalizeCommandAccessibleProxy::normalizeMonth($monthName); self::assertEquals($expectedInteger, $result); @@ -513,10 +513,9 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider validMonthNamesDataProvider - * @param string $monthName Month name - * @param int $expectedInteger Number of the month (not used) + * @param string|int $monthName Month name */ - public function normalizeMonthReturnsInteger($monthName, $expectedInteger): void + public function normalizeMonthReturnsInteger($monthName): void { $result = NormalizeCommandAccessibleProxy::normalizeMonth($monthName); self::assertIsInt($result); @@ -553,12 +552,12 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider invalidMonthNamesDataProvider - * @param string $invalidMonthName Month name (invalid) + * @param string|int $invalidMonthName Month name (invalid) * @param int $expectedExceptionCode Expected exception code */ public function normalizeMonthThrowsExceptionForInvalidMonthRepresentation( $invalidMonthName, - $expectedExceptionCode + int $expectedExceptionCode ): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionCode($expectedExceptionCode); @@ -604,10 +603,10 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider validWeekdayDataProvider - * @param string $weekday Weekday expression + * @param string|int $weekday Weekday expression * @param int $expectedInteger Number of weekday */ - public function normalizeWeekdayConvertsName($weekday, $expectedInteger): void + public function normalizeWeekdayConvertsName($weekday, int $expectedInteger): void { $result = NormalizeCommandAccessibleProxy::normalizeWeekday($weekday); self::assertEquals($expectedInteger, $result); @@ -616,10 +615,9 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider validWeekdayDataProvider - * @param string $weekday Weekday expression - * @param int $expectedInteger Number of weekday (not used) + * @param string|int $weekday Weekday expression */ - public function normalizeWeekdayReturnsInteger($weekday, $expectedInteger): void + public function normalizeWeekdayReturnsInteger($weekday): void { $result = NormalizeCommandAccessibleProxy::normalizeWeekday($weekday); self::assertIsInt($result); @@ -654,7 +652,7 @@ class NormalizeCommandTest extends UnitTestCase /** * @test * @dataProvider invalidWeekdayDataProvider - * @param string $weekday Weekday expression (invalid) + * @param string|int $weekday Weekday expression (invalid) */ public function normalizeWeekdayThrowsExceptionForInvalidWeekdayRepresentation($weekday): void { diff --git a/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php b/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php index b29b1d45fd66bff91065d6536522d12a686ee446..d501b6b5dc1ff3cb70afd00ca32ee8f964eca616 100644 --- a/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php +++ b/typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Scheduler\Tests\Unit\Task; +use PHPUnit\Framework\MockObject\MockObject; use TYPO3\CMS\Core\Cache\Backend\AbstractBackend; use TYPO3\CMS\Core\Cache\Backend\NullBackend; use TYPO3\CMS\Core\Cache\CacheManager; @@ -38,10 +39,10 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase /** * @test */ - public function executeCallsCollectGarbageOfConfiguredBackend() + public function executeCallsCollectGarbageOfConfiguredBackend(): void { $cache = $this->createMock(VariableFrontend::class); - $cache->expects(self::any())->method('getIdentifier')->willReturn('cache'); + $cache->method('getIdentifier')->willReturn('cache'); $cache->expects(self::atLeastOnce())->method('collectGarbage'); $mockCacheManager = new CacheManager(); $mockCacheManager->registerCache($cache); @@ -52,7 +53,7 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase 'backend' => AbstractBackend::class, ] ]; - /** @var \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask|\PHPUnit\Framework\MockObject\MockObject $subject */ + /** @var CachingFrameworkGarbageCollectionTask|MockObject $subject */ $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class) ->addMethods(['dummy']) ->disableOriginalConstructor() @@ -64,10 +65,10 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase /** * @test */ - public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend() + public function executeDoesNotCallCollectGarbageOfNotConfiguredBackend(): void { $cache = $this->createMock(VariableFrontend::class); - $cache->expects(self::any())->method('getIdentifier')->willReturn('cache'); + $cache->method('getIdentifier')->willReturn('cache'); $cache->expects(self::never())->method('collectGarbage'); $mockCacheManager = new CacheManager(); $mockCacheManager->registerCache($cache); @@ -78,7 +79,7 @@ class CachingFrameworkGarbageCollectionTest extends UnitTestCase 'backend' => AbstractBackend::class, ] ]; - /** @var \TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask|\PHPUnit\Framework\MockObject\MockObject $subject */ + /** @var CachingFrameworkGarbageCollectionTask|MockObject $subject */ $subject = $this->getMockBuilder(CachingFrameworkGarbageCollectionTask::class) ->addMethods(['dummy']) ->disableOriginalConstructor() diff --git a/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php b/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php index 576f46c53b64aa3605f9bc90ec4262761da392c9..009edb9927392dd5ce79b99a9f4dcc5f1ac72265 100644 --- a/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php +++ b/typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Seo\Tests\Unit\HrefLang; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\UriInterface; use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -29,16 +30,16 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class HrefLangGeneratorTest extends UnitTestCase { - use \Prophecy\PhpUnit\ProphecyTrait; + use ProphecyTrait; + /** * @test * * @param string $url - * @param bool $shouldBeCalled * * @dataProvider urlPathDataProvider */ - public function checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled) + public function checkIfGetSiteLanguageIsCalled(string $url): void { $subject = $this->getAccessibleMock( HrefLangGenerator::class, @@ -62,39 +63,30 @@ class HrefLangGeneratorTest extends UnitTestCase return [ [ '/', - true ], [ 'example.com', - true //This can't be defined as a domain because it can also be a filename ], [ 'filename.pdf', - true ], [ 'example.com/filename.pdf', - true ], [ '//example.com/filename.pdf', - false ], [ '//example.com', - false ], [ 'https://example.com', - false ], [ '/page-1/subpage-1', - true ], [ 'https://example.com/page-1/subpage-1', - false ], ]; } diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php index fd0874ba37229a2066aa6f09c415a10dbfa3522d..21338cb14737aef22eeb28c516502abb9c608ba0 100644 --- a/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php +++ b/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php @@ -28,7 +28,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray() + public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray(): void { $manager = new OpenGraphMetaTagManager(); $handledProperties = $manager->getAllHandledProperties(); @@ -41,7 +41,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase * * @test */ - public function checkIfPropertyIsStoredAfterAddingProperty($property, $expected, $expectedRenderedTag) + public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag): void { $manager = new OpenGraphMetaTagManager(); $manager->addProperty( @@ -57,7 +57,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException() + public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException(): void { $manager = new OpenGraphMetaTagManager(); @@ -68,7 +68,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkRenderAllPropertiesRendersCorrectMetaTags() + public function checkRenderAllPropertiesRendersCorrectMetaTags(): void { $properties = [ [ @@ -133,7 +133,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfRemovePropertyReallyRemovesProperty() + public function checkIfRemovePropertyReallyRemovesProperty(): void { $manager = new OpenGraphMetaTagManager(); $manager->addProperty('og:title', 'Title'); @@ -154,7 +154,7 @@ class OpenGraphMetaTagManagerTest extends UnitTestCase /** * @return array */ - public function propertiesProvider() + public function propertiesProvider(): array { return [ [ diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php index 5768cda880f47e821a2497c80ea41378f90cbed5..f2c5170d4df8ffbd2887f45b8aeda0dba53ef42c 100644 --- a/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php +++ b/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php @@ -28,7 +28,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray() + public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray(): void { $manager = new TwitterCardMetaTagManager(); $handledProperties = $manager->getAllHandledProperties(); @@ -45,7 +45,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase * @param array $expected * @param string $expectedRenderedTag */ - public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag) + public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag): void { $manager = new TwitterCardMetaTagManager(); $manager->addProperty( @@ -61,7 +61,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase /** * @return array */ - public function propertiesProvider() + public function propertiesProvider(): array { return [ 'title is set' => [ @@ -129,7 +129,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException() + public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException(): void { $manager = new TwitterCardMetaTagManager(); @@ -140,7 +140,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkRenderAllPropertiesRendersCorrectMetaTags() + public function checkRenderAllPropertiesRendersCorrectMetaTags(): void { $properties = [ [ @@ -195,7 +195,7 @@ class TwitterCardMetaTagManagerTest extends UnitTestCase /** * @test */ - public function checkIfRemovePropertyReallyRemovesProperty() + public function checkIfRemovePropertyReallyRemovesProperty(): void { $manager = new TwitterCardMetaTagManager(); $manager->addProperty('twitter:title', 'Title'); diff --git a/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php b/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php index a795d3d805dfa7f4e7d3779013210183b4b063c5..145575da28c6f00c4a4c7ce96ace2b6e5af062c9 100644 --- a/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php +++ b/typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Seo\Tests\Unit\XmlSitemap; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Seo\XmlSitemap\PagesXmlSitemapDataProvider; @@ -24,13 +25,14 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; class PagesXmlSitemapDataProviderTest extends UnitTestCase { - use \Prophecy\PhpUnit\ProphecyTrait; + use ProphecyTrait; + protected $resetSingletonInstances = true; /** * @var array */ - protected $items; + protected array $items; public function setUp(): void { @@ -77,7 +79,7 @@ class PagesXmlSitemapDataProviderTest extends UnitTestCase * @dataProvider numberOfItemsPerPageProvider * @test */ - public function checkGetItemsReturnsDefinedItems($numberOfItemsPerPage): void + public function checkGetItemsReturnsDefinedItems(int $numberOfItemsPerPage): void { $key = 'dummyKey'; $cObj = $this->prophesize(ContentObjectRenderer::class); @@ -93,7 +95,7 @@ class PagesXmlSitemapDataProviderTest extends UnitTestCase $subject->_set('items', $this->items); $subject->_set('numberOfItemsPerPage', $numberOfItemsPerPage); - $subject->expects(self::any())->method('defineUrl')->willReturnCallback( + $subject->method('defineUrl')->willReturnCallback( function ($input) { return $input; } diff --git a/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php b/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php index 5d841e3727c08066defc036ca7317c4f0d68db38..501bfa7e7c254cc647ab38bf3fa6f4651a37c214 100644 --- a/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php +++ b/typo3/sysext/setup/Tests/Unit/Controller/SetupModuleControllerTest.php @@ -29,7 +29,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessagesIfSetupIsUpdated() + public function addFlashMessagesAddsMessagesIfSetupIsUpdated(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, @@ -54,7 +54,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessageIfSettingsAreResetToDefault() + public function addFlashMessagesAddsMessageIfSettingsAreResetToDefault(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, @@ -79,7 +79,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated() + public function addFlashMessagesAddsMessageIfPasswordWasSuccessfullyUpdated(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, @@ -104,7 +104,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessageIfOldPasswordWasWrong() + public function addFlashMessagesAddsMessageIfOldPasswordWasWrong(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, @@ -129,7 +129,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessageIfPasswordsNotTheSame() + public function addFlashMessagesAddsMessageIfPasswordsNotTheSame(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, @@ -154,7 +154,7 @@ class SetupModuleControllerTest extends UnitTestCase /** * @test */ - public function addFlashMessagesAddsMessagesToQueue() + public function addFlashMessagesAddsMessagesToQueue(): void { $setupModuleControllerMock = $this->getAccessibleMock( SetupModuleController::class, diff --git a/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php b/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php index 4edfec00cd0fb5a6c327139f6e4c5e499c411209..f53459bd5a8ea3879921e0aaf0a103b9975b5f38 100644 --- a/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php +++ b/typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php @@ -27,10 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class AddonRegistryTest extends UnitTestCase { - /** - * @var AddonRegistry - */ - protected $subject; + protected AddonRegistry $subject; protected function setUp(): void { @@ -67,8 +64,7 @@ class AddonRegistryTest extends UnitTestCase 'foobar' => false, 'randomInt' => 4 // chosen by fair dice roll ]) - ) - ; + ); } /** diff --git a/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php b/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php index 755cfc85bb18697a94e5ec7bde301dda80119383..1e729462f22aa652aca724f81a2f5fa2129b0806 100644 --- a/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php +++ b/typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php @@ -27,10 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class ModeRegistryTest extends UnitTestCase { - /** - * @var ModeRegistry - */ - protected $subject; + protected ModeRegistry $subject; protected function setUp(): void { diff --git a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php index 77a4f233fbaa22d528620d1020d9564334f8668a..eaee3aa96db8a22b446186c86625578d8581b95e 100644 --- a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php +++ b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php @@ -18,6 +18,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Workspaces\Tests\Unit\Controller\Remote; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FileReference; @@ -31,7 +32,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class RemoteServerTest extends UnitTestCase { - use \Prophecy\PhpUnit\ProphecyTrait; + use ProphecyTrait; + /** * @var bool Reset singletons created by subject */ @@ -40,12 +42,12 @@ class RemoteServerTest extends UnitTestCase /** * @var FileReference[]|ObjectProphecy[] */ - protected $fileReferenceProphecies; + protected array $fileReferenceProphecies; /** * @return array */ - public function prepareFileReferenceDifferencesAreCorrectDataProvider() + public function prepareFileReferenceDifferencesAreCorrectDataProvider(): array { return [ // without thumbnails @@ -106,12 +108,12 @@ class RemoteServerTest extends UnitTestCase /** * @param string $fileFileReferenceList * @param string $versionFileReferenceList - * @param $useThumbnails + * @param bool $useThumbnails * @param array|null $expected * @dataProvider prepareFileReferenceDifferencesAreCorrectDataProvider * @test */ - public function prepareFileReferenceDifferencesAreCorrect($fileFileReferenceList, $versionFileReferenceList, $useThumbnails, array $expected = null) + public function prepareFileReferenceDifferencesAreCorrect(string $fileFileReferenceList, string $versionFileReferenceList, bool $useThumbnails, array $expected = null): void { $liveFileReferences = $this->getFileReferenceProphecies($fileFileReferenceList); $versionFileReferences = $this->getFileReferenceProphecies($versionFileReferenceList); @@ -131,7 +133,7 @@ class RemoteServerTest extends UnitTestCase * @param string $idList List of ids * @return FileReference[]|ObjectProphecy[] */ - protected function getFileReferenceProphecies($idList) + protected function getFileReferenceProphecies(string $idList): array { $fileReferenceProphecies = []; $ids = GeneralUtility::trimExplode(',', $idList, true); @@ -144,10 +146,10 @@ class RemoteServerTest extends UnitTestCase } /** - * @param int $id + * @param string $id * @return ObjectProphecy|FileReference */ - protected function getFileReferenceProphecy($id) + protected function getFileReferenceProphecy(string $id): FileReference { if (isset($this->fileReferenceProphecies[$id])) { return $this->fileReferenceProphecies[$id];