Skip to content

Commit

Permalink
Make tests compatible with newer phpunit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Jul 2, 2024
1 parent ba4aa9b commit 5e84412
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 53 deletions.
22 changes: 11 additions & 11 deletions Tests/DeviceDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -628,7 +628,7 @@ 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');

Expand All @@ -638,16 +638,16 @@ public function getTypeMethodFixtures(): array
/**
* @dataProvider getTypeMethodFixtures
*/
public function testTypeMethods(string $ua, array $checkTypes): void
public function testTypeMethods(string $user_agent, array $check): void
{
try {
$dd = $this->getDeviceDetector();
$dd->discardBotInformation();
$dd->setUserAgent($ua);
$dd->setUserAgent($user_agent);
$dd->parse();
} catch (\Exception $exception) {
throw new \Exception(
\sprintf('Error: %s from useragent %s', $exception->getMessage(), $ua),
\sprintf('Error: %s from useragent %s', $exception->getMessage(), $user_agent),
$exception->getCode(),
$exception
);
Expand All @@ -656,10 +656,10 @@ public function testTypeMethods(string $ua, array $checkTypes): void
$this->assertEquals([
$dd->isBot(), $dd->isMobile(), $dd->isDesktop(),
$dd->isTablet(), $dd->isTV(), $dd->isWearable(),
], $checkTypes, \sprintf(
], $check, \sprintf(
"test: %s\nfrom useragent %s",
'[isBot(), isMobile(), isDesktop(), isTablet(), isTV(), isWearable()]',
$ua
$user_agent
));
}

Expand Down
12 changes: 6 additions & 6 deletions Tests/Parser/Client/BrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class BrowserTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client, ?array $headers = null): void
public function testParse(string $user_agent, array $client, ?array $headers = null): void
{
$browserParser = new Browser();
$browserParser->setVersionTruncation(Browser::VERSION_TRUNCATION_NONE);
$browserParser->setUserAgent($useragent);
$browserParser->setUserAgent($user_agent);

if (null !== $headers) {
$browserParser->setClientHints(ClientHints::factory($headers));
Expand All @@ -39,17 +39,17 @@ public function testParse(string $useragent, array $client, ?array $headers = nu
$browser = $browserParser->parse();
unset($browser['short_name']);

$this->assertEquals($client, $browser, "UserAgent: {$useragent}");
$this->assertEquals($client, $browser, "UserAgent: {$user_agent}");
$this->assertTrue($this->checkBrowserEngine($browser['engine']), \sprintf(
"UserAgent: %s\nEngine wrong name: `%s`",
$useragent,
$user_agent,
$browser['engine']
));

self::$browsersTested[] = $client['name'];
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/browser.yml');

Expand Down Expand Up @@ -108,7 +108,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);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Parser/Client/FeedReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class FeedReaderTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client): void
public function testParse(string $user_agent, array $client): void
{
$feedReaderParser = new FeedReader();
$feedReaderParser->setVersionTruncation(FeedReader::VERSION_TRUNCATION_NONE);
$feedReaderParser->setUserAgent($useragent);
$this->assertEquals($client, $feedReaderParser->parse(), "UserAgent: {$useragent}");
$feedReaderParser->setUserAgent($user_agent);
$this->assertEquals($client, $feedReaderParser->parse(), "UserAgent: {$user_agent}");
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/feed_reader.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Client/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class LibraryTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client): void
public function testParse(string $user_agent, array $client): void
{
$libraryParser = new Library();
$libraryParser->setVersionTruncation(Library::VERSION_TRUNCATION_NONE);
$libraryParser->setUserAgent($useragent);
$libraryParser->setUserAgent($user_agent);
$this->assertEquals($client, $libraryParser->parse());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/library.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Client/MediaPlayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class MediaPlayerTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client): void
public function testParse(string $user_agent, array $client): void
{
$mediaPlayerParser = new MediaPlayer();
$mediaPlayerParser->setVersionTruncation(MediaPlayer::VERSION_TRUNCATION_NONE);
$mediaPlayerParser->setUserAgent($useragent);
$mediaPlayerParser->setUserAgent($user_agent);
$this->assertEquals($client, $mediaPlayerParser->parse());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mediaplayer.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Client/MobileAppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class MobileAppTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client): void
public function testParse(string $user_agent, array $client): void
{
$mobileAppParser = new MobileApp();
$mobileAppParser->setVersionTruncation(MobileApp::VERSION_TRUNCATION_NONE);
$mobileAppParser->setUserAgent($useragent);
$mobileAppParser->setUserAgent($user_agent);
$this->assertEquals($client, $mobileAppParser->parse());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/mobile_app.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Client/PIMTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class PIMTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $client): void
public function testParse(string $user_agent, array $client): void
{
$PIMParser = new PIM();
$PIMParser->setVersionTruncation(PIM::VERSION_TRUNCATION_NONE);
$PIMParser->setUserAgent($useragent);
$PIMParser->setUserAgent($user_agent);
$this->assertEquals($client, $PIMParser->parse());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/pim.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Device/CameraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class CameraTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $device): void
public function testParse(string $user_agent, array $device): void

Check failure on line 24 in Tests/Parser/Device/CameraTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
{
$consoleParser = new Camera();
$consoleParser->setUserAgent($useragent);
$consoleParser->setUserAgent($user_agent);

Check failure on line 27 in Tests/Parser/Device/CameraTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
$this->assertTrue(\is_array($consoleParser->parse()));
$this->assertEquals($device['type'], Camera::getDeviceName($consoleParser->getDeviceType()));
$this->assertEquals($device['brand'], $consoleParser->getBrand());
$this->assertEquals($device['model'], $consoleParser->getModel());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/camera.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Device/CarBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class CarBrowserTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $device): void
public function testParse(string $user_agent, array $device): void

Check failure on line 24 in Tests/Parser/Device/CarBrowserTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
{
$consoleParser = new CarBrowser();
$consoleParser->setUserAgent($useragent);
$consoleParser->setUserAgent($user_agent);

Check failure on line 27 in Tests/Parser/Device/CarBrowserTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
$this->assertTrue(\is_array($consoleParser->parse()));
$this->assertEquals($device['type'], CarBrowser::getDeviceName($consoleParser->getDeviceType()));
$this->assertEquals($device['brand'], $consoleParser->getBrand());
$this->assertEquals($device['model'], $consoleParser->getModel());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/car_browser.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Device/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class ConsoleTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $device): void
public function testParse(string $user_agent, array $device): void

Check failure on line 24 in Tests/Parser/Device/ConsoleTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
{
$consoleParser = new Console();
$consoleParser->setUserAgent($useragent);
$consoleParser->setUserAgent($user_agent);

Check failure on line 27 in Tests/Parser/Device/ConsoleTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
$this->assertTrue(\is_array($consoleParser->parse()));
$this->assertEquals($device['type'], Console::getDeviceName($consoleParser->getDeviceType()));
$this->assertEquals($device['brand'], $consoleParser->getBrand());
$this->assertEquals($device['model'], $consoleParser->getModel());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/console.yml');

Expand Down
6 changes: 3 additions & 3 deletions Tests/Parser/Device/NotebookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class NotebookTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $device): void
public function testParse(string $user_agent, array $device): void

Check failure on line 24 in Tests/Parser/Device/NotebookTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
{
$notebookParser = new Notebook();
$notebookParser->setUserAgent($useragent);
$notebookParser->setUserAgent($user_agent);

Check failure on line 27 in Tests/Parser/Device/NotebookTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
$this->assertNotNull($notebookParser->parse());
$this->assertEquals($device['type'], Notebook::getDeviceName($notebookParser->getDeviceType()));
$this->assertEquals($device['brand'], $notebookParser->getBrand());
$this->assertEquals($device['model'], $notebookParser->getModel());
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/notebook.yml');

Expand Down
14 changes: 7 additions & 7 deletions Tests/Parser/OperatingSystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ class OperatingSystemTest extends TestCase
/**
* @dataProvider getFixtures
*/
public function testParse(string $useragent, array $os, ?array $headers = null): void
public function testParse(string $user_agent, array $os, ?array $headers = null): void

Check failure on line 27 in Tests/Parser/OperatingSystemTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format
{
$osParser = new OperatingSystem();
$osParser->setUserAgent($useragent);
$osParser->setUserAgent($user_agent);

Check failure on line 30 in Tests/Parser/OperatingSystemTest.php

View workflow job for this annotation

GitHub Actions / PHPCS

Variable "user_agent" is not in valid camel caps format

if (null !== $headers) {
$osParser->setClientHints(ClientHints::factory($headers));
}

$this->assertEquals($os, $osParser->parse(), "UserAgent: {$useragent}");
$this->assertEquals($os, $osParser->parse(), "UserAgent: {$user_agent}");
self::$osTested[] = $os['name'];
}

public function getFixtures(): array
public static function getFixtures(): array
{
$fixtureData = Spyc::YAMLLoad(\realpath(__DIR__) . '/fixtures/oss.yml');

Expand All @@ -53,7 +53,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) {
Expand All @@ -72,7 +72,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) {
Expand All @@ -95,7 +95,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'],
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/VendorFragmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 5e84412

Please sign in to comment.