/**
  * Creates ServiceProperties object from parsed XML response.
  *
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return MicrosoftAzure\Storage\Common\Models\ServiceProperties.
  */
 public static function create($parsedResponse)
 {
     $result = new ServiceProperties();
     $result->setLogging(Logging::create($parsedResponse['Logging']));
     $result->setMetrics(Metrics::create($parsedResponse['HourMetrics']));
     return $result;
 }
 /**
  * @covers MicrosoftAzure\Storage\Common\Models\ServiceProperties::getLogging
  */
 public function testGetLogging()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $logging = Logging::create($sample['Logging']);
     $result = new ServiceProperties();
     $result->setLogging($logging);
     // Test
     $actual = $result->getLogging($logging);
     // Assert
     $this->assertEquals($logging, $actual);
 }
示例#3
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return MicrosoftAzure\Storage\Common\Models\Logging
  */
 public static function create($parsedResponse)
 {
     $result = new Logging();
     $result->setVersion($parsedResponse['Version']);
     $result->setDelete(Utilities::toBoolean($parsedResponse['Delete']));
     $result->setRead(Utilities::toBoolean($parsedResponse['Read']));
     $result->setWrite(Utilities::toBoolean($parsedResponse['Write']));
     $result->setRetentionPolicy(RetentionPolicy::create($parsedResponse['RetentionPolicy']));
     return $result;
 }
 public static function getInterestingServiceProperties()
 {
     $ret = array();
     // This is the default that comes from the server.
     array_push($ret, self::getDefaultServiceProperties());
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     $rp->setDays(10);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(true);
     $l->setRead(true);
     $l->setWrite(true);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     // The service does not accept setting days when enabled is false.
     $rp->setEnabled(false);
     $rp->setDays(null);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setRetentionPolicy($rp);
     $m->setVersion('1.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     $rp = new RetentionPolicy();
     $rp->setEnabled(true);
     // Days has to be 0 < days <= 365
     $rp->setDays(364);
     $l = new Logging();
     $l->setRetentionPolicy($rp);
     // Note: looks like only v1.0 is available now.
     // http://msdn.microsoft.com/en-us/library/windowsazure/hh360996.aspx
     $l->setVersion('1.0');
     $l->setDelete(false);
     $l->setRead(false);
     $l->setWrite(false);
     $m = new Metrics();
     $m->setVersion('1.0');
     $m->setEnabled(false);
     $m->setIncludeAPIs(null);
     $m->setRetentionPolicy($rp);
     $sp = new ServiceProperties();
     $sp->setLogging($l);
     $sp->setMetrics($m);
     array_push($ret, $sp);
     return $ret;
 }
 public function testCheckLogging()
 {
     // Check that the default values of options are reasonable
     $rp = new RetentionPolicy();
     $l = new Logging();
     $this->assertNull($l->getRetentionPolicy(), 'Default Logging->getRetentionPolicy should be null');
     $this->assertNull($l->getVersion(), 'Default Logging->getVersion should be null');
     $this->assertNull($l->getDelete(), 'Default Logging->getDelete should be null');
     $this->assertNull($l->getRead(), 'Default Logging->getRead should be false');
     $this->assertNull($l->getWrite(), 'Default Logging->getWrite should be false');
     $l->setRetentionPolicy($rp);
     $l->setVersion('2.0');
     $l->setDelete(true);
     $l->setRead(true);
     $l->setWrite(true);
     $this->assertEquals($rp, $l->getRetentionPolicy(), 'Set Logging->getRetentionPolicy');
     $this->assertEquals('2.0', $l->getVersion(), 'Set Logging->getVersion');
     $this->assertTrue($l->getDelete(), 'Set Logging->getDelete should be true');
     $this->assertTrue($l->getRead(), 'Set Logging->getRead should be true');
     $this->assertTrue($l->getWrite(), 'Set Logging->getWrite should be true');
 }
示例#6
0
 /**
  * @covers MicrosoftAzure\Storage\Common\Models\Logging::toArray
  */
 public function testToArray()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $logging = Logging::create($sample['Logging']);
     $expected = array('Version' => $sample['Logging']['Version'], 'Delete' => $sample['Logging']['Delete'], 'Read' => $sample['Logging']['Read'], 'Write' => $sample['Logging']['Write'], 'RetentionPolicy' => $logging->getRetentionPolicy()->toArray());
     // Test
     $actual = $logging->toArray();
     // Assert
     $this->assertEquals($expected, $actual);
 }