✨ Hello world!
This commit is contained in:
50
vendor/donatj/phpuseragentparser/tests/UserAgentParserFunctionTest.php
vendored
Normal file
50
vendor/donatj/phpuseragentparser/tests/UserAgentParserFunctionTest.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class UserAgentParserFunctionTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider userAgentDataProvider
|
||||
*/
|
||||
public function test_parse_user_agent( $string, $expected ) {
|
||||
$result = parse_user_agent($string);
|
||||
$this->assertSame($expected, $result, $string . " test failed!");
|
||||
}
|
||||
|
||||
public function userAgentDataProvider() {
|
||||
$out = array();
|
||||
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
|
||||
foreach( $uas as $string => $parts ) {
|
||||
$out[] = array( $string, $parts );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function test_parse_user_agent_empty() {
|
||||
$expected = array(
|
||||
'platform' => null,
|
||||
'browser' => null,
|
||||
'version' => null,
|
||||
);
|
||||
|
||||
$result = parse_user_agent('');
|
||||
$this->assertSame($result, $expected);
|
||||
|
||||
$result = parse_user_agent('Mozilla (asdjkakljasdkljasdlkj) BlahBlah');
|
||||
$this->assertSame($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function test_no_user_agent_exception() {
|
||||
unset($_SERVER['HTTP_USER_AGENT']);
|
||||
parse_user_agent();
|
||||
}
|
||||
|
||||
public function test_global_user_agent() {
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Test/1.0';
|
||||
$this->assertSame(array( 'platform' => null, 'browser' => 'Test', 'version' => '1.0' ), parse_user_agent());
|
||||
}
|
||||
|
||||
}
|
45
vendor/donatj/phpuseragentparser/tests/UserAgentParserObjectTest.php
vendored
Normal file
45
vendor/donatj/phpuseragentparser/tests/UserAgentParserObjectTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use donatj\UserAgent\UserAgentParser;
|
||||
|
||||
class UserAgentParserObjectTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public function userAgentDataProvider() {
|
||||
$out = array();
|
||||
$uas = json_decode(file_get_contents(__DIR__ . '/user_agents.json'), true);
|
||||
foreach( $uas as $string => $parts ) {
|
||||
$out[] = array( $string );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider userAgentDataProvider
|
||||
*/
|
||||
public function test_parse( $string ) {
|
||||
$parser = new UserAgentParser;
|
||||
$result = $parser->parse($string);
|
||||
|
||||
$expected = parse_user_agent($string);
|
||||
|
||||
$this->assertSame($expected[\donatj\UserAgent\PLATFORM], $result->platform());
|
||||
$this->assertSame($expected[\donatj\UserAgent\BROWSER], $result->browser());
|
||||
$this->assertSame($expected[\donatj\UserAgent\BROWSER_VERSION], $result->browserVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider userAgentDataProvider
|
||||
*/
|
||||
public function test_invoke( $string ) {
|
||||
$parser = new UserAgentParser;
|
||||
$result = $parser($string);
|
||||
|
||||
$expected = parse_user_agent($string);
|
||||
|
||||
$this->assertSame($expected[\donatj\UserAgent\PLATFORM], $result->platform());
|
||||
$this->assertSame($expected[\donatj\UserAgent\BROWSER], $result->browser());
|
||||
$this->assertSame($expected[\donatj\UserAgent\BROWSER_VERSION], $result->browserVersion());
|
||||
}
|
||||
|
||||
}
|
1027
vendor/donatj/phpuseragentparser/tests/user_agents.json
vendored
Normal file
1027
vendor/donatj/phpuseragentparser/tests/user_agents.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user