Ejemplo n.º 1
0
 /**
  * @depends testCreatesOrigins
  */
 public function testCreatesDistribution()
 {
     if (!self::$originId) {
         $this->fail('No originId was set');
     }
     self::log("Creating a distribution");
     $result = $this->client->createDistribution(array('Aliases' => array('Quantity' => 0), 'CacheBehaviors' => array('Quantity' => 0), 'Comment' => 'Testing... 123', 'Enabled' => true, 'CallerReference' => 'BazBar-' . time(), 'DefaultCacheBehavior' => array('MinTTL' => 3600, 'ViewerProtocolPolicy' => 'allow-all', 'TargetOriginId' => self::$originId, 'TrustedSigners' => array('Enabled' => true, 'Quantity' => 1, 'Items' => array('self')), 'ForwardedValues' => array('QueryString' => false)), 'DefaultRootObject' => 'foo.txt', 'Logging' => array('Enabled' => false, 'Bucket' => '', 'Prefix' => ''), 'Origins' => array('Quantity' => 1, 'Items' => array(array('Id' => self::$originId, 'DomainName' => self::$bucketName . '.s3.amazonaws.com', 'S3OriginConfig' => array('OriginAccessIdentity' => 'origin-access-identity/cloudfront/' . self::$originId))))));
     $this->assertInstanceOf('Guzzle\\Service\\Resource\\Model', $result);
     $result = $result->toArray();
     $this->assertArrayHasKey('Id', $result);
     self::$distributionId = $result['Id'];
     $this->assertArrayHasKey('Status', $result);
     $this->assertArrayHasKey('Location', $result);
     self::$distributionUrl = $result['DomainName'];
     $this->assertArrayHasKey('ETag', $result);
     $this->assertEquals(1, $result['DistributionConfig']['Origins']['Quantity']);
     $this->assertArrayHasKey(0, $result['DistributionConfig']['Origins']['Items']);
     $this->assertEquals(self::$bucketName . '.s3.amazonaws.com', $result['DistributionConfig']['Origins']['Items'][0]['DomainName']);
     $id = $result['Id'];
     $result = $this->client->listDistributions();
     $this->assertInstanceOf('Guzzle\\Service\\Resource\\Model', $result);
     $result = $result->toArray();
     $this->assertGreaterThan(0, $result['Quantity']);
     $found = false;
     foreach ($result['Items'] as $item) {
         if ($item['Id'] == $id) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found);
 }