Quellcode durchsuchen

[1.11] Reviewed DeviceAtlas and TeraWurfl UserAgent adapters

- Coding standards review
- Added testing constants to TestConfiguration
- Do conditional checks for lib_dir options -- if class is discoverable via
  autoloading, no need to look for those values.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23130 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew vor 15 Jahren
Ursprung
Commit
e2d8c197a7

+ 43 - 41
library/Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php

@@ -1,4 +1,4 @@
-<?php
+<?php
 /**
  * Zend Framework
  *
@@ -17,13 +17,13 @@
  * @subpackage UserAgent
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
+ */
+
 /**
  * Zend_Http_UserAgent_Features_Adapter_Interface
- */
-require_once 'Zend/Http/UserAgent/Features/Adapter.php';
-
+ */
+require_once 'Zend/Http/UserAgent/Features/Adapter.php';
+
 /**
  * Features adapter build with the Tera Wurfl Api
  * See installation instruction here : http://deviceatlas.com/licences 
@@ -33,44 +33,46 @@ require_once 'Zend/Http/UserAgent/Features/Adapter.php';
  * @subpackage UserAgent
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
-{
-
+ */
+class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
+{
     /**
      * Get features from request
      *
      * @param  array $request $_SERVER variable
      * @return array
-     */
-    public static function getFromRequest($request, array $config)
-    {
-        if (!isset($config['deviceatlas'])) {
-            require_once 'Zend/Http/UserAgent/Features/Exception.php';
-            throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
-        }
-        
-        $config = $config['deviceatlas'];
-        
-        if (empty($config['deviceatlas_lib_dir'])) {
-            require_once 'Zend/Http/UserAgent/Features/Exception.php';
-            throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
-        }
-        
-        if (empty($config['deviceatlas_data'])) {
-            require_once 'Zend/Http/UserAgent/Features/Exception.php';
-            throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
-        }
-        
-        // Include the Device Atlas file
-        require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
-        
-        //load the device data-tree : e.g. 'json/DeviceAtlas.json
-        $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
-        
-        $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
-        
-        return $properties;
-    }
-
+     */
+    public static function getFromRequest($request, array $config)
+    {
+        if (!class_exists('Mobi_Mtld_DA_Api')) {
+            if (!isset($config['deviceatlas'])) {
+                require_once 'Zend/Http/UserAgent/Features/Exception.php';
+                throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
+            }
+        }
+        
+        $config = $config['deviceatlas'];
+        
+        if (!class_exists('Mobi_Mtld_DA_Api')) {
+            if (empty($config['deviceatlas_lib_dir'])) {
+                require_once 'Zend/Http/UserAgent/Features/Exception.php';
+                throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
+            }
+
+            // Include the Device Atlas file from the specified lib_dir
+            require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
+        }
+        
+        if (empty($config['deviceatlas_data'])) {
+            require_once 'Zend/Http/UserAgent/Features/Exception.php';
+            throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
+        }
+        
+        //load the device data-tree : e.g. 'json/DeviceAtlas.json
+        $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
+        
+        $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
+        
+        return $properties;
+    }
 }

+ 66 - 59
library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php

@@ -1,4 +1,4 @@
-<?php
+<?php
 /**
  * Zend Framework
  *
@@ -17,13 +17,13 @@
  * @subpackage UserAgent
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
+ */
+
 /**
  * Zend_Http_UserAgent_Features_Adapter_Interface
- */
-require_once 'Zend/Http/UserAgent/Features/Adapter.php';
-
+ */
+require_once 'Zend/Http/UserAgent/Features/Adapter.php';
+
 /**
  * Features adapter build with the Tera Wurfl Api
  * See installation instruction here : http://www.tera-wurfl.com/wiki/index.php/Installation 
@@ -33,63 +33,70 @@ require_once 'Zend/Http/UserAgent/Features/Adapter.php';
  * @subpackage UserAgent
  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Http_UserAgent_Features_Adapter_TeraWurfl implements Zend_Http_UserAgent_Features_Adapter
-{
-
+ */
+class Zend_Http_UserAgent_Features_Adapter_TeraWurfl implements Zend_Http_UserAgent_Features_Adapter
+{
     /**
      * Get features from request
      *
      * @param  array $request $_SERVER variable
      * @return array
-     */
-    public static function getFromRequest($request, array $config)
-    {
-        if (!isset($config['terawurfl'])) {
-            require_once 'Zend/Http/UserAgent/Features/Exception.php';
-            throw new Zend_Http_UserAgent_Features_Exception('"TeraWurfl" configuration is not defined');
-        }
-        
-        $config = $config['terawurfl'];
-        
-        if (empty($config['terawurfl_lib_dir'])) {
-            require_once 'Zend/Http/UserAgent/Features/Exception.php';
-            throw new Zend_Http_UserAgent_Features_Exception('The "terawurfl_lib_dir" parameter is not defined');
-        }
-        
-        // Include the Tera-WURFL file
-        require_once ($config['terawurfl_lib_dir'] . '/TeraWurfl.php');
-        
+     */
+    public static function getFromRequest($request, array $config)
+    {
+        if (!class_exists('TeraWurfl')) {
+            // If TeraWurfl class not found, see if we can load it from 
+            // configuration
+            //
+            if (!isset($config['terawurfl'])) {
+                // No configuration
+                require_once 'Zend/Http/UserAgent/Features/Exception.php';
+                throw new Zend_Http_UserAgent_Features_Exception('"TeraWurfl" configuration is not defined');
+            }
+            
+            $config = $config['terawurfl'];
+
+             if (empty($config['terawurfl_lib_dir'])) {
+                // No lib_dir given
+                require_once 'Zend/Http/UserAgent/Features/Exception.php';
+                throw new Zend_Http_UserAgent_Features_Exception('The "terawurfl_lib_dir" parameter is not defined');
+            }
+
+            // Include the Tera-WURFL file
+            require_once ($config['terawurfl_lib_dir'] . '/TeraWurfl.php');
+        }
+        
+        
         // instantiate the Tera-WURFL object
-        $wurflObj = new TeraWurfl();
-        
-        // Get the capabilities of the current client.
-        $matched = $wurflObj->getDeviceCapabilitiesFromRequest(array_change_key_case($request, CASE_UPPER));
-        
-        return self::getAllCapabilities($wurflObj);
-    }
-
-    /***
-     * Builds an array with all capabilities
-     * 
-     * @param TeraWurfl $wurflObj TeraWurfl object
-     */
-    public static function getAllCapabilities(TeraWurfl $wurflObj)
-    {
-        
-        foreach ($wurflObj->capabilities as $group) {
-            if (!is_array($group)) {
-                continue;
-            }
-            while (list ($key, $value) = each($group)) {
-                if (is_bool($value)) {
-                    // to have the same type than the official WURFL API
-                    $features[$key] = ($value ? 'true' : 'false');
-                } else {
-                    $features[$key] = $value;
-                }
-            }
-        }
-        return $features;
-    }
+        $wurflObj = new TeraWurfl();
+        
+        // Get the capabilities of the current client.
+        $matched = $wurflObj->getDeviceCapabilitiesFromRequest(array_change_key_case($request, CASE_UPPER));
+        
+        return self::getAllCapabilities($wurflObj);
+    }
+
+    /***
+     * Builds an array with all capabilities
+     * 
+     * @param TeraWurfl $wurflObj TeraWurfl object
+     */
+    public static function getAllCapabilities(TeraWurfl $wurflObj)
+    {
+        
+        foreach ($wurflObj->capabilities as $group) {
+            if (!is_array($group)) {
+                continue;
+            }
+            while (list ($key, $value) = each($group)) {
+                if (is_bool($value)) {
+                    // to have the same type than the official WURFL API
+                    $features[$key] = ($value ? 'true' : 'false');
+                } else {
+                    $features[$key] = $value;
+                }
+            }
+        }
+        return $features;
+    }
 }

+ 13 - 0
tests/TestConfiguration.php.dist

