diff --git a/Tests/DeviceDetectorTest.php b/Tests/DeviceDetectorTest.php index 416b68a276..43e3238067 100644 --- a/Tests/DeviceDetectorTest.php +++ b/Tests/DeviceDetectorTest.php @@ -247,7 +247,7 @@ public function testParse(array $fixtureData): void $this->assertEquals($fixtureData, $uaInfo, $errorMessage); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtures = []; $fixtureFiles = \glob(\realpath(__DIR__) . '/fixtures/*.yml'); @@ -301,7 +301,7 @@ public function testParseClient(array $fixtureData): void $this->assertEquals($fixtureData['client'], $uaInfo['client'], $messageError); } - public function getFixturesClient(): array + public static function getFixturesClient(): array { $fixtures = []; $fixtureFiles = \glob(\realpath(__DIR__) . '/Parser/Client/fixtures/*.yml'); @@ -341,7 +341,7 @@ public function testParseDevice(array $fixtureData): void $this->assertEquals($fixtureData['device'], $uaInfo['device']); } - public function getFixturesDevice(): array + public static function getFixturesDevice(): array { $fixtures = []; $fixtureFiles = \glob(\realpath(__DIR__) . '/Parser/Device/fixtures/*.yml'); @@ -403,7 +403,7 @@ public function testVersionTruncation(string $useragent, int $truncationType, st AbstractParser::setVersionTruncation(AbstractParser::VERSION_TRUNCATION_NONE); } - public function getVersionTruncationFixtures(): array + public static function getVersionTruncationFixtures(): array { return [ ['Mozilla/5.0 (Linux; Android 4.2.2; ARCHOS 101 PLATINUM Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Safari/537.36', AbstractParser::VERSION_TRUNCATION_NONE, '4.2.2', '34.0.1847.114'], @@ -528,7 +528,7 @@ public function testParseBots(array $fixtureData): void ); } - public function getBotFixtures(): array + public static function getBotFixtures(): array { $fixturesPath = \realpath(__DIR__ . '/fixtures/bots.yml'); $fixtures = \Spyc::YAMLLoad($fixturesPath); @@ -628,11 +628,15 @@ public function testGetClient(): void $this->assertEquals($expected, $dd->getClient()); } - public function getTypeMethodFixtures(): array + public static function getTypeMethodFixtures(): array { - $fixturePath = \realpath(__DIR__ . '/Parser/fixtures/type-methods.yml'); + $fixtureData = \Spyc::YAMLLoad(\realpath(__DIR__ . '/Parser/fixtures/type-methods.yml')); - return \Spyc::YAMLLoad($fixturePath); + $fixtureData = \array_map(static function (array $item): array { + return ['ua' => $item['user_agent'], 'checkTypes' => $item['check']]; + }, $fixtureData); + + return $fixtureData; } /** diff --git a/Tests/Parser/Client/BrowserTest.php b/Tests/Parser/Client/BrowserTest.php index 023c9a92ae..22deb4899a 100644 --- a/Tests/Parser/Client/BrowserTest.php +++ b/Tests/Parser/Client/BrowserTest.php @@ -49,10 +49,14 @@ public function testParse(string $useragent, array $client, ?array $headers = nu self::$browsersTested[] = $client['name']; } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/browser.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client'], 'headers' => $item['headers'] ?? null]; + }, $fixtureData); + return $fixtureData; } @@ -108,7 +112,7 @@ public function testBrowserFamiliesNoDuplicates(): void /** * @return array */ - public function getFixturesBrowserHints(): array + public static function getFixturesBrowserHints(): array { $method = new \ReflectionMethod(BrowserHints::class, 'getRegexes'); $method->setAccessible(true); diff --git a/Tests/Parser/Client/FeedReaderTest.php b/Tests/Parser/Client/FeedReaderTest.php index c8fd3ca74a..4d4cba3a9c 100644 --- a/Tests/Parser/Client/FeedReaderTest.php +++ b/Tests/Parser/Client/FeedReaderTest.php @@ -29,10 +29,14 @@ public function testParse(string $useragent, array $client): void $this->assertEquals($client, $feedReaderParser->parse(), "UserAgent: {$useragent}"); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/feed_reader.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client']]; + }, $fixtureData); + return $fixtureData; } diff --git a/Tests/Parser/Client/LibraryTest.php b/Tests/Parser/Client/LibraryTest.php index a9baa68ee3..7161209390 100644 --- a/Tests/Parser/Client/LibraryTest.php +++ b/Tests/Parser/Client/LibraryTest.php @@ -29,10 +29,14 @@ public function testParse(string $useragent, array $client): void $this->assertEquals($client, $libraryParser->parse()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/library.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client']]; + }, $fixtureData); + return $fixtureData; } diff --git a/Tests/Parser/Client/MediaPlayerTest.php b/Tests/Parser/Client/MediaPlayerTest.php index b8ca8482ea..b69e68d188 100644 --- a/Tests/Parser/Client/MediaPlayerTest.php +++ b/Tests/Parser/Client/MediaPlayerTest.php @@ -29,10 +29,14 @@ public function testParse(string $useragent, array $client): void $this->assertEquals($client, $mediaPlayerParser->parse()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mediaplayer.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client']]; + }, $fixtureData); + return $fixtureData; } diff --git a/Tests/Parser/Client/MobileAppTest.php b/Tests/Parser/Client/MobileAppTest.php index c15da0f6a2..cda42c5917 100644 --- a/Tests/Parser/Client/MobileAppTest.php +++ b/Tests/Parser/Client/MobileAppTest.php @@ -29,10 +29,14 @@ public function testParse(string $useragent, array $client): void $this->assertEquals($client, $mobileAppParser->parse()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mobile_app.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client']]; + }, $fixtureData); + return $fixtureData; } diff --git a/Tests/Parser/Client/PIMTest.php b/Tests/Parser/Client/PIMTest.php index 27a389143c..1c9f781f2c 100644 --- a/Tests/Parser/Client/PIMTest.php +++ b/Tests/Parser/Client/PIMTest.php @@ -29,10 +29,14 @@ public function testParse(string $useragent, array $client): void $this->assertEquals($client, $PIMParser->parse()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/pim.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'client' => $item['client']]; + }, $fixtureData); + return $fixtureData; } diff --git a/Tests/Parser/Device/CameraTest.php b/Tests/Parser/Device/CameraTest.php index c429fe2bb6..5b1ec2dd89 100644 --- a/Tests/Parser/Device/CameraTest.php +++ b/Tests/Parser/Device/CameraTest.php @@ -31,10 +31,14 @@ public function testParse(string $useragent, array $device): void $this->assertEquals($device['model'], $consoleParser->getModel()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/camera.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'device' => $item['device']]; + }, $fixtureData); + return $fixtureData; } } diff --git a/Tests/Parser/Device/CarBrowserTest.php b/Tests/Parser/Device/CarBrowserTest.php index 2758e07dd1..03919aaa92 100644 --- a/Tests/Parser/Device/CarBrowserTest.php +++ b/Tests/Parser/Device/CarBrowserTest.php @@ -31,10 +31,14 @@ public function testParse(string $useragent, array $device): void $this->assertEquals($device['model'], $consoleParser->getModel()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/car_browser.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'device' => $item['device']]; + }, $fixtureData); + return $fixtureData; } } diff --git a/Tests/Parser/Device/ConsoleTest.php b/Tests/Parser/Device/ConsoleTest.php index 83c4593978..1d78acebab 100644 --- a/Tests/Parser/Device/ConsoleTest.php +++ b/Tests/Parser/Device/ConsoleTest.php @@ -31,10 +31,14 @@ public function testParse(string $useragent, array $device): void $this->assertEquals($device['model'], $consoleParser->getModel()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/console.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'device' => $item['device']]; + }, $fixtureData); + return $fixtureData; } } diff --git a/Tests/Parser/Device/NotebookTest.php b/Tests/Parser/Device/NotebookTest.php index 9801229341..a7015e43d2 100644 --- a/Tests/Parser/Device/NotebookTest.php +++ b/Tests/Parser/Device/NotebookTest.php @@ -31,10 +31,14 @@ public function testParse(string $useragent, array $device): void $this->assertEquals($device['model'], $notebookParser->getModel()); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/notebook.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'device' => $item['device']]; + }, $fixtureData); + return $fixtureData; } } diff --git a/Tests/Parser/OperatingSystemTest.php b/Tests/Parser/OperatingSystemTest.php index e68a2609a4..8873ac0909 100644 --- a/Tests/Parser/OperatingSystemTest.php +++ b/Tests/Parser/OperatingSystemTest.php @@ -37,10 +37,14 @@ public function testParse(string $useragent, array $os, ?array $headers = null): self::$osTested[] = $os['name']; } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/oss.yml'); + $fixtureData = \array_map(static function (array $item): array { + return ['useragent' => $item['user_agent'], 'os' => $item['os'], 'headers' => $item['headers'] ?? null]; + }, $fixtureData); + return $fixtureData; } @@ -53,7 +57,7 @@ public function testOSInGroup(string $os): void $this->assertContains($os, $familyOs); } - public function getAllOs(): array + public static function getAllOs(): array { $allOs = \array_keys(OperatingSystem::getAvailableOperatingSystems()); $allOs = \array_map(static function ($os) { @@ -72,7 +76,7 @@ public function testFamilyOSExists(string $os): void $this->assertContains($os, $allOs); } - public function getAllFamilyOs(): array + public static function getAllFamilyOs(): array { $allFamilyOs = \call_user_func_array('array_merge', \array_values(OperatingSystem::getAvailableOperatingSystemFamilies())); $allFamilyOs = \array_map(static function ($os) { @@ -95,7 +99,7 @@ public function testGetNameFromId(string $os, string $version, ?string $expected $this->assertEquals($expected, OperatingSystem::getNameFromId($os, $version)); } - public function getNameFromIds(): array + public static function getNameFromIds(): array { return [ ['DEB', '4.5', 'Debian 4.5'], diff --git a/Tests/Parser/VendorFragmentTest.php b/Tests/Parser/VendorFragmentTest.php index fbeb7af4c4..af7f294635 100644 --- a/Tests/Parser/VendorFragmentTest.php +++ b/Tests/Parser/VendorFragmentTest.php @@ -31,7 +31,7 @@ public function testParse(string $useragent, string $vendor): void self::$regexesTested[] = $vfParser->getMatchedRegex(); } - public function getFixtures(): array + public static function getFixtures(): array { $fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/vendorfragments.yml');