/** 
  * @covers WindowsAzure\Common\Internal\Atom\Feed::parseXml
  */
 public function testFeedParseXmlAllProperties()
 {
     // Setup
     $expected = new Feed();
     $entry = array();
     $entry[] = new Entry();
     $category = array();
     $categoryInstance = new Category();
     $categoryInstance->setScheme('testCategory');
     $category[] = $categoryInstance;
     $contributor = array();
     $contributorItem = new Person();
     $contributorItem->setName('testContributor');
     $contributor[] = $contributorItem;
     $generator = new Generator();
     $generator->setText('testGenerator');
     $icon = 'testIcon';
     $id = 'testId';
     $link = array();
     $atomLink = new AtomLink();
     $atomLink->setHref('testLink');
     $link[] = $atomLink;
     $logo = 'testLogo';
     $rights = 'testRights';
     $subtitle = 'testSubtitle';
     $title = 'testTitle';
     $updated = \DateTime::createFromFormat(\DateTime::ATOM, '2011-09-29T23:50:26+00:00');
     $expected->setEntry($entry);
     $expected->setCategory($category);
     $expected->setContributor($contributor);
     $expected->setGenerator($generator);
     $expected->setIcon($icon);
     $expected->setId($id);
     $expected->setLink($link);
     $expected->setLogo($logo);
     $expected->setRights($rights);
     $expected->setSubtitle($subtitle);
     $expected->setTitle($title);
     $expected->setUpdated($updated);
     $actual = new Feed();
     $xml = '
     <feed xmlns="http://www.w3.org/2005/Atom">
         <entry/>
         <content/>
         <category scheme="testCategory"/>
         <contributor>testContributor</contributor>
         <generator>testGenerator</generator>
         <icon>testIcon</icon>
         <id>testId</id>
         <link href="testLink"/>
         <logo>testLogo</logo>
         <rights>testRights</rights>
         <subtitle>testSubtitle</subtitle>
         <title>testTitle</title>
         <updated>2011-09-29T23:50:26+00:00</updated>
     </feed>';
     // Test
     $actual->parseXml($xml);
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /** 
  * @covers WindowsAzure\Common\Internal\Atom\AtomLink::writeXml
  */
 public function testWriteXmlSuccess()
 {
     // Setup
     $expected = '<atom:link href="http://www.contonso.com" xmlns:atom="http://www.w3.org/2005/Atom"/>';
     $atomLink = new AtomLink();
     $atomLink->setHref('http://www.contonso.com');
     // Test
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $atomLink->writeXml($xmlWriter);
     $actual = $xmlWriter->outputMemory();
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /**
  * Create new IngestManifestAsset
  *
  * @param Models\IngestManifestAsset $ingestManifestAsset An IngestManifestAsset
  * data
  *
  * @param Models\Asset               $asset               An Asset data to be
  * linked with IngestManifestAsset
  *
  * @return WindowsAzure\MediaServices\Models\IngestManifestAsset
  */
 public function createIngestManifestAsset($ingestManifestAsset, $asset)
 {
     Validate::isA($ingestManifestAsset, 'WindowsAzure\\Mediaservices\\Models\\IngestManifestAsset', 'ingestManifestAsset');
     Validate::isA($asset, 'WindowsAzure\\Mediaservices\\Models\\Asset', 'asset');
     $href = urlencode($asset->getId());
     $atomLink = new AtomLink();
     $atomLink->setHref($this->getUri() . "Assets('{$href}')");
     $atomLink->setType(Resources::ATOM_ENTRY_CONTENT_TYPE);
     $atomLink->setTitle('Asset');
     $atomLink->setRel(Resources::MEDIA_SERVICES_ASSET_REL);
     return IngestManifestAsset::createFromOptions($this->_createEntity($ingestManifestAsset, 'IngestManifestAssets', array($atomLink)));
 }
示例#4
0
 /**
  * Create a job HTTP call context.
  *
  * @param WindowsAzure\MediaServices\Models\Job $job         Job data
  * @param array                                 $inputAssets Input assets list
  *
  * @return WindowsAzure\Common\Internal\Http\HttpCallContext
  */
 private function _getCreateEmptyJobContext($job, $inputAssets)
 {
     Validate::isA($job, 'WindowsAzure\\MediaServices\\Models\\Job', 'job');
     Validate::isArray($inputAssets, 'inputAssets');
     $atomLinks = array();
     foreach ($inputAssets as $inputAsset) {
         Validate::isA($inputAsset, 'WindowsAzure\\MediaServices\\Models\\Asset', 'inputAssets');
         $href = urlencode($inputAsset->getId());
         $atomLink = new AtomLink();
         $atomLink->setHref($this->getUri() . "Assets('{$href}')");
         $atomLink->setType(Resources::ATOM_FEED_CONTENT_TYPE);
         $atomLink->setTitle('InputAssets');
         $atomLink->setRel(Resources::MEDIA_SERVICES_INPUT_ASSETS_REL);
         $atomLinks[] = $atomLink;
     }
     $result = new HttpCallContext();
     $result->setMethod(Resources::HTTP_POST);
     $result->setHeaders($this->_batchHeaders);
     $result->setUri($this->getUri());
     $result->setPath('/Jobs');
     $result->setBody($this->wrapAtomEntry($job, $atomLinks));
     $result->addStatusCode(Resources::STATUS_CREATED);
     return $result;
 }