From fe6077515d278474763f04260a39ef46f0d0b4de Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Thu, 1 Aug 2024 14:20:52 -0500 Subject: [PATCH] Clean up tests --- tests/UserAgentParserFunctionTest.php | 10 +++++----- tests/UserAgentParserObjectTest.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/UserAgentParserFunctionTest.php b/tests/UserAgentParserFunctionTest.php index 89f09aa..0167ede 100644 --- a/tests/UserAgentParserFunctionTest.php +++ b/tests/UserAgentParserFunctionTest.php @@ -5,12 +5,12 @@ class UserAgentParserFunctionTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider userAgentDataProvider */ - public function test_parse_user_agent( $string, $expected ) { + public function test_parse_user_agent( string $string, array $expected ) : void { $result = parse_user_agent($string); $this->assertSame($expected, $result, $string . " test failed!"); } - public function userAgentDataProvider() { + public static function userAgentDataProvider() : array { $out = []; if( file_exists(__DIR__ . '/user_agents.json') && filesize(__DIR__ . '/user_agents.json') > 0 ) { $uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true); @@ -25,7 +25,7 @@ public function userAgentDataProvider() { return $out; } - public function test_parse_user_agent_empty() { + public function test_parse_user_agent_empty() : void { $expected = [ 'platform' => null, 'browser' => null, @@ -47,7 +47,7 @@ public function test_parse_user_agent_empty() { * * @see https://thephp.cc/news/2016/02/questioning-phpunit-best-practices */ - public function test_no_user_agent_exception() { + public function test_no_user_agent_exception() : void { unset($_SERVER['HTTP_USER_AGENT']); try { parse_user_agent(); @@ -59,7 +59,7 @@ public function test_no_user_agent_exception() { $this->fail("Expected \InvalidArgumentException"); } - public function test_global_user_agent() { + public function test_global_user_agent() : void { $_SERVER['HTTP_USER_AGENT'] = 'Test/1.0'; $this->assertSame([ 'platform' => null, 'browser' => 'Test', 'version' => '1.0' ], parse_user_agent()); } diff --git a/tests/UserAgentParserObjectTest.php b/tests/UserAgentParserObjectTest.php index 320e2d4..ae7817c 100644 --- a/tests/UserAgentParserObjectTest.php +++ b/tests/UserAgentParserObjectTest.php @@ -4,7 +4,7 @@ class UserAgentParserObjectTest extends \PHPUnit\Framework\TestCase { - public function userAgentDataProvider() { + public function userAgentDataProvider() : array { $out = []; if( file_exists(__DIR__ . '/user_agents.json') && filesize(__DIR__ . '/user_agents.json') > 0 ) { $uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true); @@ -22,7 +22,7 @@ public function userAgentDataProvider() { /** * @dataProvider userAgentDataProvider */ - public function test_parse( $string ) { + public function test_parse( $string ) : void { $parser = new UserAgentParser; $result = $parser->parse($string); @@ -36,7 +36,7 @@ public function test_parse( $string ) { /** * @dataProvider userAgentDataProvider */ - public function test_invoke( $string ) { + public function test_invoke( $string ) : void { $parser = new UserAgentParser; $result = $parser($string);