コード例 #1
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Rackspace',
            Rackspace::RACKSPACE_USER   => 'test', 
            Rackspace::RACKSPACE_KEY    => 'test', 
            Rackspace::RACKSPACE_REGION => 'USA'  
        )); 

        $this->httpClientAdapterTest = new HttpTest();

        $this->infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter($this->httpClientAdapterTest);
        
        $shortClassName = 'RackspaceTest';      
        // load the HTTP response (from a file)
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';
        
        if (file_exists($filename)) {
            // authentication (from file)
            $content = file_get_contents(dirname(__FILE__) . '/_files/'.$shortClassName . '_testAuthenticate.response');
            $this->httpClientAdapterTest->setResponse($content);
            $this->assertTrue($this->infrastructure->getAdapter()->authenticate(),'Authentication failed');
            // set the specific API response
            $content = file_get_contents($filename);
            $this->httpClientAdapterTest->setResponse($content); 
        }
        
    }
コード例 #2
0
    /**
     * Setup for each test
     */
    public function setUp()
    {
        $this->infrastructure = CloudFactory::getAdapter(array( 
            CloudFactory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Ec2',
            Ec2::AWS_ACCESS_KEY         => '0123456789', 
            Ec2::AWS_SECRET_KEY         => 'test', 
            Ec2::AWS_REGION             => 'us-east-1'     
        )); 

        $this->httpClientAdapterTest = new HttpTest();     

        // load the HTTP response (from a file)
        $shortClassName = 'Ec2Test';
        $filename= dirname(__FILE__) . '/_files/' . $shortClassName . '_'. $this->getName().'.response';

        if (file_exists($filename)) {
            $this->httpClientAdapterTest->setResponse(file_get_contents($filename)); 
        }
        
        $adapter= $this->infrastructure->getAdapter();
        
        $client = new HttpClient(null, array(
            'adapter' => $this->httpClientAdapterTest
        ));
        
        call_user_func(array($adapter,'setHttpClient'),$client);
    
    }
コード例 #3
0
ファイル: FactoryTest.php プロジェクト: bradley-holt/zf2
 public function testGetAdapterWithConfig()
 {
     // EC2 adapter
     $Ec2Adapter = CloudFactory::getAdapter(new Config(Ec2OfflineTest::getConfigArray(), true));
     $this->assertEquals('Zend\\Cloud\\Infrastructure\\Adapter\\Ec2', get_class($Ec2Adapter));
     // Rackspace adapter
     $rackspaceAdapter = CloudFactory::getAdapter(new Config(RackspaceOfflineTest::getConfigArray(), true));
     $this->assertEquals('Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace', get_class($rackspaceAdapter));
 }
コード例 #4
0
 /**
  * Setup for each test
  */
 public function setUp()
 {
     if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) {
         $this->markTestSkipped('Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace online tests are not enabled');
     }
     if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER') || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')) {
         $this->markTestSkipped('Constants User and Key have to be set.');
     }
     self::$infrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter(array(\Zend\Cloud\Infrastructure\Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\\Cloud\\Infrastructure\\Adapter\\Rackspace', \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_USER => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'), \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_KEY => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'), \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_REGION => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION')));
     self::$httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket();
     self::$infrastructure->getAdapter()->getHttpClient()->setAdapter(self::$httpClientAdapterSocket);
     // terms of use compliance: no more than two queries per second
     sleep(2);
 }
コード例 #5
0
ファイル: Ec2OnlineTest.php プロジェクト: nevvermind/zf2
 /**
  * Setup for each test
  */
 public function setUp()
 {
     if (!constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED')) {
         $this->markTestSkipped('Zend\\Cloud\\Infrastructure\\Adapter\\Ec2 online tests are not enabled');
     }
     if (!defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || !defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY')) {
         $this->markTestSkipped('Constants AccessKeyId and SecretKey have to be set.');
     }
     self::$infrastructure = Factory::getAdapter(array(Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\\Cloud\\Infrastructure\\Adapter\\Ec2', Ec2::AWS_ACCESS_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), Ec2::AWS_SECRET_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'), Ec2::AWS_REGION => constant('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE')));
     self::$httpClientAdapterSocket = new Socket();
     self::$infrastructure->getAdapter()->getHttpClient()->setAdapter(self::$httpClientAdapterSocket);
     // terms of use compliance: no more than two queries per second
     sleep(2);
 }
コード例 #6
0
ファイル: Ec2OnlineTest.php プロジェクト: ruflin/zf2
    /**
     * Sets up this test case
     *
     * @return void
     */
    public static function setUpBeforeClass()
    {
        if (!constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED')) {
            self::markTestSkipped('Zend\Cloud\Infrastructure\Adapter\Ec2 online tests are not enabled');
        }
        if(!defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID') || !defined('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY')) {
            self::markTestSkipped('Constants AccessKeyId and SecretKey have to be set.');
        }

        self::$infrastructure = Factory::getAdapter(array( 
            Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Ec2', 
            Ec2::AWS_ACCESS_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), 
            Ec2::AWS_SECRET_KEY => constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'), 
            Ec2::AWS_REGION     => constant('TESTS_ZEND_SERVICE_AMAZON_EC2_ZONE')   
        )); 

        self::$httpClientAdapterSocket = new Socket();


        self::$infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter(self::$httpClientAdapterSocket);

    }
コード例 #7
0
ファイル: RackspaceOnlineTest.php プロジェクト: ruflin/zf2
    /**
     * Sets up this test case
     *
     * @return void
     */
    public static function setUpBeforeClass()
    {
        if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) {
            self::markTestSkipped('Zend\Cloud\Infrastructure\Adapter\Rackspace 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::$infrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter(array( 
            \Zend\Cloud\Infrastructure\Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend\Cloud\Infrastructure\Adapter\Rackspace', 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_USER   => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'), 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_KEY    => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'), 
            \Zend\Cloud\Infrastructure\Adapter\Rackspace::RACKSPACE_REGION => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_REGION')   
        )); 

        self::$httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket();


        self::$infrastructure->getAdapter()
                             ->getHttpClient()
                             ->setAdapter(self::$httpClientAdapterSocket);

    }
コード例 #8
0
 public function setUp()
 {
     $this->_config = $this->_getConfig();
     $this->_commonInfrastructure = \Zend\Cloud\Infrastructure\Factory::getAdapter($this->_config);
     parent::setUp();
 }