Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Aug 1, 2024
1 parent b551000 commit 3df7909
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tests/UserAgentParserFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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();
Expand All @@ -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());
}
Expand Down
6 changes: 3 additions & 3 deletions tests/UserAgentParserObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 3df7909

Please sign in to comment.