2
0

OfflineIpLocationTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_Service_DeveloperGarden
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. if (!defined('PHPUnit_MAIN_METHOD')) {
  23. define('PHPUnit_MAIN_METHOD', 'Zend_Service_DeveloperGarden_IpLocationTest::main');
  24. }
  25. /**
  26. * @see Zend_Service_DeveloperGarden_IpLocation
  27. */
  28. require_once 'Zend/Service/DeveloperGarden/IpLocation.php';
  29. /**
  30. * Zend_Service_DeveloperGarden test case
  31. *
  32. * @category Zend
  33. * @package Zend_Service_DeveloperGarden
  34. * @subpackage UnitTests
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. * @version $Id$
  38. */
  39. class Zend_Service_DeveloperGarden_OfflineIpLocationTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * @var Zend_Service_DeveloperGarden_OfflineIpLocation_Mock
  43. */
  44. protected $_service = null;
  45. public static function main()
  46. {
  47. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  48. PHPUnit_TextUI_TestRunner::run($suite);
  49. }
  50. public function setUp()
  51. {
  52. if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN')) {
  53. define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN', 'Unknown');
  54. }
  55. if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD')) {
  56. define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD', 'Unknown');
  57. }
  58. $config = array(
  59. 'username' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN,
  60. 'password' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD,
  61. );
  62. $this->service = new Zend_Service_DeveloperGarden_OfflineIpLocation_Mock($config);
  63. }
  64. /**
  65. * @expectedException Zend_Service_DeveloperGarden_Exception
  66. */
  67. public function testIpAddressVersion()
  68. {
  69. $ip = new Zend_Service_DeveloperGarden_IpLocation_IpAddress('127.0.0.1', 4);
  70. $this->assertNotNull($ip->setVersion(6));
  71. }
  72. /**
  73. * @expectedException Zend_Service_DeveloperGarden_Exception
  74. */
  75. public function testIpAddressInValid()
  76. {
  77. $ip = new Zend_Service_DeveloperGarden_IpLocation_IpAddress('266.266.266.266');
  78. }
  79. }
  80. class Zend_Service_DeveloperGarden_OfflineIpLocation_Mock
  81. extends Zend_Service_DeveloperGarden_IpLocation
  82. {
  83. }
  84. if (PHPUnit_MAIN_METHOD == 'Zend_Service_DeveloperGarden_OfflineIpLocationTest::main') {
  85. Zend_Service_DeveloperGarden_OfflineIpLocationTest::main();
  86. }