/** * @covers WindowsAzure\MediaServices\Models\AssetDeliveryPolicy::createFromOptions * @covers WindowsAzure\MediaServices\Models\AssetDeliveryPolicy::fromArray * @covers WindowsAzure\MediaServices\Models\AssetDeliveryPolicy::__construct */ public function testCreateFromOptions() { // Setup $assetDeliveryPolicyTestId = 'AssetDeliveryPolicyTest-12563'; $options = array('Id' => $assetDeliveryPolicyTestId, 'Name' => 'testNameForAssetDeliveryPolicyTest', 'AssetDeliveryProtocol' => AssetDeliveryProtocol::SMOOTH_STREAMING, 'AssetDeliveryPolicyType' => AssetDeliveryPolicyType::DYNAMIC_COMMON_ENCRYPTION, 'AssetDeliveryConfiguration' => '<root>sample configuration</root>', 'Created' => '1975-12-14', 'LastModified' => '2015-12-14'); $created = new \Datetime($options['Created']); $modified = new \Datetime($options['LastModified']); // Test $assetDeliveryPolicy = AssetDeliveryPolicy::createFromOptions($options); // Assert $this->assertEquals($assetDeliveryPolicyTestId, $assetDeliveryPolicy->getId()); $this->assertEquals($options['Name'], $assetDeliveryPolicy->getName()); $this->assertEquals($options['AssetDeliveryProtocol'], $assetDeliveryPolicy->getAssetDeliveryProtocol()); $this->assertEquals($options['AssetDeliveryPolicyType'], $assetDeliveryPolicy->getAssetDeliveryPolicyType()); $this->assertEquals($options['AssetDeliveryConfiguration'], $assetDeliveryPolicy->getAssetDeliveryConfiguration()); $this->assertEquals($created, $assetDeliveryPolicy->getCreated()); $this->assertEquals($modified, $assetDeliveryPolicy->getLastModified()); }
/** * Get AssetDeliveryPolicy list linked to an Asset * * @param \WindowsAzure\MediaServices\Models\Asset|string $asset Asset data or * Asset Id to retrieve the linked delivery policies. * * @return array */ public function getAssetLinkedDeliveryPolicy($asset) { $assetId = Utilities::getEntityId($asset, 'WindowsAzure\\MediaServices\\Models\\Asset'); $propertyList = $this->_getEntityList("Assets('{$assetId}')/DeliveryPolicies"); $result = array(); foreach ($propertyList as $properties) { $result[] = AssetDeliveryPolicy::createFromOptions($properties); } return $result; }