Issue Type: Bug Created: 2012-05-10T20:47:56.000+0000 Last Updated: 2012-06-15T08:44:24.000+0000 Status: Open Fix version(s): Reporter: Martin Hujer (mhujer) Assignee: Business&Decision / Interakting (interakting) Tags: - Zend_Http_UserAgent
Related issues: Attachments:
And are skipped on Linux, because of missing browscap.
On PHP 5.3.8, Windows 7 64bit, PHPUnit 3.4.15:
<pre class="highlight">
1) Zend_Http_UserAgentTest::testUserAgentDefineIdentificationSequence
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-iPhone
+Default Browser
I:\xampp\zf\tests\Zend\Http\UserAgentTest.php:125
2) Zend_Http_UserAgent_Features_Adapter_BrowscapTest::testGetFromRequest
Failed asserting that matches expected
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-04T16:28:03.000+0000
On Linux testUserAgentDefineIdentificationSequence fails for a different reason when using the browscap file from PHP 5.4.2 or 5.3.10:
<pre class="highlight">
1) Zend_Http_UserAgentTest::testUserAgentDefineIdentificationSequence
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-iPhone
+Safari
Posted by Henry Hayes (henryhayes) on 2012-06-15T08:44:24.000+0000
Hi Guys,
I have improved the unit tests for this. Now, it uses a dataProvider to supply the useragent and expected results.
<pre class="highlight">
/**
* Unit test for Zend_Http_UserAgent_Features_Adapter_Browscap::testGetFromRequest
*
* @dataProvider dataProvider
*/
public function testGetFromRequest($userAgentString, array $params)
{
$request = array();
$request['http_user_agent'] = $userAgentString;
$adapter = Zend_Http_UserAgent_Features_Adapter_Browscap::getFromRequest($request, array());
foreach ($params as $name => $value) {
$this->assertEquals($value, $adapter[$name]);
}
}
/**
* Data provider for testGetFromRequest().
*/
public function dataProvider()
{
return array(
// Generic iPhone
array(
'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) ' .
'Version/3.0 Mobile/4A102 Safari/419.3',
array(
'ismobiledevice' => '1',
'javascript' => '1',
'cssversion' => '3',
'device_name' => 'iPhone',
'mobile_browser' => 'Safari',
'device_os' => 'iOS',
)
),
// Generic iPad
array(
'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 ' .
'(KHTML, like Gecko) Mobile/*',
array(
'ismobiledevice' => '1',
'javascript' => '1',
'cssversion' => '3',
'device_name' => 'iPad',
'mobile_browser' => 'Safari',
'device_os' => 'iOS',
)
),
// MS IE 9 Windows 7 x64
array(
'Mozilla/5.0 (compatible; MSIE 9.0; *Windows NT 6.1; WOW64; Trident/5.0*)*',
array(
'ismobiledevice' => '',
'javascript' => '1',
'cssversion' => '3',
'device_name' => 'PC',
'mobile_browser' => 'IE',
'device_os' => 'Win7',
'win64' => '1',
)
),
// Linux Firefox 13.0
array(
'Mozilla/5.0 (*Linux*) Gecko/* Firefox/13.*',
array(
'ismobiledevice' => '',
'javascript' => '1',
'cssversion' => '3',
'device_name' => 'PC',
'mobile_browser' => 'Firefox',
'device_os' => 'Linux',
)
),
);
}
It is temporarily implemented here: