TeraWurflTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Http_UserAgent
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Zend_Http_UserAgent
  23. */
  24. require_once 'Zend/Http/UserAgent.php';
  25. require_once 'Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Http_UserAgent
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Http_UserAgent_Features_Adapter_TeraWurflTest extends PHPUnit_Framework_TestCase
  34. {
  35. public function setUp()
  36. {
  37. if (!constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR')) {
  38. $this->markTestSkipped('Requires TERAWURFL library');
  39. }
  40. $this->config['terawurfl']['terawurfl_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_TERAWURFL_LIB_DIR');
  41. error_reporting(E_ALL ^ E_NOTICE); // TeraWurfl.php having Notice messages
  42. }
  43. public function testGetFromRequest()
  44. {
  45. $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';
  46. $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
  47. $this->assertEquals('Safari', $wurfl['mobile_browser']);
  48. $this->assertEquals('iPhone OS', $wurfl['device_os']);
  49. $this->assertEquals('1.0', $wurfl['device_os_version']);
  50. $this->assertEquals('true', $wurfl['has_qwerty_keyboard']);
  51. $this->assertEquals('touchscreen', $wurfl['pointing_method']);
  52. $this->assertEquals('false', $wurfl['is_tablet']);
  53. $this->assertEquals('iPhone', $wurfl['model_name']);
  54. $this->assertEquals('Apple', $wurfl['brand_name']);
  55. $request['http_user_agent'] = 'SonyEricssonK700i/R2AC SEMC-Browser/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1';
  56. $wurfl = Zend_Http_UserAgent_Features_Adapter_TeraWurfl::getFromRequest($request, $this->config);
  57. $this->assertEquals('http://wap.sonyericsson.com/UAprof/K700iR101.xml', $wurfl['uaprof']);
  58. $this->assertEquals('SonyEricsson', $wurfl['brand_name']);
  59. $this->assertEquals('2002_january', $wurfl['release_date']);
  60. $this->assertEquals('false', $wurfl['has_qwerty_keyboard']);
  61. $this->assertEquals('', $wurfl['pointing_method']);
  62. $this->assertEquals('false', $wurfl['is_tablet']);
  63. $this->assertEquals('K700i', $wurfl['model_name']);
  64. }
  65. }