Ejemplo n.º 1
0
 /**
  * Creates ServiceProperties object from parsed XML response.
  *
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\ServiceProperties.
  */
 public static function create($parsedResponse)
 {
     $result = new ServiceProperties();
     $result->setLogging(Logging::create($parsedResponse['Logging']));
     $result->setMetrics(Metrics::create($parsedResponse['Metrics']));
     return $result;
 }
 public function testCheckMetrics()
 {
     $rp = new RetentionPolicy();
     $m = new Metrics();
     $this->assertNull($m->getRetentionPolicy(), 'Default Metrics->getRetentionPolicy should be null');
     $this->assertNull($m->getVersion(), 'Default Metrics->getVersion should be null');
     $this->assertNull($m->getEnabled(), 'Default Metrics->getEnabled should be false');
     $this->assertNull($m->getIncludeAPIs(), 'Default Metrics->getIncludeAPIs should be null');
     $m->setRetentionPolicy($rp);
     $m->setVersion('2.0');
     $m->setEnabled(true);
     $m->setIncludeAPIs(true);
     $this->assertEquals($rp, $m->getRetentionPolicy(), 'Set Metrics->getRetentionPolicy');
     $this->assertEquals('2.0', $m->getVersion(), 'Set Metrics->getVersion');
     $this->assertTrue($m->getEnabled(), 'Set Metrics->getEnabled should be true');
     $this->assertTrue($m->getIncludeAPIs(), 'Set Metrics->getIncludeAPIs should be true');
 }
Ejemplo n.º 3
0
 /**
  * Creates object from $parsedResponse.
  * 
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Common\Models\Metrics
  */
 public static function create($parsedResponse)
 {
     $result = new Metrics();
     $result->setVersion($parsedResponse['Version']);
     $result->setEnabled(Utilities::toBoolean($parsedResponse['Enabled']));
     if ($result->getEnabled()) {
         $result->setIncludeAPIs(Utilities::toBoolean($parsedResponse['IncludeAPIs']));
     }
     $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;
 }
Ejemplo n.º 5
0
 /**
  * @covers WindowsAzure\Common\Models\Metrics::toArray
  */
 public function testToArrayWithNotEnabled()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $sample['Metrics']['Enabled'] = 'false';
     $metrics = Metrics::create($sample['Metrics']);
     $expected = array('Version' => $sample['Metrics']['Version'], 'Enabled' => $sample['Metrics']['Enabled'], 'RetentionPolicy' => $metrics->getRetentionPolicy()->toArray());
     // Test
     $actual = $metrics->toArray();
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /**
  * @covers WindowsAzure\Common\Models\ServiceProperties::getMetrics
  */
 public function testGetMetrics()
 {
     // Setup
     $sample = TestResources::getServicePropertiesSample();
     $metrics = Metrics::create($sample['Metrics']);
     $result = new ServiceProperties();
     $result->setMetrics($metrics);
     // Test
     $actual = $result->getMetrics($metrics);
     // Assert
     $this->assertEquals($metrics, $actual);
 }