Issues

ZF-12202: Some Zend_Http_UserAgent test fail on Windows

Description

And are skipped on Linux, because of missing browscap.

On PHP 5.3.8, Windows 7 64bit, PHPUnit 3.4.15:


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 

Comments

On Linux {{testUserAgentDefineIdentificationSequence}} fails for a different reason when using the browscap file from PHP 5.4.2 or 5.3.10:


1) Zend_Http_UserAgentTest::testUserAgentDefineIdentificationSequence
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-iPhone
+Safari

Hi Guys,

I have improved the unit tests for this. Now, it uses a {{dataProvider}} to supply the useragent and expected results.


/**
     * 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:

http://yinyang.googlecode.com/svn/trunk/…