/**
  * @test
  */
 public function testToXml()
 {
     $cfg = new DistributionConfigData();
     $cfg->setAliases(array(array('cname' => 'cname-1'), new DistributionConfigAliasData('cname-2')));
     $cfg->callerReference = 'caller-reference';
     $cfg->comment = 'the-comment';
     $cfg->enabled = true;
     $cfg->priceClass = 'price-class';
     $cfg->defaultRootObject = 'default-root-object';
     $cbd = new CacheBehaviorData();
     $cbd->minTtl = 3600;
     $cbd->pathPattern = 'path-pattern';
     $cbd->targetOriginId = 'target-origin-id';
     $cbd->viewerProtocolPolicy = 'pp-1';
     $cbd->setTrustedSigners(array(array('awsAccountNumber' => 'awsAccountNumber-1'), array('awsAccountNumber' => 'awsAccountNumber-2')));
     $fc = new ForwardedValuesCookiesData();
     $fc->forward = 'whitelist';
     $fc->setWhitelistedNames(array(array('name' => 'cookie-name-1'), array('name' => 'cookie-name-2')));
     $fwd = new ForwardedValuesData();
     $fwd->queryString = true;
     $fwd->setCookies($fc);
     $cbd->setForwardedValues($fwd);
     $cfg->setCacheBehaviors(array($cbd, $cbd));
     $cfg->setDefaultCacheBehavior($cbd);
     $this->assertEquals($this->getFixtureFileContent('CloudFront/20150727/DistributionConfig1.xml'), $cfg->toXml());
     unset($cfg);
 }
Example #2
0
 /**
  * Loads ForwardedValuesCookiesData from simple xml object
  *
  * @param   \SimpleXMLElement $sxml
  * @return  ForwardedValuesCookiesData Returns ForwardedValuesCookiesData
  */
 protected function _loadForwardedValuesCookiesData(\SimpleXMLElement $sxml)
 {
     $item = null;
     if ($this->exist($sxml)) {
         $item = new ForwardedValuesCookiesData();
         $item->forward = $this->exist($sxml->Forward) ? (string) $sxml->Forward : null;
         $item->whitelistedNames = $this->_loadWhitelistedCookieNamesList($sxml->WhitelistedNames);
         $item->setCloudFront($this->cloudFront);
     }
     return $item;
 }