WurflApiTest.php 2.6 KB

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