@@ -334,6 +334,19 @@ define('TESTS_ZEND_HTTP_USERAGENT_WURFL_LIB_DIR', false);
 define('TESTS_ZEND_HTTP_USERAGENT_WURFL_CONFIG_FILE', false);
 
 /**
+ * Location of DeviceAtlas library and data file, for testing mobile device
+ * detection against DeviceAtlas
+ */
+define('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_LIB_DIR', false);
+define('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_DATA_FILE', false);
+
+/**
+ * Location of TeraWurfl library and data file, for testing mobile device
+ * detection against TeraWurfl
+ */
+define('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR', false);
+
+/**
  * Zend_Loader_Autoloader multi-version support tests
  *
  * ENABLED:      whether or not to run the multi-version tests

+ 67 - 68
tests/Zend/Http/UserAgent/Features/Adapter/DeviceAtlasTest.php

@@ -1,68 +1,67 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Http_UserAgent
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once dirname(__FILE__) . '/../../../../../TestHelper.php';
-
-/**
- * Zend_Http_UserAgent
- */
-require_once 'Zend/Http/UserAgent.php';
-require_once 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
-
-/**
- * @category   Zend
- * @package    Zend_Http_UserAgent
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Http_UserAgent_Features_Adapter_DeviceAtlasTest extends PHPUnit_Framework_TestCase
-{
-
-    public function setUp()
-    {
-        if (!constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_LIB_DIR') || !constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_DATA_FILE')) {
-            $this->markTestSkipped('Requires Device Atlas library');
-        }
-        $this->config['deviceatlas']['deviceatlas_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_LIB_DIR');
-        $this->config['deviceatlas']['deviceatlas_data'] = constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_DATA_FILE');
-        $this->config['mobile']['features']['path'] = 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
-        $this->config['mobile']['features']['classname'] = 'Zend_Http_UserAgent_Features_Adapter_DeviceAtlas';
-    }
-
-    public function testGetFromRequest()
-    {
-        $request['http_user_agent'] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleW1ebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3';
-        $deviceAtlas = Zend_Http_UserAgent_Features_Adapter_DeviceAtlas::getFromRequest($request, $this->config);
-        $this->assertEquals(1, $deviceAtlas['touchScreen']);
-        $this->assertEquals(1, $deviceAtlas['markup.xhtmlBasic10']);
-        $this->assertEquals('iPhone', $deviceAtlas['model']);
-        $this->assertEquals('Mozilla/5.0 (iPhone; U; C', $deviceAtlas['_matched']);
-        $this->assertEquals('Apple', $deviceAtlas['vendor']);
-        
-        $request['http_user_agent'] = 'SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
-        $deviceAtlas = Zend_Http_UserAgent_Features_Adapter_DeviceAtlas::getFromRequest($request, $this->config);
-        $this->assertEquals(20000, $deviceAtlas['memoryLimitMarkup']);
-        $this->assertEquals('K700i', $deviceAtlas['model']);
-        $this->assertEquals('SonyEricssonK700i', $deviceAtlas['_matched']);
-        $this->assertEquals('Sony Ericsson', $deviceAtlas['vendor']);
-    }
-}
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Http_UserAgent
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once dirname(__FILE__) . '/../../../../../TestHelper.php';
+
+require_once 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Http_UserAgent
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Http_UserAgent_Features_Adapter_DeviceAtlasTest extends PHPUnit_Framework_TestCase
+{
+
+    public function setUp()
+    {
+        if (!constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_LIB_DIR') 
+            || !constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_DATA_FILE')
+        ) {
+            $this->markTestSkipped('Requires Device Atlas library');
+        }
+
+        $this->config['deviceatlas']['deviceatlas_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_LIB_DIR');
+        $this->config['deviceatlas']['deviceatlas_data']    = constant('TESTS_ZEND_HTTP_USERAGENT_DEVICEATLAS_DATA_FILE');
+        $this->config['mobile']['features']['path']         = 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
+        $this->config['mobile']['features']['classname']    = 'Zend_Http_UserAgent_Features_Adapter_DeviceAtlas';
+    }
+
+    public function testGetFromRequest()
+    {
+        $request['http_user_agent'] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleW1ebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3';
+        $deviceAtlas = Zend_Http_UserAgent_Features_Adapter_DeviceAtlas::getFromRequest($request, $this->config);
+        $this->assertEquals(1,                           $deviceAtlas['touchScreen']);
+        $this->assertEquals(1,                           $deviceAtlas['markup.xhtmlBasic10']);
+        $this->assertEquals('iPhone',                    $deviceAtlas['model']);
+        $this->assertEquals('Mozilla/5.0 (iPhone; U; C', $deviceAtlas['_matched']);
+        $this->assertEquals('Apple',                     $deviceAtlas['vendor']);
+        
+        $request['http_user_agent'] = 'SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
+        $deviceAtlas = Zend_Http_UserAgent_Features_Adapter_DeviceAtlas::getFromRequest($request, $this->config);
+        $this->assertEquals(20000,               $deviceAtlas['memoryLimitMarkup']);
+        $this->assertEquals('K700i',             $deviceAtlas['model']);
+        $this->assertEquals('SonyEricssonK700i', $deviceAtlas['_matched']);
+        $this->assertEquals('Sony Ericsson',     $deviceAtlas['vendor']);
+    }
+}

+ 71 - 72
tests/Zend/Http/UserAgent/Features/Adapter/TeraWurflTest.php

@@ -1,72 +1,71 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category   Zend
- * @package    Zend_Http_UserAgent
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-
-require_once dirname(__FILE__) . '/../../../../../TestHelper.php';
-
-/**
- * Zend_Http_UserAgent
- */
-require_once 'Zend/Http/UserAgent.php';
-require_once 'Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php';
-
-/**
- * @category   Zend
- * @package    Zend_Http_UserAgent
- * @subpackage UnitTests
- * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license    http://framework.zend.com/license/new-bsd     New BSD License
- */
-class Zend_Http_UserAgent_Features_Adapter_TeraWurflTest extends PHPUnit_Framework_TestCase
-{
-
-    public function setUp()
-    {
-        if (!constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR')) {
-            $this->markTestSkipped('Requires TERAWURFL library');
-        }
-        $this->config['terawurfl']['terawurfl_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR');
-        error_reporting(E_ALL ^ E_NOTICE); // TeraWurfl.php having Notice messages
-    }
-
-    public function testGetFromRequest()
-    {
-        $request['http_user_agent'] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleW1ebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3';
-        $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
-        $this->assertEquals('Safari', $wurfl['mobile_browser']);
-        $this->assertEquals('iPhone OS', $wurfl['device_os']);
-        $this->assertEquals('1.0', $wurfl['device_os_version']);
-        $this->assertEquals('true', $wurfl['has_qwerty_keyboard']);
-        $this->assertEquals('touchscreen', $wurfl['pointing_method']);
-        $this->assertEquals('false', $wurfl['is_tablet']);
-        $this->assertEquals('iPhone', $wurfl['model_name']);
-        $this->assertEquals('Apple', $wurfl['brand_name']);
-        
-        $request['http_user_agent'] = 'SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
-        $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
-        $this->assertEquals('http://wap.sonyericsson.com/UAprof/K700iR101.xml', $wurfl['uaprof']);
-        $this->assertEquals('SonyEricsson', $wurfl['brand_name']);
-        $this->assertEquals('2002_january', $wurfl['release_date']);
-        $this->assertEquals('false', $wurfl['has_qwerty_keyboard']);
-        $this->assertEquals('', $wurfl['pointing_method']);
-        $this->assertEquals('false', $wurfl['is_tablet']);
-        $this->assertEquals('K700i', $wurfl['model_name']);
-    }
-}
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Http_UserAgent
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+
+require_once dirname(__FILE__) . '/../../../../../TestHelper.php';
+
+/**
+ * Zend_Http_UserAgent
+ */
+require_once 'Zend/Http/UserAgent.php';
+require_once 'Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Http_UserAgent
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
+class Zend_Http_UserAgent_Features_Adapter_TeraWurflTest extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        if (!constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR')) {
+            $this->markTestSkipped('Requires TERAWURFL library');
+        }
+        $this->config['terawurfl']['terawurfl_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR');
+        error_reporting(E_ALL ^ E_NOTICE); // TeraWurfl.php having Notice messages
+    }
+
+    public function testGetFromRequest()
+    {
+        $request['http_user_agent'] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleW1ebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3';
+        $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
+        $this->assertEquals('Safari',      $wurfl['mobile_browser']);
+        $this->assertEquals('iPhone OS',   $wurfl['device_os']);
+        $this->assertEquals('1.0',         $wurfl['device_os_version']);
+        $this->assertEquals('true',        $wurfl['has_qwerty_keyboard']);
+        $this->assertEquals('touchscreen', $wurfl['pointing_method']);
+        $this->assertEquals('false',       $wurfl['is_tablet']);
+        $this->assertEquals('iPhone',      $wurfl['model_name']);
+        $this->assertEquals('Apple',       $wurfl['brand_name']);
+        
+        $request['http_user_agent'] = 'SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
+        $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
+        $this->assertEquals('http://wap.sonyericsson.com/UAprof/K700iR101.xml', $wurfl['uaprof']);
+        $this->assertEquals('SonyEricsson', $wurfl['brand_name']);
+        $this->assertEquals('2002_january', $wurfl['release_date']);
+        $this->assertEquals('false',        $wurfl['has_qwerty_keyboard']);
+        $this->assertEquals('',             $wurfl['pointing_method']);
+        $this->assertEquals('false',        $wurfl['is_tablet']);
+        $this->assertEquals('K700i',        $wurfl['model_name']);
+    }
+}