/** * @todo are the dummy values for user and key okay? */ public function setUp() { $this->rackspace = new Servers('foo', 'bar'); $this->httpClientAdapterTest = new HttpTest(); $this->rackspace->getHttpClient()->setAdapter($this->httpClientAdapterTest); // authentication (from a file) $this->httpClientAdapterTest->setResponse(self::loadResponse('../../_files/testAuthenticate')); $this->assertTrue($this->rackspace->authenticate(), 'Authentication failed'); // load the HTTP response (from a file) $this->httpClientAdapterTest->setResponse($this->loadResponse($this->getName())); }
/** * SetUpBerofeClass */ public static function setUpBeforeClass() { if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) { self::markTestSkipped('Zend\\Service\\Rackspace\\Servers online tests are not enabled'); } if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) { self::markTestSkipped('Constants User and Key have to be set.'); } self::$rackspace = new Servers(TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER, TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY); self::$httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket(); self::$rackspace->getHttpClient()->setAdapter(self::$httpClientAdapterSocket); }
/** * Sets up this test case * * @return void */ public function setUp() { if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED') || TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED != true) { $this->markTestSkipped('Zend\\Service\\Rackspace\\Servers online tests are not enabled'); } if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) { self::markTestSkipped('Constants User and Key have to be set.'); } $this->rackspace = new Servers(TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER, TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY); $this->httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket(); $this->rackspace->getHttpClient()->setAdapter($this->httpClientAdapterSocket); // terms of use compliance: safe delay between each test sleep(2); }
/** * Get the last HTTP response * * @return \Zend\Http\Response */ public function getLastHttpResponse() { return $this->rackspace->getHttpClient()->getResponse()->toString(); }