WurflApiTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once dirname(__FILE__) . '/../../../../../TestHelper.php';
  22. /**
  23. * Zend_Http_UserAgent
  24. */
  25. require_once 'Zend/Http/UserAgent.php';
  26. require_once 'Zend/Http/UserAgent/Features/Adapter/WurflApi.php';
  27. /** to generate the cache */
  28. set_time_limit(0);
  29. /**
  30. * @category Zend
  31. * @package Zend_Http_UserAgent
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Http_UserAgent_Features_Adapter_WurflApiTest extends PHPUnit_Framework_TestCase
  37. {
  38. public function setUp()
  39. {
  40. if (!constant('TESTS_ZEND_HTTP_USERAGENT_WURFL_LIB_DIR')
  41. || !constant('TESTS_ZEND_HTTP_USERAGENT_WURFL_CONFIG_FILE')
  42. ) {
  43. $this->markTestSkipped('Requires WURFL library');
  44. }
  45. $this->config['wurflapi']['wurfl_lib_dir'] = constant('TESTS_ZEND_HTTP_USERAGENT_WURFL_LIB_DIR');
  46. $this->config['wurflapi']['wurfl_config_file'] = constant('TESTS_ZEND_HTTP_USERAGENT_WURFL_CONFIG_FILE');
  47. }
  48. public function testGetFromRequest()
  49. {
  50. $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';
  51. $wurfl = Zend_Http_UserAgent_Features_Adapter_WurflApi::getFromRequest($request, $this->config);
  52. $this->assertEquals('Safari', $wurfl['mobile_browser']);
  53. $this->assertEquals('iPhone OS', $wurfl['device_os']);
  54. $this->assertEquals('1.0', $wurfl['device_os_version']);
  55. $this->assertEquals('true', $wurfl['has_qwerty_keyboard']);
  56. $this->assertEquals('touchscreen', $wurfl['pointing_method']);
  57. $this->assertEquals('false', $wurfl['is_tablet']);
  58. $this->assertEquals('iPhone', $wurfl['model_name']);
  59. $this->assertEquals('Apple', $wurfl['brand_name']);
  60. }
  61. }