|
7 | 7 |
|
8 | 8 | final class StaticTest extends TestCase |
9 | 9 | { |
10 | | - public function testStaticUserAgent() |
| 10 | + public function userAgentStaticProvider() |
11 | 11 | { |
12 | | - $userAgents = [ |
13 | | - 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko' => [ |
| 12 | + return [ |
| 13 | + [ |
| 14 | + 'useragent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', |
14 | 15 | 'browser' => Browser::BROWSER_IE, |
15 | | - 'version' => '11.0' |
16 | | - ] |
| 16 | + 'version' => '11.0', |
| 17 | + 'platform' => Browser::PLATFORM_WINDOWS, |
| 18 | + 'mobile' => false, |
| 19 | + ], |
| 20 | + [ |
| 21 | + 'useragent' => 'Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0', |
| 22 | + 'browser' => Browser::BROWSER_FIREFOX, |
| 23 | + 'version' => '41.0', |
| 24 | + 'platform' => Browser::PLATFORM_ANDROID, |
| 25 | + 'mobile' => true, |
| 26 | + ], |
| 27 | + [ |
| 28 | + 'useragent' => 'Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0', |
| 29 | + 'browser' => Browser::BROWSER_FIREFOX, |
| 30 | + 'version' => '41.0', |
| 31 | + 'platform' => Browser::PLATFORM_ANDROID, |
| 32 | + 'mobile' => true, |
| 33 | + ], |
| 34 | + [ |
| 35 | + 'useragent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/28.0.1500.16 Mobile/10B350 Safari/8536.25', |
| 36 | + 'browser' => Browser::BROWSER_CHROME, |
| 37 | + 'version' => '28.0.1500.16', |
| 38 | + 'platform' => Browser::PLATFORM_IPHONE, |
| 39 | + 'mobile' => true, |
| 40 | + ], |
| 41 | + [ |
| 42 | + 'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) DumpRenderTree/0.0.0.0 Safari/536.11', |
| 43 | + 'browser' => Browser::BROWSER_SAFARI, |
| 44 | + 'version' => 'unknown', // all we really know here is that it's based on webkit; we do not really have a version number to deal with |
| 45 | + 'platform' => Browser::PLATFORM_LINUX, |
| 46 | + 'mobile' => false, |
| 47 | + ], |
| 48 | + [ |
| 49 | + 'useragent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/28.0.1500.16 Mobile/10B142 Safari/8536.25', |
| 50 | + 'browser' => Browser::BROWSER_CHROME, |
| 51 | + 'version' => '28.0.1500.16', |
| 52 | + 'platform' => Browser::PLATFORM_IPHONE, |
| 53 | + 'mobile' => true, |
| 54 | + ], |
| 55 | + [ |
| 56 | + 'useragent' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; HTC; Radar; Orange)', |
| 57 | + 'browser' => Browser::BROWSER_POCKET_IE, |
| 58 | + 'version' => '9.0', |
| 59 | + 'platform' => Browser::PLATFORM_WINDOWS, |
| 60 | + 'mobile' => true, |
| 61 | + ], |
17 | 62 | ]; |
18 | | - foreach($userAgents as $userAgent => $info) { |
19 | | - $b = new Browser($userAgent); |
20 | | - $this->assertSame($info['browser'], $b->getBrowser()); |
21 | | - $this->assertSame($info['version'], $b->getVersion()); |
22 | | - } |
23 | 63 |
|
24 | 64 | } |
| 65 | + |
| 66 | + /** |
| 67 | + * @dataProvider userAgentStaticProvider |
| 68 | + * @param $userAgent string Browser's User Agent |
| 69 | + * @param $type string Type of the Browser |
| 70 | + * @param $browser string Name of the Browser |
| 71 | + * @param $version string Version of the Browser |
| 72 | + * @param $osType string Type of operating system associated with the Browser |
| 73 | + * @param $osName string Name of the operating system associated with the Browser, typically has the version number |
| 74 | + * @param $osVersionName string Version of the Operating System (name) |
| 75 | + * @param $osVersionNumber string Version of the Operating System (number) |
| 76 | + */ |
| 77 | + public function testStaticUserAgent($userAgent,$browser,$version,$platform,$mobile) |
| 78 | + { |
| 79 | + $b = new Browser($userAgent); |
| 80 | + |
| 81 | + $this->assertSame((string)$browser, $b->getBrowser()); |
| 82 | + $this->assertSame((string)$version, $b->getVersion()); |
| 83 | + $this->assertSame((string)$platform, $b->getPlatform()); |
| 84 | + $this->assertSame((boolean)$mobile, $b->isMobile()); |
| 85 | + } |
25 | 86 | } |
0 commit comments