markTestSkipped('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_ENABLED is not enabled'); } if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN')) { define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN', 'Unknown'); } if (!defined('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD')) { define('TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD', 'Unknown'); } $config = array( 'username' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_LOGIN, 'password' => TESTS_ZEND_SERVICE_DEVELOPERGARDEN_ONLINE_PASSWORD, ); $this->service = new Zend_Service_DeveloperGarden_IpLocation_Mock($config); } public function testLocateValid() { try { $result = $this->service->locateIP('217.7.192.1'); $this->assertTrue(is_array($result->getIpAddressLocation())); } catch (Exception $e) { if ($e->getMessage() != 'quotas have exceeded') { throw $e; } else { $this->markTestSkipped('Quota exceeded.'); } } } /** * @expectedException Zend_Service_DeveloperGarden_Response_Exception */ public function testLocateIpNotFound() { $this->service->locateIP('127.0.0.1'); } /** * @expectedException Zend_Service_DeveloperGarden_Exception */ public function testLocateIpNotFoundShort() { $this->service->locateIP('127'); } /** * @expectedException Zend_Service_DeveloperGarden_Exception */ public function testLocateIpNotFoundString() { $this->service->locateIP('someStuff'); } } class Zend_Service_DeveloperGarden_IpLocation_Mock extends Zend_Service_DeveloperGarden_IpLocation { } if (PHPUnit_MAIN_METHOD == 'Zend_Service_DeveloperGarden_IpLocationTest::main') { Zend_Service_DeveloperGarden_IpLocationTest::main(); }