/** * Get list of tasks. * * @return array of Models\Task */ public function getTaskList() { $propertyList = $this->_getEntityList('Tasks'); $result = array(); foreach ($propertyList as $properties) { $result[] = Task::createFromOptions($properties); } return $result; }
/** * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::serialize * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::_serializeRecursive */ public function testSerializeCollection() { // Setup $taskBodyKey = 'TaskBody'; $taskBody = 'TaskBody'; $optionsKey = 'Options'; $options = TaskOptions::NONE; $mediaProcessorIdKey = 'MediaProcessorId'; $mediaProcessorId = 'MediaProcessorId'; $errorKey = 'ErrorDetails'; $errorCodeKey = 'Code'; $errorCode = 1; $errorMessageKey = 'Message'; $errorMessage = 'Error message'; $error = array(array($errorCodeKey => $errorCode, $errorMessageKey => $errorMessage), array($errorCodeKey => $errorCode, $errorMessageKey => $errorMessage)); $objArray = array($taskBodyKey => $taskBody, $optionsKey => $options, $mediaProcessorIdKey => $mediaProcessorId, $errorKey => $error); $obj = Task::createFromOptions($objArray); $expected = ' <meta:properties xmlns:meta="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <data:' . $taskBodyKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $taskBody . '</data:' . $taskBodyKey . '> <data:' . $mediaProcessorIdKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $mediaProcessorId . '</data:' . $mediaProcessorIdKey . '> <data:' . $errorKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:element xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:' . $errorMessageKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorMessage . '</data:' . $errorMessageKey . '> <data:' . $errorCodeKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorCode . '</data:' . $errorCodeKey . '> </data:element> <data:element xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:' . $errorMessageKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorMessage . '</data:' . $errorMessageKey . '> <data:' . $errorCodeKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorCode . '</data:' . $errorCodeKey . '> </data:element> </data:' . $errorKey . '> </meta:properties> '; // Test $result = ContentPropertiesSerializer::serialize($obj); // Assert $this->assertXmlStringEqualsXmlString($expected, $result); }
/** * @covers WindowsAzure\MediaServices\Models\Task::getHistoricalEvents */ public function testGetHistoricalEvents() { // Setup $historicalEvent = array('Code' => 404, 'Message' => 'Required task not found', 'TimeStamp' => '2013-12-10'); $options = array('MediaProcessorId' => 'uy47ytu', 'TaskBody' => 'body of the task', 'Options' => 42, 'HistoricalEvents' => array($historicalEvent)); $task = Task::createFromOptions($options); $date = new \Datetime($historicalEvent['TimeStamp']); // Test $result = $task->getHistoricalEvents(); // Assert $this->assertEquals($historicalEvent['Code'], $result[0]->getCode()); $this->assertEquals($historicalEvent['Message'], $result[0]->getMessage()); $this->assertEquals($date->getTimestamp(), $result[0]->getTimeStamp()->getTimestamp()); }