From 6545deb2766abc7721a354c40a4813a61113e80b Mon Sep 17 00:00:00 2001 From: Oliver Klee <typo3-coding@oliverklee.de> Date: Tue, 11 Jul 2023 09:28:27 +0200 Subject: [PATCH] [TASK] Add more tests for GeneralUtility::isOnCurrentHost There already was a data provider for the negative case of this method, but no tests using this data provider. Resolves: #101308 Releases: main, 12.4, 11.5 Change-Id: If32b5f2943240f224031e20d9849f849275358a5 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79972 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> --- .../Tests/Unit/Utility/GeneralUtilityTest.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index 61cc25a11b19..a2b25987c923 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -1263,6 +1263,7 @@ final class GeneralUtilityTest extends UnitTestCase ////////////////////////////////// // Tests concerning isOnCurrentHost ////////////////////////////////// + /** * @test */ @@ -1275,9 +1276,9 @@ final class GeneralUtilityTest extends UnitTestCase /** * Data provider for invalid isOnCurrentHost's * - * @return array Invalid Hosts + * @return array<string, array{0: string}> */ - public function checkisOnCurrentHostInvalidHosts(): array + public static function checkisOnCurrentHostInvalidHostsDataProvider(): array { return [ 'empty string' => [''], @@ -1289,6 +1290,16 @@ final class GeneralUtilityTest extends UnitTestCase ]; } + /** + * @test + * + * @dataProvider checkisOnCurrentHostInvalidHostsDataProvider + */ + public function isOnCurrentHostWithNotCurrentHostReturnsFalse(string $hostCandidate): void + { + self::assertFalse(GeneralUtility::isOnCurrentHost($hostCandidate)); + } + //////////////////////////////////////// // Tests concerning sanitizeLocalUrl //////////////////////////////////////// -- GitLab