/** * Computes canonicalized headers for headers array. * * @param array $headers request headers. * * @see Constructing the Canonicalized Headers String section at * http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx * * @return array */ protected function computeCanonicalizedHeaders($headers) { $canonicalizedHeaders = array(); $normalizedHeaders = array(); $validPrefix = Resources::X_MS_HEADER_PREFIX; if (is_null($normalizedHeaders)) { return $canonicalizedHeaders; } foreach ($headers as $header => $value) { // Convert header to lower case. $header = strtolower($header); // Retrieve all headers for the resource that begin with x-ms-, // including the x-ms-date header. if (Utilities::startsWith($header, $validPrefix)) { // Unfold the string by replacing any breaking white space // (meaning what splits the headers, which is \r\n) with a single // space. $value = str_replace("\r\n", ' ', $value); // Trim any white space around the colon in the header. $value = ltrim($value); $header = rtrim($header); $normalizedHeaders[$header] = $value; } } // Sort the headers lexicographically by header name, in ascending order. // Note that each header may appear only once in the string. ksort($normalizedHeaders); foreach ($normalizedHeaders as $key => $value) { $canonicalizedHeaders[] = $key . ':' . $value; } return $canonicalizedHeaders; }
/** * Given array of MIME parts in raw string, this function converts them into MIME * representation. * * @param array $bodyPartContents The MIME body parts. * * @return array Returns array with two elements 'headers' and 'body' which * represents the MIME message. */ public function encodeMimeMultipart($bodyPartContents) { $count = count($bodyPartContents); $mimeType = Resources::MULTIPART_MIXED_TYPE; $batchGuid = Utilities::getGuid(); $batchId = sprintf('batch_%s', $batchGuid); $contentType1 = array('content_type' => "{$mimeType}"); $changeSetGuid = Utilities::getGuid(); $changeSetId = sprintf('changeset_%s', $changeSetGuid); $contentType2 = array('content_type' => "{$mimeType}; boundary={$changeSetId}"); $options = array('encoding' => 'binary', 'content_type' => Resources::HTTP_TYPE); $eof = "\r\n"; $result = array(); $result['body'] = Resources::EMPTY_STRING; $result['headers'] = array(); $batchBody =& $result['body']; $batchHeaders =& $result['headers']; $batchHeaders['Content-Type'] = $mimeType . "; {$eof} boundary=\"{$batchId}\""; $batchBody .= "--" . $batchId . $eof; $batchBody .= "Content-Type: {$mimeType}; boundary=\"{$changeSetId}\"" . $eof; $batchBody .= $eof; for ($i = 0; $i < count($bodyPartContents); $i++) { $batchBody .= "--" . $changeSetId . $eof; $batchBody .= "Content-Transfer-Encoding: binary" . $eof; $batchBody .= "Content-Type: " . Resources::HTTP_TYPE . $eof; $batchBody .= $eof . $bodyPartContents[$i] . $eof; } $batchBody .= "--" . $changeSetId . "--" . $eof; $batchBody .= $eof; $batchBody .= "--" . $batchId . "--" . $eof; return $result; }
/** * Creates GetBlobResult from getBlob call. * * @param array $headers The HTTP response headers. * @param string $body The response body. * @param array $metadata The blob metadata. * * @return GetBlobResult */ public static function create($headers, $body, $metadata) { $result = new GetBlobResult(); $result->setContentStream(Utilities::stringToStream($body)); $result->setProperties(BlobProperties::create($headers)); $result->setMetadata(is_null($metadata) ? array() : $metadata); return $result; }
/** * Creates SetBlobMetadataResult from response headers. * * @param array $headers response headers * * @return SetBlobMetadataResult */ public static function create($headers) { $result = new SetBlobMetadataResult(); $date = $headers[Resources::LAST_MODIFIED]; $result->setLastModified(Utilities::rfc1123ToDateTime($date)); $result->setETag($headers[Resources::ETAG]); return $result; }
/** * Creates new QueryTablesResult object * * @param array $headers The HTTP response headers * @param array $entries The table entriess * * @return \MicrosoftAzure\Storage\Table\Models\QueryTablesResult */ public static function create($headers, $entries) { $result = new QueryTablesResult(); $headers = array_change_key_case($headers); $result->setNextTableName(Utilities::tryGetValue($headers, Resources::X_MS_CONTINUATION_NEXTTABLENAME)); $result->setTables($entries); return $result; }
/** * Create InsertEntityResult object from HTTP response parts. * * @param string $body The HTTP response body. * @param array $headers The HTTP response headers. * @param IAtomReaderWriter $atomSerializer The atom reader and writer. * * @return \MicrosoftAzure\Storage\Table\Models\InsertEntityResult * * @static */ public static function create($body, $headers, $atomSerializer) { $result = new InsertEntityResult(); $entity = $atomSerializer->parseEntity($body); $entity->setETag(Utilities::tryGetValue($headers, Resources::ETAG)); $result->setEntity($entity); return $result; }
/** * Creates CreateBlobSnapshotResult object from the response of the * create Blob snapshot request. * * @param array $headers The HTTP response headers in array representation. * * @return CreateBlobSnapshotResult */ public static function create($headers) { $result = new CreateBlobSnapshotResult(); $headerWithLowerCaseKey = array_change_key_case($headers); $result->setETag($headerWithLowerCaseKey[Resources::ETAG]); $result->setLastModified(Utilities::rfc1123ToDateTime($headerWithLowerCaseKey[Resources::LAST_MODIFIED])); $result->setSnapshot($headerWithLowerCaseKey[Resources::X_MS_SNAPSHOT]); return $result; }
/** * Creates CopyBlobResult object from the response of the copy blob request. * * @param array $headers The HTTP response headers in array representation. * * @return CopyBlobResult */ public static function create($headers) { $result = new CopyBlobResult(); $result->setETag(Utilities::tryGetValueInsensitive(Resources::ETAG, $headers)); if (Utilities::arrayKeyExistsInsensitive(Resources::LAST_MODIFIED, $headers)) { $lastModified = Utilities::tryGetValueInsensitive(Resources::LAST_MODIFIED, $headers); $result->setLastModified(Utilities::rfc1123ToDateTime($lastModified)); } return $result; }
/** * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult::setLastModified * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult::getLastModified */ public function testSetLastModified() { // Setup $expected = Utilities::rfc1123ToDateTime('Sun, 25 Sep 2011 19:42:18 GMT'); $prooperties = new SetBlobPropertiesResult(); $prooperties->setLastModified($expected); // Test $prooperties->setLastModified($expected); // Assert $this->assertEquals($expected, $prooperties->getLastModified()); }
/** * Creates BatchError object. * * @param MicrosoftAzure\Storage\Common\ServiceException $error The error object. * @param array $headers The response headers. * * @return \MicrosoftAzure\Storage\Table\Models\BatchError */ public static function create($error, $headers) { Validate::isTrue($error instanceof ServiceException, Resources::INVALID_EXC_OBJ_MSG); Validate::isArray($headers, 'headers'); $result = new BatchError(); $clean = array_change_key_case($headers); $result->setError($error); $contentId = Utilities::tryGetValue($clean, Resources::CONTENT_ID); $result->setContentId(is_null($contentId) ? null : intval($contentId)); return $result; }
/** * @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult::setLastModified * @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult::getLastModified */ public function testSetLastModified() { // Setup $expected = Utilities::rfc1123ToDateTime('Sun, 25 Sep 2011 19:42:18 GMT'); $result = new ListPageBlobRangesResult(); $result->setLastModified($expected); // Test $result->setLastModified($expected); // Assert $this->assertEquals($expected, $result->getLastModified()); }
/** * Creates new QueryEntitiesResult instance. * * @param array $headers The HTTP response headers. * @param array $entities The entities. * * @return QueryEntitiesResult */ public static function create($headers, $entities) { $result = new QueryEntitiesResult(); $headers = array_change_key_case($headers); $nextPK = Utilities::tryGetValue($headers, Resources::X_MS_CONTINUATION_NEXTPARTITIONKEY); $nextRK = Utilities::tryGetValue($headers, Resources::X_MS_CONTINUATION_NEXTROWKEY); $result->setEntities($entities); $result->setNextPartitionKey($nextPK); $result->setNextRowKey($nextRK); return $result; }
/** * Computes the authorization signature for blob and queue shared key. * * @param array $headers request headers. * @param string $url reuqest url. * @param array $queryParams query variables. * @param string $httpMethod request http method. * * @see Blob and Queue Services (Shared Key Authentication) at * http://msdn.microsoft.com/en-us/library/windowsazure/dd179428.aspx * * @return string */ protected function computeSignature($headers, $url, $queryParams, $httpMethod) { $canonicalizedResource = parent::computeCanonicalizedResourceForTable($url, $queryParams); $stringToSign = array(); foreach ($this->includedHeaders as $header) { $stringToSign[] = Utilities::tryGetValue($headers, $header); } $stringToSign[] = $canonicalizedResource; $stringToSign = implode("\n", $stringToSign); return $stringToSign; }
/** * Creates SetBlobPropertiesResult from response headers. * * @param array $headers response headers * * @return SetBlobPropertiesResult */ public static function create($headers) { $result = new SetBlobPropertiesResult(); $date = $headers[Resources::LAST_MODIFIED]; $result->setLastModified(Utilities::rfc1123ToDateTime($date)); $result->setETag($headers[Resources::ETAG]); if (array_key_exists(Resources::X_MS_BLOB_SEQUENCE_NUMBER, $headers)) { $sNumber = $headers[Resources::X_MS_BLOB_SEQUENCE_NUMBER]; $result->setSequenceNumber(intval($sNumber)); } return $result; }
/** * @covers MicrosoftAzure\Storage\Common\Models\RetentionPolicy::setEnabled */ public function testSetEnabled() { // Setup $sample = TestResources::getServicePropertiesSample(); $retentionPolicy = new RetentionPolicy(); $expected = Utilities::toBoolean($sample['Logging']['RetentionPolicy']['Enabled']); // Test $retentionPolicy->setEnabled($expected); // Assert $actual = $retentionPolicy->getEnabled(); $this->assertEquals($expected, $actual); }
/** * Creates CreateBlobPagesResult object from $parsed response in array * representation * * @param array $headers HTTP response headers * * @return CreateBlobPagesResult */ public static function create($headers) { $result = new CreateBlobPagesResult(); $clean = array_change_key_case($headers); $date = $clean[Resources::LAST_MODIFIED]; $date = Utilities::rfc1123ToDateTime($date); $result->setETag($clean[Resources::ETAG]); $result->setLastModified($date); $result->setContentMD5(Utilities::tryGetValue($clean, Resources::CONTENT_MD5)); $result->setSequenceNumber(intval(Utilities::tryGetValue($clean, Resources::X_MS_BLOB_SEQUENCE_NUMBER))); return $result; }
/** * @covers MicrosoftAzure\Storage\Queue\Models\MicrosoftAzureQueueMessage::createFromPeekMessages */ public function testCreateFromPeekMessages() { // Setup $sample = TestResources::listMessagesSample(); $sample = $sample['QueueMessage']; // Test $actual = MicrosoftAzureQueueMessage::createFromPeekMessages($sample); // Assert $this->assertEquals($sample['MessageId'], $actual->getMessageId()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['InsertionTime']), $actual->getInsertionDate()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['ExpirationTime']), $actual->getExpirationDate()); $this->assertEquals(intval($sample['DequeueCount']), $actual->getDequeueCount()); $this->assertEquals($sample['MessageText'], $actual->getMessageText()); }
/** * Creates PeekMessagesResult object from parsed XML response. * * @param array $parsedResponse XML response parsed into array. * * @return MicrosoftAzure\Storage\Queue\Models\PeekMessagesResult. */ public static function create($parsedResponse) { $result = new PeekMessagesResult(); $queueMessages = array(); if (!empty($parsedResponse)) { $rawMessages = Utilities::getArray($parsedResponse['QueueMessage']); foreach ($rawMessages as $value) { $message = MicrosoftAzureQueueMessage::createFromPeekMessages($value); $queueMessages[] = $message; } } $result->setQueueMessages($queueMessages); return $result; }
/** * Parses the connection string and then validate that the parsed keys belong to * the $validSettingKeys * * @param string $connectionString The user provided connection string. * * @return array The tokenized connection string keys. * * @throws \RuntimeException */ protected static function parseAndValidateKeys($connectionString) { // Initialize the static values if they are not initialized yet. if (!static::$isInitialized) { static::init(); static::$isInitialized = true; } $tokenizedSettings = ConnectionStringParser::parseConnectionString('connectionString', $connectionString); // Assure that all given keys are valid. foreach ($tokenizedSettings as $key => $value) { if (!Utilities::inArrayInsensitive($key, static::$validSettingKeys)) { throw new \RuntimeException(sprintf(Resources::INVALID_CONNECTION_STRING_SETTING_KEY, $key, implode("\n", static::$validSettingKeys))); } } return $tokenizedSettings; }
/** * Parses the given array into signed identifiers. * * @param string $publicAccess The container public access. * @param array $parsed The parsed response into array representation. * * @return none */ public static function create($publicAccess, $parsed) { $result = new ContainerAcl(); $result->_publicAccess = $publicAccess; $result->_signedIdentifiers = array(); if (!empty($parsed) && is_array($parsed['SignedIdentifier'])) { $entries = $parsed['SignedIdentifier']; $temp = Utilities::getArray($entries); foreach ($temp as $value) { $startString = urldecode($value['AccessPolicy']['Start']); $expiryString = urldecode($value['AccessPolicy']['Expiry']); $start = Utilities::convertToDateTime($startString); $expiry = Utilities::convertToDateTime($expiryString); $permission = $value['AccessPolicy']['Permission']; $id = $value['Id']; $result->addSignedIdentifier($id, $start, $expiry, $permission); } } return $result; }
/** * @covers MicrosoftAzure\Storage\Queue\Models\PeekMessagesResult::create */ public function testCreateMultiple() { // Setup $sample = TestResources::listMessagesMultipleMessagesSample(); // Test $result = PeekMessagesResult::create($sample); // Assert $actual = $result->getQueueMessages(); $this->assertCount(2, $actual); $this->assertEquals($sample['QueueMessage'][0]['MessageId'], $actual[0]->getMessageId()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['QueueMessage'][0]['InsertionTime']), $actual[0]->getInsertionDate()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['QueueMessage'][0]['ExpirationTime']), $actual[0]->getExpirationDate()); $this->assertEquals(intval($sample['QueueMessage'][0]['DequeueCount']), $actual[0]->getDequeueCount()); $this->assertEquals($sample['QueueMessage'][0]['MessageText'], $actual[0]->getMessageText()); $this->assertEquals($sample['QueueMessage'][1]['MessageId'], $actual[1]->getMessageId()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['QueueMessage'][1]['InsertionTime']), $actual[1]->getInsertionDate()); $this->assertEquals(Utilities::rfc1123ToDateTime($sample['QueueMessage'][1]['ExpirationTime']), $actual[1]->getExpirationDate()); $this->assertEquals(intval($sample['QueueMessage'][1]['DequeueCount']), $actual[1]->getDequeueCount()); $this->assertEquals($sample['QueueMessage'][1]['MessageText'], $actual[1]->getMessageText()); }
/** * Creates BlobProperties object from $parsed response in array representation * * @param array $headers HTTP response headers * @param array $parsed parsed response in array format. * * @return ListPageBlobRangesResult */ public static function create($headers, $parsed) { $result = new ListPageBlobRangesResult(); $headers = array_change_key_case($headers); $date = $headers[Resources::LAST_MODIFIED]; $date = Utilities::rfc1123ToDateTime($date); $blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]); $rawPageRanges = array(); if (!empty($parsed['PageRange'])) { $parsed = array_change_key_case($parsed); $rawPageRanges = Utilities::getArray($parsed['pagerange']); } $result->_pageRanges = array(); foreach ($rawPageRanges as $value) { $result->_pageRanges[] = new PageRange(intval($value['Start']), intval($value['End'])); } $result->setContentLength($blobLength); $result->setETag($headers[Resources::ETAG]); $result->setLastModified($date); return $result; }
/** * Creates ListQueuesResult object from parsed XML response. * * @param array $parsedResponse XML response parsed into array. * * @return MicrosoftAzure\Storage\Queue\Models\ListQueuesResult. */ public static function create($parsedResponse) { $result = new ListQueuesResult(); $serviceEndpoint = Utilities::tryGetKeysChainValue($parsedResponse, Resources::XTAG_ATTRIBUTES, Resources::XTAG_SERVICE_ENDPOINT); $result->_accountName = Utilities::tryParseAccountNameFromUrl($serviceEndpoint); $result->_prefix = Utilities::tryGetValue($parsedResponse, Resources::QP_PREFIX); $result->_marker = Utilities::tryGetValue($parsedResponse, Resources::QP_MARKER); $result->_nextMarker = Utilities::tryGetValue($parsedResponse, Resources::QP_NEXT_MARKER); $result->_maxResults = Utilities::tryGetValue($parsedResponse, Resources::QP_MAX_RESULTS); $result->_queues = array(); $rawQueues = array(); if (!empty($parsedResponse['Queues'])) { $rawQueues = Utilities::getArray($parsedResponse['Queues']['Queue']); } foreach ($rawQueues as $value) { $queue = new Queue($value['Name'], $serviceEndpoint . $value['Name']); $metadata = Utilities::tryGetValue($value, Resources::QP_METADATA); $queue->setMetadata(is_null($metadata) ? array() : $metadata); $result->_queues[] = $queue; } return $result; }
/** * Unregisters a connection string source. * * @param string $name The source name. * * @return callable */ public static function unregisterSource($name) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); $sourceCallback = Utilities::tryGetValue(self::$_sources, $name); if (!is_null($sourceCallback)) { unset(self::$_sources[$name]); } return $sourceCallback; }
/** * @covers MicrosoftAzure\Storage\Common\Internal\Validate::isDate */ public function testIsDateWithDate() { $date = Utilities::rfc1123ToDateTime('Fri, 09 Oct 2009 21:04:30 GMT'); Validate::isDate($date); $this->assertTrue(true); }
/** * Creates ListBlobsResult object from parsed XML response. * * @param array $parsed XML response parsed into array. * * @return ListBlobsResult */ public static function create($parsed) { $result = new ListBlobsResult(); $serviceEndpoint = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ATTRIBUTES, Resources::XTAG_SERVICE_ENDPOINT); $containerName = Utilities::tryGetKeysChainValue($parsed, Resources::XTAG_ATTRIBUTES, Resources::XTAG_CONTAINER_NAME); $result->_containerName = $containerName; $result->_prefix = Utilities::tryGetValue($parsed, Resources::QP_PREFIX); $result->_marker = Utilities::tryGetValue($parsed, Resources::QP_MARKER); $result->_nextMarker = Utilities::tryGetValue($parsed, Resources::QP_NEXT_MARKER); $result->_maxResults = intval(Utilities::tryGetValue($parsed, Resources::QP_MAX_RESULTS, 0)); $result->_delimiter = Utilities::tryGetValue($parsed, Resources::QP_DELIMITER); $result->_blobs = array(); $result->_blobPrefixes = array(); $rawBlobs = array(); $rawBlobPrefixes = array(); if (is_array($parsed['Blobs']) && array_key_exists('Blob', $parsed['Blobs'])) { $rawBlobs = Utilities::getArray($parsed['Blobs']['Blob']); } foreach ($rawBlobs as $value) { $blob = new Blob(); $blob->setName($value['Name']); $blob->setUrl($serviceEndpoint . $containerName . '/' . $value['Name']); $blob->setSnapshot(Utilities::tryGetValue($value, 'Snapshot')); $blob->setProperties(BlobProperties::create(Utilities::tryGetValue($value, 'Properties'))); $blob->setMetadata(Utilities::tryGetValue($value, Resources::QP_METADATA, array())); $result->_blobs[] = $blob; } if (is_array($parsed['Blobs']) && array_key_exists('BlobPrefix', $parsed['Blobs'])) { $rawBlobPrefixes = Utilities::getArray($parsed['Blobs']['BlobPrefix']); } foreach ($rawBlobPrefixes as $value) { $blobPrefix = new BlobPrefix(); $blobPrefix->setName($value['Name']); $result->_blobPrefixes[] = $blobPrefix; } return $result; }
/** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlob * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobMetadata * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobMetadata */ private function setBlobMetadataWorker($container, $options, $metadata) { $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); // Make sure there is something to test $createBlockBlobResult = $this->restProxy->createBlockBlob($container, $blob, ""); if (!is_null($options)) { BlobServiceFunctionalTestData::fixETagAccessCondition($options->getAccessCondition(), $createBlockBlobResult->getETag()); } $firstkey = ''; if (!is_null($metadata) && count($metadata) > 0) { $firstkey = array_keys($metadata); $firstkey = $firstkey[0]; } try { // And put in some properties $res = is_null($options) ? $this->restProxy->setBlobMetadata($container, $blob, $metadata) : $this->restProxy->setBlobMetadata($container, $blob, $metadata, $options); if (is_null($options)) { $options = new SetBlobMetadataOptions(); } if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertTrue(false, 'Expect negative timeouts in $options to throw'); } if (!BlobServiceFunctionalTestData::passTemporalAccessCondition($options->getAccessCondition())) { $this->assertTrue(false, 'Failing access condition should throw'); } if (!BlobServiceFunctionalTestData::passTemporalAccessCondition($options->getAccessCondition())) { $this->assertTrue(false, 'Expect failing access condition to throw'); } if (Utilities::startsWith($firstkey, '<')) { $this->assertTrue(false, 'Should get HTTP request error if the metadata is invalid'); } $this->verifySetBlobMetadataWorker($res); $res2 = $this->restProxy->getBlobMetadata($container, $blob); $this->verifyGetBlobMetadataWorker($res2, $metadata); } catch (ServiceException $e) { if (Utilities::startsWith($firstkey, '<')) { $this->assertEquals(TestResources::STATUS_BAD_REQUEST, $e->getCode(), 'getCode'); } else { if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertEquals(TestResources::STATUS_INTERNAL_SERVER_ERROR, $e->getCode(), 'bad timeout: getCode'); } else { if (!BlobServiceFunctionalTestData::passTemporalAccessCondition($options->getAccessCondition())) { $this->assertEquals(TestResources::STATUS_PRECONDITION_FAILED, $e->getCode(), 'bad temporal access condition: getCode'); } else { if (!BlobServiceFunctionalTestData::passETagAccessCondition($options->getAccessCondition())) { $this->assertEquals(TestResources::STATUS_PRECONDITION_FAILED, $e->getCode(), 'bad etag access condition: getCode'); } else { throw $e; } } } } } // Clean up. $this->restProxy->deleteBlob($container, $blob); }
/** * Gets metadata array by parsing them from given headers. * * @param array $headers HTTP headers containing metadata elements. * * @return array. */ public function getMetadataArray($headers) { $metadata = array(); foreach ($headers as $key => $value) { $isMetadataHeader = Utilities::startsWith(strtolower($key), Resources::X_MS_META_HEADER_PREFIX); if ($isMetadataHeader) { // Metadata name is case-presrved and case insensitive $MetadataName = str_ireplace(Resources::X_MS_META_HEADER_PREFIX, Resources::EMPTY_STRING, $key); $metadata[$MetadataName] = $value; } } return $metadata; }
/** * @covers MicrosoftAzure\Storage\Blob\Models\Container::getProperties */ public function testGetProperties() { // Setup $date = Utilities::rfc1123ToDateTime('Wed, 12 Aug 2009 20:39:39 GMT'); $container = new Container(); $expected = new ContainerProperties(); $expected->setETag('0x8CACB9BD7C1EEEC'); $expected->setLastModified($date); $container->setProperties($expected); // Test $actual = $container->getProperties(); // Assert $this->assertEquals($expected, $actual); }
/** * Converts this object to array with XML tags * * @return array. */ public function toArray() { $array = array('Enabled' => Utilities::booleanToString($this->_enabled)); if (isset($this->_days)) { $array['Days'] = strval($this->_days); } return $array; }