/** * @covers WindowsAzure\MediaServices\Templates\PlayReadyLicenseResponseTemplate::getResponseCustomData * @covers WindowsAzure\MediaServices\Templates\PlayReadyLicenseResponseTemplate::setResponseCustomData */ public function testGetSetResponseCustomData() { // Setup $entity = new PlayReadyLicenseResponseTemplate(); $payload = "custom data"; // Test $entity->setResponseCustomData($payload); $result = $entity->getResponseCustomData(); // Assert $this->assertEquals($payload, $result); }
/** * Deserialize a PlayReadyLicenseResponseTemplate xml into a PlayReadyLicenseResponseTemplate object. * * @param string $options Array containing values for object properties * * @return PlayReadyLicenseResponseTemplate */ public static function deserialize($template) { $xml = simplexml_load_string($template); $result = new PlayReadyLicenseResponseTemplate(); // Validation if ($xml->getName() !== 'PlayReadyLicenseResponseTemplate') { throw new \RuntimeException("This is not a PlayReadyLicenseResponseTemplate, it is a '{$xml->getName()}'"); } if (!isset($xml->LicenseTemplates)) { throw new \RuntimeException("The PlayReadyLicenseResponseTemplate must contains an 'LicenseTemplates' element"); } // decoding $result->setLicenseTemplates(self::deserializeLicenseTemplates($xml->LicenseTemplates)); if (isset($xml->ResponseCustomData)) { $result->setResponseCustomData((string) $xml->ResponseCustomData); } self::ValidateLicenseResponseTemplate($result); return $result; }
private function getPlayReadyTemplate() { $template = new PlayReadyLicenseResponseTemplate(); $template->setResponseCustomData('test custom data'); $licenseTemplate = new PlayReadyLicenseTemplate(); $template->setLicenseTemplates(array($licenseTemplate)); $licenseTemplate->setLicenseType(PlayReadyLicenseType::PERSISTENT); $licenseTemplate->setBeginDate(new \DateTime('now')); $licenseTemplate->setRelativeExpirationDate(new \DateInterval('PT6H')); $licenseTemplate->setContentKey(new ContentEncryptionKeyFromHeader()); $playRight = new PlayReadyPlayRight(); $licenseTemplate->setPlayRight($playRight); $playRight->setAgcAndColorStripeRestriction(new AgcAndColorStripeRestriction(1)); $playRight->setAllowPassingVideoContentToUnknownOutput(UnknownOutputPassingOption::ALLOWED); $playRight->setAnalogVideoOpl(100); $playRight->setCompressedDigitalAudioOpl(300); $playRight->setCompressedDigitalVideoOpl(400); $playRight->setExplicitAnalogTelevisionOutputRestriction(new ExplicitAnalogTelevisionRestriction(0, true)); $playRight->setImageConstraintForAnalogComponentVideoRestriction(true); $playRight->setImageConstraintForAnalogComputerMonitorRestriction(true); $playRight->setScmsRestriction(new ScmsRestriction(2)); $playRight->setUncompressedDigitalAudioOpl(250); $playRight->setUncompressedDigitalVideoOpl(270); return $template; }
/** * @covers \WindowsAzure\MediaServices\Templates\MediaServicesLicenseTemplateSerializer::serialize * @covers \WindowsAzure\MediaServices\Templates\MediaServicesLicenseTemplateSerializer::deserialize */ public function testRoundTripTest() { $template = new PlayReadyLicenseResponseTemplate(); $template->setResponseCustomData('test custom data'); $licenseTemplate = new PlayReadyLicenseTemplate(); $template->setLicenseTemplates(array($licenseTemplate)); $licenseTemplate->setLicenseType(PlayReadyLicenseType::PERSISTENT); $licenseTemplate->setBeginDate(new \DateTime('now')); $licenseTemplate->setRelativeExpirationDate(new \DateInterval('PT6H')); $licenseTemplate->setContentKey(new ContentEncryptionKeyFromKeyIdentifier('test custom id')); $playRight = new PlayReadyPlayRight(); $licenseTemplate->setPlayRight($playRight); $playRight->setAgcAndColorStripeRestriction(new AgcAndColorStripeRestriction(1)); $playRight->setAllowPassingVideoContentToUnknownOutput(UnknownOutputPassingOption::ALLOWED); $playRight->setAnalogVideoOpl(100); $playRight->setCompressedDigitalAudioOpl(300); $playRight->setCompressedDigitalVideoOpl(400); $playRight->setExplicitAnalogTelevisionOutputRestriction(new ExplicitAnalogTelevisionRestriction(0, true)); $playRight->setImageConstraintForAnalogComponentVideoRestriction(true); $playRight->setImageConstraintForAnalogComputerMonitorRestriction(true); $playRight->setScmsRestriction(new ScmsRestriction(2)); $playRight->setUncompressedDigitalAudioOpl(250); $playRight->setUncompressedDigitalVideoOpl(270); $result = MediaServicesLicenseTemplateSerializer::serialize($template); $playreadyLicense = MediaServicesLicenseTemplateSerializer::deserialize($result); $this->assertEqualsLicenseResponseTemplate($template, $playreadyLicense); }