From 5a6b2ae8685cf53a74d04559f320cbd098aa7cd7 Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Mon, 26 Jun 2017 10:27:48 +0800 Subject: [PATCH 1/7] Upgrading REST API version to 2016-05-31, and deprecated ATOM support. --- BreakingChanges.md | 5 +++++ ChangeLog.md | 8 ++++++++ src/Common/Internal/Resources.php | 9 +++------ src/Table/TableRestProxy.php | 20 ++++++++++++++++++- .../SharedKeyAuthSchemeTest.php | 6 ++++-- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/BreakingChanges.md b/BreakingChanges.md index aba06dd..83c7160 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -1,3 +1,8 @@ +Tracking Breaking changes in 0.17.0 + +Table +* Deprecated ATOM support for Table service. + Tracking Breaking changes in 0.16.0 All diff --git a/ChangeLog.md b/ChangeLog.md index 999c731..d97651c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,11 @@ +2017.07 - version 0.17.0 + +All +* REST API version upgraded to 2016-05-31. + +Table +* Deprecated ATOM support for Table service. + 2017.06 - version 0.16.0 All diff --git a/src/Common/Internal/Resources.php b/src/Common/Internal/Resources.php index 5c78c42..d04ac9c 100644 --- a/src/Common/Internal/Resources.php +++ b/src/Common/Internal/Resources.php @@ -294,13 +294,11 @@ class Resources const DEAFULT_RETRY_INTERVAL = 1000;//Milliseconds // Header values - const SDK_VERSION = '0.16.0'; - const STORAGE_API_LATEST_VERSION = '2015-04-05'; + const SDK_VERSION = '0.17.0'; + const STORAGE_API_LATEST_VERSION = '2016-05-31'; const DATA_SERVICE_VERSION_VALUE = '3.0'; const MAX_DATA_SERVICE_VERSION_VALUE = '3.0;NetFx'; - const ACCEPT_HEADER_VALUE = 'application/atom+xml,application/xml'; - const ATOM_ENTRY_CONTENT_TYPE = 'application/atom+xml;type=entry;charset=utf-8'; - const ATOM_FEED_CONTENT_TYPE = 'application/atom+xml;type=feed;charset=utf-8'; + const ACCEPT_HEADER_VALUE = 'application/json'; const JSON_FULL_METADATA_CONTENT_TYPE = 'application/json;odata=fullmetadata'; const JSON_MINIMAL_METADATA_CONTENT_TYPE = 'application/json;odata=minimalmetadata'; const JSON_NO_METADATA_CONTENT_TYPE = 'application/json;odata=nometadata'; @@ -365,7 +363,6 @@ class Resources const XML_CONTENT_TYPE = 'application/xml'; const JSON_CONTENT_TYPE = 'application/json'; const BINARY_FILE_TYPE = 'application/octet-stream'; - const XML_ATOM_CONTENT_TYPE = 'application/atom+xml'; const HTTP_TYPE = 'application/http'; const MULTIPART_MIXED_TYPE = 'multipart/mixed'; diff --git a/src/Table/TableRestProxy.php b/src/Table/TableRestProxy.php index b6a0e56..7eee8ca 100644 --- a/src/Table/TableRestProxy.php +++ b/src/Table/TableRestProxy.php @@ -311,6 +311,12 @@ class TableRestProxy extends ServiceRestProxy implements ITable $ETag ? $etagObj : Resources::ASTERISK ); + $this->addOptionalHeader( + $headers, + Resources::ACCEPT_HEADER, + Resources::JSON_CONTENT_TYPE + ); + $options->setLocationMode(LocationMode::PRIMARY_ONLY); $context = new HttpCallContext(); @@ -949,7 +955,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179387.aspx */ - public function deleteTable($table, TableServiceOptions$options = null) + public function deleteTable($table, TableServiceOptions $options = null) { $this->deleteTableAsync($table, $options)->wait(); } @@ -1618,6 +1624,12 @@ class TableRestProxy extends ServiceRestProxy implements ITable 'acl' ); + $this->addOptionalHeader( + $headers, + Resources::ACCEPT_HEADER, + Resources::XML_CONTENT_TYPE + ); + $dataSerializer = $this->dataSerializer; $promise = $this->sendAsync( @@ -1692,6 +1704,12 @@ class TableRestProxy extends ServiceRestProxy implements ITable 'acl' ); + $this->addOptionalHeader( + $headers, + Resources::ACCEPT_HEADER, + Resources::XML_CONTENT_TYPE + ); + $options->setLocationMode(LocationMode::PRIMARY_ONLY); return $this->sendAsync( diff --git a/tests/unit/Common/Internal/Authentication/SharedKeyAuthSchemeTest.php b/tests/unit/Common/Internal/Authentication/SharedKeyAuthSchemeTest.php index b3dcbe5..0715419 100644 --- a/tests/unit/Common/Internal/Authentication/SharedKeyAuthSchemeTest.php +++ b/tests/unit/Common/Internal/Authentication/SharedKeyAuthSchemeTest.php @@ -101,13 +101,15 @@ class SharedKeyAuthSchemeTest extends \PHPUnit_Framework_TestCase $headers = array(Resources::X_MS_VERSION => $apiVersion, Resources::X_MS_DATE => $date1); $queryParams = array(Resources::QP_COMP => 'list'); $httpMethod = 'GET'; - $expected = 'SharedKey ' . $accountName . ':YDjZ61Lqt6HeMx+vv5QzFjW1juW7XEECVXJ4V9/pFgA='; + $expected = 'SharedKey ' . $accountName; $mock = new SharedKeyAuthSchemeMock($accountName, $accountKey); $actual = $mock->getAuthorizationHeader($headers, $url, $queryParams, $httpMethod); - $this->assertEquals($expected, $actual); + $this->assertTrue( + substr($actual, 0, \strlen($expected)) == $expected + ); } /** From ef4f812dde71a62f643b0170cfb026842874846d Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Mon, 26 Jun 2017 17:28:42 +0800 Subject: [PATCH 2/7] Changed the name of the function Validator::isString to Validator::canCastAsString to avoid mis-use. Also added test cases to list NULL container/share. --- src/Blob/BlobRestProxy.php | 101 +++++++++--------- src/Blob/Models/BlobContinuationToken.php | 2 +- src/Blob/Models/BlockList.php | 2 +- src/Blob/Models/CreateBlobPagesResult.php | 2 +- src/Blob/Models/CreateContainerOptions.php | 2 +- src/Blob/Models/ListBlobsOptions.php | 4 +- src/Blob/Models/ListContainersOptions.php | 4 +- src/Blob/Models/ListPageBlobRangesResult.php | 2 +- src/Blob/Models/SetBlobMetadataResult.php | 2 +- src/Blob/Models/SetBlobPropertiesResult.php | 2 +- src/Common/CloudConfigurationManager.php | 6 +- src/Common/Internal/ACLBase.php | 6 +- .../Internal/ConnectionStringParser.php | 4 +- .../Internal/ConnectionStringSource.php | 2 +- src/Common/Internal/Http/HttpCallContext.php | 26 ++--- src/Common/Internal/RestProxy.php | 8 +- .../Internal/Serialization/JsonSerializer.php | 4 +- .../Internal/Serialization/XmlSerializer.php | 2 +- src/Common/Internal/Utilities.php | 8 +- src/Common/Internal/Validate.php | 10 +- src/Common/Models/AccessPolicy.php | 2 +- src/Common/Models/ContinuationToken.php | 2 +- src/Common/SharedAccessSignatureHelper.php | 52 ++++----- src/File/FileRestProxy.php | 93 ++++++++-------- src/File/Models/CopyFileResult.php | 6 +- src/File/Models/FileContinuationToken.php | 2 +- src/File/Models/FileServiceOptions.php | 2 +- .../Models/ListDirectoriesAndFilesOptions.php | 2 +- src/File/Models/ListFileRangesResult.php | 2 +- src/File/Models/ListSharesOptions.php | 4 +- src/Queue/Models/ListQueuesOptions.php | 4 +- src/Queue/Models/QueueContinuationToken.php | 2 +- src/Queue/Models/UpdateMessageResult.php | 2 +- src/Queue/QueueRestProxy.php | 36 +++---- src/Table/Models/BatchOperations.php | 12 +-- src/Table/Models/Entity.php | 2 +- src/Table/Models/TableContinuationToken.php | 6 +- src/Table/TableRestProxy.php | 20 ++-- tests/unit/Blob/BlobRestProxyTest.php | 14 ++- tests/unit/Common/Internal/ValidateTest.php | 8 +- tests/unit/File/FileRestProxyTest.php | 10 ++ 41 files changed, 252 insertions(+), 230 deletions(-) diff --git a/src/Blob/BlobRestProxy.php b/src/Blob/BlobRestProxy.php index ebe73e9..2487120 100644 --- a/src/Blob/BlobRestProxy.php +++ b/src/Blob/BlobRestProxy.php @@ -213,7 +213,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Models\BlobServiceOptions $options = null, $operation = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); $method = Resources::HTTP_GET; $headers = array(); @@ -408,8 +408,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Models\BlobServiceOptions $options, Models\AccessCondition $accessCondition = null ) { - Validate::isString($blob, 'blob'); - Validate::isString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); $method = Resources::HTTP_PUT; @@ -496,10 +496,10 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, CreateBlobPagesOptions $options = null ) { - Validate::isString($blob, 'blob'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); - Validate::isString($container, 'container'); - Validate::isString($content, 'content'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($content, 'content'); Validate::isTrue( $range instanceof Range, sprintf( @@ -685,7 +685,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\CreateContainerOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); $method = Resources::HTTP_PUT; @@ -749,7 +749,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); $method = Resources::HTTP_DELETE; @@ -894,7 +894,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); $method = Resources::HTTP_GET; $headers = array(); @@ -1001,7 +1001,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Models\ContainerACL $acl, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($acl, 'acl'); $method = Resources::HTTP_PUT; @@ -1094,7 +1094,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob array $metadata, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Utilities::validateMetadata($metadata); $method = Resources::HTTP_PUT; @@ -1172,7 +1172,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\ListBlobsOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::notNull($container, 'container'); + Validate::canCastAsString($container, 'container'); $method = Resources::HTTP_GET; $headers = array(); @@ -1311,8 +1312,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $length, Models\CreateBlobOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); Validate::isInteger($length, 'length'); Validate::notNull($length, 'length'); @@ -1404,9 +1405,9 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\CreateBlobOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_PUT; @@ -1654,8 +1655,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlobOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); Validate::isTrue( $options == null || @@ -1725,8 +1726,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlobOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); if (is_null($options)) { $options = new CreateBlobOptions(); @@ -1840,10 +1841,10 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlobOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); if (is_null($options)) { @@ -2140,10 +2141,10 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\CreateBlobBlockOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); - Validate::isString($blockId, 'blockId'); + Validate::canCastAsString($blockId, 'blockId'); Validate::notNullOrEmpty($blockId, 'blockId'); if (is_null($options)) { @@ -2222,9 +2223,9 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $content, Models\AppendBlockOptions $options = null ) { - Validate::isString($container, 'container'); + Validate::canCastAsString($container, 'container'); Validate::notNullOrEmpty($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); if (is_null($options)) { @@ -2424,8 +2425,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blockList, Models\CommitBlobBlocksOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); Validate::isTrue( $blockList instanceof BlockList || is_array($blockList), @@ -2582,8 +2583,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\ListBlobBlocksOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_GET; @@ -2676,8 +2677,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\GetBlobPropertiesOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_HEAD; @@ -2756,8 +2757,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\GetBlobMetadataOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_HEAD; @@ -2848,8 +2849,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\ListPageBlobRangesOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_GET; @@ -2948,8 +2949,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\SetBlobPropertiesOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_PUT; @@ -3093,8 +3094,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob array $metadata, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); Utilities::validateMetadata($metadata); @@ -3251,8 +3252,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\GetBlobOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); $method = Resources::HTTP_GET; $headers = array(); @@ -3358,8 +3359,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\DeleteBlobOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_DELETE; @@ -3451,8 +3452,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $blob, Models\CreateBlobSnapshotOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); Validate::notNullOrEmpty($blob, 'blob'); $method = Resources::HTTP_PUT; @@ -3665,9 +3666,9 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $copyId, Models\BlobServiceOptions $options = null ) { - Validate::isString($container, 'container'); - Validate::isString($blob, 'blob'); - Validate::isString($copyId, 'copyId'); + Validate::canCastAsString($container, 'container'); + Validate::canCastAsString($blob, 'blob'); + Validate::canCastAsString($copyId, 'copyId'); Validate::notNullOrEmpty($container, 'container'); Validate::notNullOrEmpty($blob, 'blob'); Validate::notNullOrEmpty($copyId, 'copyId'); diff --git a/src/Blob/Models/BlobContinuationToken.php b/src/Blob/Models/BlobContinuationToken.php index d3f2136..534dfff 100644 --- a/src/Blob/Models/BlobContinuationToken.php +++ b/src/Blob/Models/BlobContinuationToken.php @@ -56,7 +56,7 @@ class BlobContinuationToken extends ContinuationToken */ public function setNextMarker($nextMarker) { - Validate::isString($nextMarker, 'nextMarker'); + Validate::canCastAsString($nextMarker, 'nextMarker'); $this->nextMarker = $nextMarker; } diff --git a/src/Blob/Models/BlockList.php b/src/Blob/Models/BlockList.php index 356c574..528c576 100644 --- a/src/Blob/Models/BlockList.php +++ b/src/Blob/Models/BlockList.php @@ -71,7 +71,7 @@ class BlockList */ public function addEntry($blockId, $type) { - Validate::isString($blockId, 'blockId'); + Validate::canCastAsString($blockId, 'blockId'); Validate::isTrue( BlobBlockType::isValid($type), sprintf(Resources::INVALID_BTE_MSG, get_class(new BlobBlockType())) diff --git a/src/Blob/Models/CreateBlobPagesResult.php b/src/Blob/Models/CreateBlobPagesResult.php index e89a797..4e5ee00 100644 --- a/src/Blob/Models/CreateBlobPagesResult.php +++ b/src/Blob/Models/CreateBlobPagesResult.php @@ -118,7 +118,7 @@ class CreateBlobPagesResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->_etag = $etag; } diff --git a/src/Blob/Models/CreateContainerOptions.php b/src/Blob/Models/CreateContainerOptions.php index 1f1e4c4..a825338 100644 --- a/src/Blob/Models/CreateContainerOptions.php +++ b/src/Blob/Models/CreateContainerOptions.php @@ -70,7 +70,7 @@ class CreateContainerOptions extends BlobServiceOptions */ public function setPublicAccess($publicAccess) { - Validate::isString($publicAccess, 'publicAccess'); + Validate::canCastAsString($publicAccess, 'publicAccess'); $this->_publicAccess = $publicAccess; } diff --git a/src/Blob/Models/ListBlobsOptions.php b/src/Blob/Models/ListBlobsOptions.php index 9336edc..5522ec1 100644 --- a/src/Blob/Models/ListBlobsOptions.php +++ b/src/Blob/Models/ListBlobsOptions.php @@ -70,7 +70,7 @@ class ListBlobsOptions extends BlobServiceOptions */ public function setPrefix($prefix) { - Validate::isString($prefix, 'prefix'); + Validate::canCastAsString($prefix, 'prefix'); $this->_prefix = $prefix; } @@ -93,7 +93,7 @@ class ListBlobsOptions extends BlobServiceOptions */ public function setDelimiter($delimiter) { - Validate::isString($delimiter, 'delimiter'); + Validate::canCastAsString($delimiter, 'delimiter'); $this->_delimiter = $delimiter; } diff --git a/src/Blob/Models/ListContainersOptions.php b/src/Blob/Models/ListContainersOptions.php index 8eadae4..ae662f8 100644 --- a/src/Blob/Models/ListContainersOptions.php +++ b/src/Blob/Models/ListContainersOptions.php @@ -68,7 +68,7 @@ class ListContainersOptions extends BlobServiceOptions */ public function setPrefix($prefix) { - Validate::isString($prefix, 'prefix'); + Validate::canCastAsString($prefix, 'prefix'); $this->_prefix = $prefix; } @@ -99,7 +99,7 @@ class ListContainersOptions extends BlobServiceOptions */ public function setMaxResults($maxResults) { - Validate::isString($maxResults, 'maxResults'); + Validate::canCastAsString($maxResults, 'maxResults'); $this->_maxResults = $maxResults; } diff --git a/src/Blob/Models/ListPageBlobRangesResult.php b/src/Blob/Models/ListPageBlobRangesResult.php index 9be7b54..7e894db 100644 --- a/src/Blob/Models/ListPageBlobRangesResult.php +++ b/src/Blob/Models/ListPageBlobRangesResult.php @@ -128,7 +128,7 @@ class ListPageBlobRangesResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->_etag = $etag; } diff --git a/src/Blob/Models/SetBlobMetadataResult.php b/src/Blob/Models/SetBlobMetadataResult.php index 5b9803c..51a3932 100644 --- a/src/Blob/Models/SetBlobMetadataResult.php +++ b/src/Blob/Models/SetBlobMetadataResult.php @@ -110,7 +110,7 @@ class SetBlobMetadataResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->_etag = $etag; } } diff --git a/src/Blob/Models/SetBlobPropertiesResult.php b/src/Blob/Models/SetBlobPropertiesResult.php index 1653208..e512599 100644 --- a/src/Blob/Models/SetBlobPropertiesResult.php +++ b/src/Blob/Models/SetBlobPropertiesResult.php @@ -115,7 +115,7 @@ class SetBlobPropertiesResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->_etag = $etag; } diff --git a/src/Common/CloudConfigurationManager.php b/src/Common/CloudConfigurationManager.php index c52762d..49dc957 100644 --- a/src/Common/CloudConfigurationManager.php +++ b/src/Common/CloudConfigurationManager.php @@ -80,7 +80,7 @@ class CloudConfigurationManager */ public static function getConnectionString($key) { - Validate::isString($key, 'key'); + Validate::canCastAsString($key, 'key'); self::_init(); $value = null; @@ -110,7 +110,7 @@ class CloudConfigurationManager */ public static function registerSource($name, $provider = null, $prepend = false) { - Validate::isString($name, 'name'); + Validate::canCastAsString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); @@ -140,7 +140,7 @@ class CloudConfigurationManager */ public static function unregisterSource($name) { - Validate::isString($name, 'name'); + Validate::canCastAsString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); self::_init(); diff --git a/src/Common/Internal/ACLBase.php b/src/Common/Internal/ACLBase.php index e0a2dab..8370de0 100644 --- a/src/Common/Internal/ACLBase.php +++ b/src/Common/Internal/ACLBase.php @@ -185,12 +185,12 @@ abstract class ACLBase \DateTime $expiry, $permissions ) { - Validate::isString($id, 'id'); + Validate::canCastAsString($id, 'id'); if ($start != null) { Validate::isDate($start); } Validate::isDate($expiry); - Validate::isString($permissions, 'permissions'); + Validate::canCastAsString($permissions, 'permissions'); $accessPolicy = new AccessPolicy($this->getResourceType()); $accessPolicy->setStart($start); @@ -222,7 +222,7 @@ abstract class ACLBase */ public function removeSignedIdentifier($id) { - Validate::isString($id, 'id'); + Validate::canCastAsString($id, 'id'); //var_dump($this->signedIdentifiers); for ($i = 0; $i < count($this->signedIdentifiers); ++$i) { if ($this->signedIdentifiers[$i]->getId() == $id) { diff --git a/src/Common/Internal/ConnectionStringParser.php b/src/Common/Internal/ConnectionStringParser.php index 4f88694..34d1ba9 100644 --- a/src/Common/Internal/ConnectionStringParser.php +++ b/src/Common/Internal/ConnectionStringParser.php @@ -60,9 +60,9 @@ class ConnectionStringParser */ public static function parseConnectionString($argumentName, $connectionString) { - Validate::isString($argumentName, 'argumentName'); + Validate::canCastAsString($argumentName, 'argumentName'); Validate::notNullOrEmpty($argumentName, 'argumentName'); - Validate::isString($connectionString, 'connectionString'); + Validate::canCastAsString($connectionString, 'connectionString'); Validate::notNullOrEmpty($connectionString, 'connectionString'); $parser = new ConnectionStringParser($argumentName, $connectionString); diff --git a/src/Common/Internal/ConnectionStringSource.php b/src/Common/Internal/ConnectionStringSource.php index 0ba83ff..468d379 100644 --- a/src/Common/Internal/ConnectionStringSource.php +++ b/src/Common/Internal/ConnectionStringSource.php @@ -65,7 +65,7 @@ class ConnectionStringSource */ public static function environmentSource($key) { - Validate::isString($key, 'key'); + Validate::canCastAsString($key, 'key'); return getenv($key); } diff --git a/src/Common/Internal/Http/HttpCallContext.php b/src/Common/Internal/Http/HttpCallContext.php index 9478b38..80273e2 100644 --- a/src/Common/Internal/Http/HttpCallContext.php +++ b/src/Common/Internal/Http/HttpCallContext.php @@ -87,7 +87,7 @@ class HttpCallContext */ public function setMethod($method) { - Validate::isString($method, 'method'); + Validate::canCastAsString($method, 'method'); $this->_method = $method; } @@ -165,7 +165,7 @@ class HttpCallContext */ public function setUri($uri) { - Validate::isString($uri, 'uri'); + Validate::canCastAsString($uri, 'uri'); $this->_uri = $uri; } @@ -189,7 +189,7 @@ class HttpCallContext */ public function setPath($path) { - Validate::isString($path, 'path'); + Validate::canCastAsString($path, 'path'); $this->_path = $path; } @@ -238,7 +238,7 @@ class HttpCallContext */ public function setBody($body) { - Validate::isString($body, 'body'); + Validate::canCastAsString($body, 'body'); $this->_body = $body; } @@ -253,8 +253,8 @@ class HttpCallContext */ public function addHeader($name, $value) { - Validate::isString($name, 'name'); - Validate::isString($value, 'value'); + Validate::canCastAsString($name, 'name'); + Validate::canCastAsString($value, 'value'); $this->_headers[$name] = $value; } @@ -271,8 +271,8 @@ class HttpCallContext */ public function addOptionalHeader($name, $value) { - Validate::isString($name, 'name'); - Validate::isString($value, 'value'); + Validate::canCastAsString($name, 'name'); + Validate::canCastAsString($value, 'value'); if (!empty($value)) { $this->_headers[$name] = $value; @@ -288,7 +288,7 @@ class HttpCallContext */ public function removeHeader($name) { - Validate::isString($name, 'name'); + Validate::canCastAsString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); unset($this->_headers[$name]); @@ -304,8 +304,8 @@ class HttpCallContext */ public function addQueryParameter($name, $value) { - Validate::isString($name, 'name'); - Validate::isString($value, 'value'); + Validate::canCastAsString($name, 'name'); + Validate::canCastAsString($value, 'value'); $this->_queryParams[$name] = $value; } @@ -345,8 +345,8 @@ class HttpCallContext */ public function addOptionalQueryParameter($name, $value) { - Validate::isString($name, 'name'); - Validate::isString($value, 'value'); + Validate::canCastAsString($name, 'name'); + Validate::canCastAsString($value, 'value'); if (!empty($value)) { $this->_queryParams[$name] = $value; diff --git a/src/Common/Internal/RestProxy.php b/src/Common/Internal/RestProxy.php index 1b03d26..6d777f1 100644 --- a/src/Common/Internal/RestProxy.php +++ b/src/Common/Internal/RestProxy.php @@ -102,8 +102,8 @@ class RestProxy protected function addOptionalQueryParam(array &$queryParameters, $key, $value) { Validate::isArray($queryParameters, 'queryParameters'); - Validate::isString($key, 'key'); - Validate::isString($value, 'value'); + Validate::canCastAsString($key, 'key'); + Validate::canCastAsString($value, 'value'); if (!is_null($value) && Resources::EMPTY_STRING !== $value) { $queryParameters[$key] = $value; @@ -124,8 +124,8 @@ class RestProxy protected function addOptionalHeader(array &$headers, $key, $value) { Validate::isArray($headers, 'headers'); - Validate::isString($key, 'key'); - Validate::isString($value, 'value'); + Validate::canCastAsString($key, 'key'); + Validate::canCastAsString($value, 'value'); if (!is_null($value) && Resources::EMPTY_STRING !== $value) { $headers[$key] = $value; diff --git a/src/Common/Internal/Serialization/JsonSerializer.php b/src/Common/Internal/Serialization/JsonSerializer.php index 4fd731b..6083f7c 100644 --- a/src/Common/Internal/Serialization/JsonSerializer.php +++ b/src/Common/Internal/Serialization/JsonSerializer.php @@ -50,7 +50,7 @@ class JsonSerializer implements ISerializer public static function objectSerialize($targetObject, $rootName) { Validate::notNull($targetObject, 'targetObject'); - Validate::isString($rootName, 'rootName'); + Validate::canCastAsString($rootName, 'rootName'); $contianer = new \stdClass(); @@ -84,7 +84,7 @@ class JsonSerializer implements ISerializer */ public function unserialize($serialized) { - Validate::isString($serialized, 'serialized'); + Validate::canCastAsString($serialized, 'serialized'); $json = json_decode($serialized); if ($json && !is_array($json)) { diff --git a/src/Common/Internal/Serialization/XmlSerializer.php b/src/Common/Internal/Serialization/XmlSerializer.php index 54c26f4..650560c 100644 --- a/src/Common/Internal/Serialization/XmlSerializer.php +++ b/src/Common/Internal/Serialization/XmlSerializer.php @@ -135,7 +135,7 @@ class XmlSerializer implements ISerializer public static function objectSerialize($targetObject, $rootName) { Validate::notNull($targetObject, 'targetObject'); - Validate::isString($rootName, 'rootName'); + Validate::canCastAsString($rootName, 'rootName'); $xmlWriter = new \XmlWriter(); $xmlWriter->openMemory(); $xmlWriter->setIndent(true); diff --git a/src/Common/Internal/Utilities.php b/src/Common/Internal/Utilities.php index 660476b..a551290 100644 --- a/src/Common/Internal/Utilities.php +++ b/src/Common/Internal/Utilities.php @@ -635,7 +635,7 @@ class Utilities */ public static function base256ToDec($number) { - Validate::isString($number, 'number'); + Validate::canCastAsString($number, 'number'); $result = 0; $base = 1; @@ -734,8 +734,8 @@ class Utilities } foreach ($metadata as $key => $value) { - Validate::isString($key, 'metadata key'); - Validate::isString($value, 'metadata value'); + Validate::canCastAsString($key, 'metadata key'); + Validate::canCastAsString($value, 'metadata value'); } } @@ -862,7 +862,7 @@ class Utilities public static function calculateContentMD5($content) { Validate::notNull($content, 'content'); - Validate::isString($content, 'content'); + Validate::canCastAsString($content, 'content'); return base64_encode(md5($content, true)); } diff --git a/src/Common/Internal/Validate.php b/src/Common/Internal/Validate.php index e0cf615..a8738bb 100644 --- a/src/Common/Internal/Validate.php +++ b/src/Common/Internal/Validate.php @@ -58,7 +58,7 @@ class Validate } /** - * Throws exception if the provided variable type is not string. + * Throws exception if the provided variable can not convert to a string. * * @param mixed $var The variable to check. * @param string $name The parameter name. @@ -67,7 +67,7 @@ class Validate * * @return void */ - public static function isString($var, $name) + public static function canCastAsString($var, $name) { try { (string)$var; @@ -315,7 +315,7 @@ class Validate */ public static function isA($objectInstance, $class, $name) { - Validate::isString($class, 'class'); + Validate::canCastAsString($class, 'class'); Validate::notNull($objectInstance, 'objectInstance'); Validate::isObject($objectInstance, 'objectInstance'); @@ -347,7 +347,7 @@ class Validate */ public static function methodExists($objectInstance, $method, $name) { - Validate::isString($method, 'method'); + Validate::canCastAsString($method, 'method'); Validate::notNull($objectInstance, 'objectInstance'); Validate::isObject($objectInstance, 'objectInstance'); @@ -376,7 +376,7 @@ class Validate */ public static function isDateString($value, $name) { - Validate::isString($value, 'value'); + Validate::canCastAsString($value, 'value'); try { new \DateTime($value); diff --git a/src/Common/Models/AccessPolicy.php b/src/Common/Models/AccessPolicy.php index d88be4f..5696e72 100644 --- a/src/Common/Models/AccessPolicy.php +++ b/src/Common/Models/AccessPolicy.php @@ -73,7 +73,7 @@ class AccessPolicy */ public function __construct($resourceType = Resources::RESOURCE_TYPE_BLOB) { - Validate::isString($resourceType, 'resourceType'); + Validate::canCastAsString($resourceType, 'resourceType'); Validate::isTrue( $resourceType == Resources::RESOURCE_TYPE_BLOB || $resourceType == Resources::RESOURCE_TYPE_CONTAINER || diff --git a/src/Common/Models/ContinuationToken.php b/src/Common/Models/ContinuationToken.php index 33c2e59..5956f16 100644 --- a/src/Common/Models/ContinuationToken.php +++ b/src/Common/Models/ContinuationToken.php @@ -55,7 +55,7 @@ class ContinuationToken */ public function setLocation($location) { - Validate::isString($location, 'location'); + Validate::canCastAsString($location, 'location'); Validate::isTrue( $location == LocationMode::PRIMARY_ONLY || $location == LocationMode::SECONDARY_ONLY || diff --git a/src/Common/SharedAccessSignatureHelper.php b/src/Common/SharedAccessSignatureHelper.php index 1a08815..caf0f1c 100644 --- a/src/Common/SharedAccessSignatureHelper.php +++ b/src/Common/SharedAccessSignatureHelper.php @@ -55,10 +55,10 @@ class SharedAccessSignatureHelper */ public function __construct($accountName, $accountKey) { - Validate::isString($accountName, 'accountName'); + Validate::canCastAsString($accountName, 'accountName'); Validate::notNullOrEmpty($accountName, 'accountName'); - Validate::isString($accountKey, 'accountKey'); + Validate::canCastAsString($accountKey, 'accountKey'); Validate::notNullOrEmpty($accountKey, 'accountKey'); $this->accountName = urldecode($accountName); @@ -119,7 +119,7 @@ class SharedAccessSignatureHelper $signedVersion = Resources::STORAGE_API_LATEST_VERSION; // check that the resource name is valid. Validate::notNullOrEmpty($resourceName, 'resourceName'); - Validate::isString($resourceName, 'resourceName'); + Validate::canCastAsString($resourceName, 'resourceName'); // validate and sanitize signed permissions $signedPermissions = $this->validateAndSanitizeSignedPermissions( $signedPermissions, @@ -127,19 +127,19 @@ class SharedAccessSignatureHelper ); // check that expiracy is valid Validate::notNullOrEmpty($signedExpiry, 'signedExpiry'); - Validate::isString($signedExpiry, 'signedExpiry'); + Validate::canCastAsString($signedExpiry, 'signedExpiry'); Validate::isDateString($signedExpiry, 'signedExpiry'); // check that signed start is valid - Validate::isString($signedStart, 'signedStart'); + Validate::canCastAsString($signedStart, 'signedStart'); if (strlen($signedStart) > 0) { Validate::isDateString($signedStart, 'signedStart'); } // check that signed IP is valid - Validate::isString($signedIP, 'signedIP'); + Validate::canCastAsString($signedIP, 'signedIP'); // validate and sanitize signed protocol $signedProtocol = $this->validateAndSanitizeSignedProtocol($signedProtocol); // check that signed identifier is valid - Validate::isString($signedIdentifier, 'signedIdentifier'); + Validate::canCastAsString($signedIdentifier, 'signedIdentifier'); Validate::isTrue( strlen($signedIdentifier) <= 64, sprintf(Resources::INVALID_STRING_LENGTH, 'signedIdentifier', 'maximum 64') @@ -155,16 +155,16 @@ class SharedAccessSignatureHelper } if ($type === 'bf') { - Validate::isString($cacheControl, 'cacheControl'); - Validate::isString($contentDisposition, 'contentDisposition'); - Validate::isString($contentEncoding, 'contentEncoding'); - Validate::isString($contentLanguage, 'contentLanguage'); - Validate::isString($contentType, 'contentType'); + Validate::canCastAsString($cacheControl, 'cacheControl'); + Validate::canCastAsString($contentDisposition, 'contentDisposition'); + Validate::canCastAsString($contentEncoding, 'contentEncoding'); + Validate::canCastAsString($contentLanguage, 'contentLanguage'); + Validate::canCastAsString($contentType, 'contentType'); } elseif ($type === 't') { - Validate::isString($startingPartitionKey, 'startingPartitionKey'); - Validate::isString($startingRowKey, 'startingRowKey'); - Validate::isString($endingPartitionKey, 'endingPartitionKey'); - Validate::isString($endingRowKey, 'endingRowKey'); + Validate::canCastAsString($startingPartitionKey, 'startingPartitionKey'); + Validate::canCastAsString($startingRowKey, 'startingRowKey'); + Validate::canCastAsString($endingPartitionKey, 'endingPartitionKey'); + Validate::canCastAsString($endingRowKey, 'endingRowKey'); } // construct an array with the parameters to generate the shared access signature at the account level @@ -282,7 +282,7 @@ class SharedAccessSignatureHelper $contentType = "" ) { // check that the resource name is valid. - Validate::isString($signedResource, 'signedResource'); + Validate::canCastAsString($signedResource, 'signedResource'); Validate::notNullOrEmpty($signedResource, 'signedResource'); Validate::isTrue( $signedResource == Resources::RESOURCE_TYPE_BLOB || @@ -363,7 +363,7 @@ class SharedAccessSignatureHelper $contentType = "" ) { // check that the resource name is valid. - Validate::isString($signedResource, 'signedResource'); + Validate::canCastAsString($signedResource, 'signedResource'); Validate::notNullOrEmpty($signedResource, 'signedResource'); Validate::isTrue( $signedResource == Resources::RESOURCE_TYPE_FILE || @@ -539,7 +539,7 @@ class SharedAccessSignatureHelper $signedProtocol = "" ) { // check that version is valid - Validate::isString($signedVersion, 'signedVersion'); + Validate::canCastAsString($signedVersion, 'signedVersion'); Validate::notNullOrEmpty($signedVersion, 'signedVersion'); Validate::isDateString($signedVersion, 'signedVersion'); @@ -553,18 +553,18 @@ class SharedAccessSignatureHelper $signedPermissions = $this->validateAndSanitizeSignedPermissions($signedPermissions); // check that expiracy is valid - Validate::isString($signedExpiry, 'signedExpiry'); + Validate::canCastAsString($signedExpiry, 'signedExpiry'); Validate::notNullOrEmpty($signedExpiry, 'signedExpiry'); Validate::isDateString($signedExpiry, 'signedExpiry'); // check that signed start is valid - Validate::isString($signedStart, 'signedStart'); + Validate::canCastAsString($signedStart, 'signedStart'); if (strlen($signedStart) > 0) { Validate::isDateString($signedStart, 'signedStart'); } // check that signed IP is valid - Validate::isString($signedIP, 'signedIP'); + Validate::canCastAsString($signedIP, 'signedIP'); // validate and sanitize signed protocol $signedProtocol = $this->validateAndSanitizeSignedProtocol($signedProtocol); @@ -619,7 +619,7 @@ class SharedAccessSignatureHelper private function validateAndSanitizeSignedService($signedService) { // validate signed service is not null or empty - Validate::isString($signedService, 'signedService'); + Validate::canCastAsString($signedService, 'signedService'); Validate::notNullOrEmpty($signedService, 'signedService'); // The signed service should only be a combination of the letters b(lob) q(ueue) t(able) or f(ile) @@ -643,7 +643,7 @@ class SharedAccessSignatureHelper private function validateAndSanitizeSignedResourceType($signedResourceType) { // validate signed resource type is not null or empty - Validate::isString($signedResourceType, 'signedResourceType'); + Validate::canCastAsString($signedResourceType, 'signedResourceType'); Validate::notNullOrEmpty($signedResourceType, 'signedResourceType'); // The signed resource type should only be a combination of the letters s(ervice) c(container) or o(bject) @@ -669,7 +669,7 @@ class SharedAccessSignatureHelper $signedResource = '' ) { // validate signed permissions are not null or empty - Validate::isString($signedPermissions, 'signedPermissions'); + Validate::canCastAsString($signedPermissions, 'signedPermissions'); Validate::notNullOrEmpty($signedPermissions, 'signedPermissions'); if ($signedResource == '') { @@ -695,7 +695,7 @@ class SharedAccessSignatureHelper */ private function validateAndSanitizeSignedProtocol($signedProtocol) { - Validate::isString($signedProtocol, 'signedProtocol'); + Validate::canCastAsString($signedProtocol, 'signedProtocol'); // sanitize string $sanitizedSignedProtocol = strtolower($signedProtocol); if (strlen($sanitizedSignedProtocol) > 0) { diff --git a/src/File/FileRestProxy.php b/src/File/FileRestProxy.php index 36f1c8f..2b1a8ff 100644 --- a/src/File/FileRestProxy.php +++ b/src/File/FileRestProxy.php @@ -122,7 +122,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile FileServiceOptions $options = null, $operation = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::isTrue( $operation == 'properties' || $operation == 'metadata', Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID @@ -194,12 +194,12 @@ class FileRestProxy extends ServiceRestProxy implements IFile FileServiceOptions $options = null, $operation = 'properties' ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::isTrue( $operation == 'properties' || $operation == 'metadata', Resources::FILE_SHARE_PROPERTIES_OPERATION_INVALID ); - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); $headers = array(); if ($operation == 'properties') { @@ -478,7 +478,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile $share, CreateShareOptions $options = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::notNullOrEmpty($share, 'share'); $method = Resources::HTTP_PUT; @@ -548,7 +548,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile $share, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::notNullOrEmpty($share, 'share'); $method = Resources::HTTP_DELETE; @@ -771,7 +771,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile $share, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); $method = Resources::HTTP_GET; $headers = array(); @@ -868,7 +868,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile ShareACL $acl, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::notNullOrEmpty($acl, 'acl'); $method = Resources::HTTP_PUT; @@ -942,7 +942,7 @@ class FileRestProxy extends ServiceRestProxy implements IFile */ public function getShareStatsAsync($share, FileServiceOptions $options = null) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); $method = Resources::HTTP_GET; $headers = array(); @@ -1028,8 +1028,9 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path = '', ListDirectoriesAndFilesOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::notNull($share, 'share'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_GET; $headers = array(); @@ -1129,8 +1130,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, CreateDirectoryOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); Validate::notNullOrEmpty($path, 'path'); $method = Resources::HTTP_PUT; @@ -1199,8 +1200,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_DELETE; $headers = array(); @@ -1266,8 +1267,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_GET; $headers = array(); @@ -1336,8 +1337,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_GET; $headers = array(); @@ -1421,8 +1422,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile array $metadata, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_PUT; $postParams = array(); @@ -1503,9 +1504,9 @@ class FileRestProxy extends ServiceRestProxy implements IFile $size, CreateFileOptions $options = null ) { - Validate::isString($share, 'share'); + Validate::canCastAsString($share, 'share'); Validate::notNullOrEmpty($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($path, 'path'); Validate::notNullOrEmpty($path, 'path'); Validate::isInteger($size, 'size'); @@ -1629,8 +1630,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_DELETE; $headers = array(); @@ -1697,8 +1698,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, GetFileOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_GET; $headers = array(); @@ -1787,8 +1788,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_HEAD; $headers = array(); @@ -1860,8 +1861,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile FileProperties $properties, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $headers = array(); @@ -1970,8 +1971,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile $path, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_GET; $headers = array(); @@ -2055,8 +2056,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile array $metadata, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); $method = Resources::HTTP_PUT; $postParams = array(); @@ -2146,8 +2147,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile Range $range, PutFileRangeOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); Validate::notNullOrEmpty($path, 'path'); Validate::notNullOrEmpty($share, 'share'); Validate::notNull($range->getLength(), Resources::RESOURCE_RANGE_LENGTH_MUST_SET); @@ -2344,8 +2345,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile Range $range, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); Validate::notNullOrEmpty($path, 'path'); Validate::notNullOrEmpty($share, 'share'); @@ -2437,8 +2438,8 @@ class FileRestProxy extends ServiceRestProxy implements IFile Range $range = null, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); Validate::notNullOrEmpty($path, 'path'); Validate::notNullOrEmpty($share, 'share'); @@ -2565,9 +2566,9 @@ class FileRestProxy extends ServiceRestProxy implements IFile array $metadata = array(), FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); - Validate::isString($sourcePath, 'sourcePath'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); + Validate::canCastAsString($sourcePath, 'sourcePath'); Validate::notNullOrEmpty($path, 'path'); Validate::notNullOrEmpty($share, 'share'); Validate::notNullOrEmpty($sourcePath, 'sourcePath'); @@ -2656,9 +2657,9 @@ class FileRestProxy extends ServiceRestProxy implements IFile $copyID, FileServiceOptions $options = null ) { - Validate::isString($share, 'share'); - Validate::isString($path, 'path'); - Validate::isString($copyID, 'copyID'); + Validate::canCastAsString($share, 'share'); + Validate::canCastAsString($path, 'path'); + Validate::canCastAsString($copyID, 'copyID'); Validate::notNullOrEmpty($share, 'share'); Validate::notNullOrEmpty($path, 'path'); Validate::notNullOrEmpty($copyID, 'copyID'); diff --git a/src/File/Models/CopyFileResult.php b/src/File/Models/CopyFileResult.php index fecfdff..98e4aee 100644 --- a/src/File/Models/CopyFileResult.php +++ b/src/File/Models/CopyFileResult.php @@ -112,7 +112,7 @@ class CopyFileResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->etag = $etag; } @@ -135,7 +135,7 @@ class CopyFileResult */ protected function setCopyID($copyID) { - Validate::isString($copyID, 'copyID'); + Validate::canCastAsString($copyID, 'copyID'); $this->copyID = $copyID; } @@ -158,7 +158,7 @@ class CopyFileResult */ protected function setCopyStatus($copyStatus) { - Validate::isString($copyStatus, 'copyStatus'); + Validate::canCastAsString($copyStatus, 'copyStatus'); $this->copyStatus = $copyStatus; } } diff --git a/src/File/Models/FileContinuationToken.php b/src/File/Models/FileContinuationToken.php index 9aabb2c..579928e 100644 --- a/src/File/Models/FileContinuationToken.php +++ b/src/File/Models/FileContinuationToken.php @@ -56,7 +56,7 @@ class FileContinuationToken extends ContinuationToken */ public function setNextMarker($nextMarker) { - Validate::isString($nextMarker, 'nextMarker'); + Validate::canCastAsString($nextMarker, 'nextMarker'); $this->nextMarker = $nextMarker; } diff --git a/src/File/Models/FileServiceOptions.php b/src/File/Models/FileServiceOptions.php index cbfb314..9adb42e 100644 --- a/src/File/Models/FileServiceOptions.php +++ b/src/File/Models/FileServiceOptions.php @@ -43,7 +43,7 @@ class FileServiceOptions extends ServiceOptions { public function setLocationMode($locationMode) { - Validate::isString($locationMode, 'locationMode'); + Validate::canCastAsString($locationMode, 'locationMode'); Validate::isTrue( $locationMode == LocationMode::PRIMARY_ONLY, Resources::FILE_LOCATION_IS_PRIMARY_ONLY diff --git a/src/File/Models/ListDirectoriesAndFilesOptions.php b/src/File/Models/ListDirectoriesAndFilesOptions.php index 0aeedd8..cd04c67 100644 --- a/src/File/Models/ListDirectoriesAndFilesOptions.php +++ b/src/File/Models/ListDirectoriesAndFilesOptions.php @@ -76,7 +76,7 @@ class ListDirectoriesAndFilesOptions extends FileServiceOptions */ public function setMaxResults($maxResults) { - Validate::isString($maxResults, 'maxResults'); + Validate::canCastAsString($maxResults, 'maxResults'); $this->maxResults = $maxResults; } } diff --git a/src/File/Models/ListFileRangesResult.php b/src/File/Models/ListFileRangesResult.php index 14b3ad3..51a7e77 100644 --- a/src/File/Models/ListFileRangesResult.php +++ b/src/File/Models/ListFileRangesResult.php @@ -127,7 +127,7 @@ class ListFileRangesResult */ protected function setETag($etag) { - Validate::isString($etag, 'etag'); + Validate::canCastAsString($etag, 'etag'); $this->etag = $etag; } diff --git a/src/File/Models/ListSharesOptions.php b/src/File/Models/ListSharesOptions.php index 4067ff3..bad0a62 100644 --- a/src/File/Models/ListSharesOptions.php +++ b/src/File/Models/ListSharesOptions.php @@ -68,7 +68,7 @@ class ListSharesOptions extends FileServiceOptions */ public function setPrefix($prefix) { - Validate::isString($prefix, 'prefix'); + Validate::canCastAsString($prefix, 'prefix'); $this->prefix = $prefix; } @@ -99,7 +99,7 @@ class ListSharesOptions extends FileServiceOptions */ public function setMaxResults($maxResults) { - Validate::isString($maxResults, 'maxResults'); + Validate::canCastAsString($maxResults, 'maxResults'); $this->maxResults = $maxResults; } diff --git a/src/Queue/Models/ListQueuesOptions.php b/src/Queue/Models/ListQueuesOptions.php index d6e3cef..938ba7d 100644 --- a/src/Queue/Models/ListQueuesOptions.php +++ b/src/Queue/Models/ListQueuesOptions.php @@ -66,7 +66,7 @@ class ListQueuesOptions extends QueueServiceOptions */ public function setPrefix($prefix) { - Validate::isString($prefix, 'prefix'); + Validate::canCastAsString($prefix, 'prefix'); $this->_prefix = $prefix; } @@ -89,7 +89,7 @@ class ListQueuesOptions extends QueueServiceOptions */ public function setMaxResults($maxResults) { - Validate::isString($maxResults, 'maxResults'); + Validate::canCastAsString($maxResults, 'maxResults'); $this->_maxResults = $maxResults; } diff --git a/src/Queue/Models/QueueContinuationToken.php b/src/Queue/Models/QueueContinuationToken.php index bd27c98..2866f93 100644 --- a/src/Queue/Models/QueueContinuationToken.php +++ b/src/Queue/Models/QueueContinuationToken.php @@ -56,7 +56,7 @@ class QueueContinuationToken extends ContinuationToken */ public function setNextMarker($nextMarker) { - Validate::isString($nextMarker, 'nextMarker'); + Validate::canCastAsString($nextMarker, 'nextMarker'); $this->nextMarker = $nextMarker; } diff --git a/src/Queue/Models/UpdateMessageResult.php b/src/Queue/Models/UpdateMessageResult.php index 4068aad..1fff8d8 100644 --- a/src/Queue/Models/UpdateMessageResult.php +++ b/src/Queue/Models/UpdateMessageResult.php @@ -117,7 +117,7 @@ class UpdateMessageResult */ protected function setPopReceipt($popReceipt) { - Validate::isString($popReceipt, 'popReceipt'); + Validate::canCastAsString($popReceipt, 'popReceipt'); $this->_popReceipt = $popReceipt; } } diff --git a/src/Queue/QueueRestProxy.php b/src/Queue/QueueRestProxy.php index 10a02ff..3631927 100644 --- a/src/Queue/QueueRestProxy.php +++ b/src/Queue/QueueRestProxy.php @@ -169,7 +169,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_DELETE; @@ -230,9 +230,9 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $messageText, CreateMessageOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - Validate::isString($messageText, 'messageText'); + Validate::canCastAsString($messageText, 'messageText'); $method = Resources::HTTP_POST; $headers = array(); @@ -310,7 +310,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, Models\CreateQueueOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_PUT; @@ -382,11 +382,11 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $popReceipt, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - Validate::isString($messageId, 'messageId'); + Validate::canCastAsString($messageId, 'messageId'); Validate::notNullOrEmpty($messageId, 'messageId'); - Validate::isString($popReceipt, 'popReceipt'); + Validate::canCastAsString($popReceipt, 'popReceipt'); Validate::notNullOrEmpty($popReceipt, 'popReceipt'); $method = Resources::HTTP_DELETE; @@ -445,7 +445,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_DELETE; @@ -497,7 +497,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_GET; @@ -561,7 +561,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, ListMessagesOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_GET; @@ -634,7 +634,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queueName, PeekMessagesOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); $method = Resources::HTTP_GET; @@ -706,7 +706,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue array $metadata = null, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); Utilities::validateMetadata($metadata); @@ -807,13 +807,13 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $visibilityTimeoutInSeconds, QueueServiceOptions $options = null ) { - Validate::isString($queueName, 'queueName'); + Validate::canCastAsString($queueName, 'queueName'); Validate::notNullOrEmpty($queueName, 'queueName'); - Validate::isString($messageId, 'messageId'); + Validate::canCastAsString($messageId, 'messageId'); Validate::notNullOrEmpty($messageId, 'messageId'); - Validate::isString($popReceipt, 'popReceipt'); + Validate::canCastAsString($popReceipt, 'popReceipt'); Validate::notNullOrEmpty($popReceipt, 'popReceipt'); - Validate::isString($messageText, 'messageText'); + Validate::canCastAsString($messageText, 'messageText'); Validate::isInteger( $visibilityTimeoutInSeconds, 'visibilityTimeoutInSeconds' @@ -905,7 +905,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue $queue, Models\QueueServiceOptions $options = null ) { - Validate::isString($queue, 'queue'); + Validate::canCastAsString($queue, 'queue'); $method = Resources::HTTP_GET; $headers = array(); @@ -978,7 +978,7 @@ class QueueRestProxy extends ServiceRestProxy implements IQueue Models\QueueACL $acl, Models\QueueServiceOptions $options = null ) { - Validate::isString($queue, 'queue'); + Validate::canCastAsString($queue, 'queue'); Validate::notNullOrEmpty($acl, 'acl'); $method = Resources::HTTP_PUT; diff --git a/src/Table/Models/BatchOperations.php b/src/Table/Models/BatchOperations.php index 4437fce..be1d803 100644 --- a/src/Table/Models/BatchOperations.php +++ b/src/Table/Models/BatchOperations.php @@ -101,7 +101,7 @@ class BatchOperations */ public function addInsertEntity($table, Entity $entity) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); $operation = new BatchOperation(); @@ -122,7 +122,7 @@ class BatchOperations */ public function addUpdateEntity($table, Entity $entity) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); $operation = new BatchOperation(); @@ -143,7 +143,7 @@ class BatchOperations */ public function addMergeEntity($table, Entity $entity) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); $operation = new BatchOperation(); @@ -164,7 +164,7 @@ class BatchOperations */ public function addInsertOrReplaceEntity($table, Entity $entity) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); $operation = new BatchOperation(); @@ -185,7 +185,7 @@ class BatchOperations */ public function addInsertOrMergeEntity($table, Entity $entity) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); $operation = new BatchOperation(); @@ -208,7 +208,7 @@ class BatchOperations */ public function addDeleteEntity($table, $partitionKey, $rowKey, $etag = null) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG); Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG); diff --git a/src/Table/Models/Entity.php b/src/Table/Models/Entity.php index cdd9a0c..6d5942d 100644 --- a/src/Table/Models/Entity.php +++ b/src/Table/Models/Entity.php @@ -55,7 +55,7 @@ class Entity Validate::isArray($properties, 'entity properties'); foreach ($properties as $key => $value) { - Validate::isString($key, 'key'); + Validate::canCastAsString($key, 'key'); Validate::isTrue( $value instanceof Property, Resources::INVALID_PROP_MSG diff --git a/src/Table/Models/TableContinuationToken.php b/src/Table/Models/TableContinuationToken.php index b23297f..ea5dd8e 100644 --- a/src/Table/Models/TableContinuationToken.php +++ b/src/Table/Models/TableContinuationToken.php @@ -74,7 +74,7 @@ class TableContinuationToken extends ContinuationToken */ public function setNextPartitionKey($nextPartitionKey) { - Validate::isString($nextPartitionKey, 'nextPartitionKey'); + Validate::canCastAsString($nextPartitionKey, 'nextPartitionKey'); $this->nextPartitionKey = $nextPartitionKey; } @@ -97,7 +97,7 @@ class TableContinuationToken extends ContinuationToken */ public function setNextRowKey($nextRowKey) { - Validate::isString($nextRowKey, 'nextRowKey'); + Validate::canCastAsString($nextRowKey, 'nextRowKey'); $this->nextRowKey = $nextRowKey; } @@ -120,7 +120,7 @@ class TableContinuationToken extends ContinuationToken */ public function setNextTableName($nextTableName) { - Validate::isString($nextTableName, 'nextTableName'); + Validate::canCastAsString($nextTableName, 'nextTableName'); $this->nextTableName = $nextTableName; } } diff --git a/src/Table/TableRestProxy.php b/src/Table/TableRestProxy.php index 7eee8ca..b1133b8 100644 --- a/src/Table/TableRestProxy.php +++ b/src/Table/TableRestProxy.php @@ -288,7 +288,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $rowKey, DeleteEntityOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG); Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG); @@ -350,7 +350,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $useETag, TableServiceOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); Validate::isTrue($entity->isValid($msg), $msg); @@ -413,7 +413,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable Entity $entity, TableServiceCreateOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); Validate::notNullOrEmpty($entity, 'entity'); Validate::isTrue($entity->isValid($msg), $msg); @@ -836,7 +836,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $table, TableServiceCreateOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); $method = Resources::HTTP_POST; @@ -905,7 +905,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $table, GetTableOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); $method = Resources::HTTP_GET; @@ -974,7 +974,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $table, TableServiceOptions$options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); $method = Resources::HTTP_DELETE; @@ -1033,7 +1033,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable */ public function queryEntitiesAsync($table, $options = null) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); $method = Resources::HTTP_GET; @@ -1448,7 +1448,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $rowKey, GetEntityOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($table, 'table'); Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG); Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG); @@ -1605,7 +1605,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable $table, Models\TableServiceOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); $method = Resources::HTTP_GET; $headers = array(); @@ -1684,7 +1684,7 @@ class TableRestProxy extends ServiceRestProxy implements ITable TableACL $acl, TableServiceOptions $options = null ) { - Validate::isString($table, 'table'); + Validate::canCastAsString($table, 'table'); Validate::notNullOrEmpty($acl, 'acl'); $method = Resources::HTTP_PUT; diff --git a/tests/unit/Blob/BlobRestProxyTest.php b/tests/unit/Blob/BlobRestProxyTest.php index a6a331b..e28c3fa 100644 --- a/tests/unit/Blob/BlobRestProxyTest.php +++ b/tests/unit/Blob/BlobRestProxyTest.php @@ -470,6 +470,16 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase $this->assertEquals($expectedLastModified, $result->getLastModified()); $this->assertEquals($expected, $result->getMetadata()); } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage can't be NULL. + */ + public function testListBlobsNull() + { + $this->restProxy->listBlobs(null); + } /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs @@ -757,8 +767,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock - * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException - * @expectedExceptionMessage 412 + * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException + * @expectedExceptionMessage 412 */ public function testAppendBlockConflictBecauseOfAppendPosition() { diff --git a/tests/unit/Common/Internal/ValidateTest.php b/tests/unit/Common/Internal/ValidateTest.php index f391e2c..bea70ff 100644 --- a/tests/unit/Common/Internal/ValidateTest.php +++ b/tests/unit/Common/Internal/ValidateTest.php @@ -61,22 +61,22 @@ class ValidateTest extends \PHPUnit_Framework_TestCase } /** - * @covers MicrosoftAzure\Storage\Common\Internal\Validate::isString + * @covers MicrosoftAzure\Storage\Common\Internal\Validate::canCastAsString */ public function testIsStringWithString() { - Validate::isString('I\'m a string', 'string'); + Validate::canCastAsString('I\'m a string', 'string'); $this->assertTrue(true); } /** - * @covers MicrosoftAzure\Storage\Common\Internal\Validate::isString + * @covers MicrosoftAzure\Storage\Common\Internal\Validate::canCastAsString */ public function testIsStringWithNonString() { $this->setExpectedException(get_class(new InvalidArgumentTypeException(''))); - Validate::isString(new \DateTime(), 'string'); + Validate::canCastAsString(new \DateTime(), 'string'); } /** diff --git a/tests/unit/File/FileRestProxyTest.php b/tests/unit/File/FileRestProxyTest.php index 83fd47e..2809b6e 100644 --- a/tests/unit/File/FileRestProxyTest.php +++ b/tests/unit/File/FileRestProxyTest.php @@ -215,6 +215,16 @@ class FileRestProxyTest extends FileServiceRestProxyTestBase $this->assertEquals(0, $result->getShareUsage()); } + /** + * @covers \MicrosoftAzure\Storage\File\FileRestProxy::listDirectoriesAndFiles + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage can't be NULL. + */ + public function testListDirectoriesAndFilesWithNull() + { + $this->restProxy->listDirectoriesAndFiles(null); + } + /** * @covers \MicrosoftAzure\Storage\File\FileRestProxy::deleteShare * @covers \MicrosoftAzure\Storage\File\FileRestProxy::deleteShareAsync From 562c58d9bdb3b48f6efe0e8c152bea0ea81ce9f7 Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Tue, 4 Jul 2017 21:53:16 +0800 Subject: [PATCH 3/7] Added support for anonymous read access for blob service. --- ChangeLog.md | 1 + .../Middlewares/CommonRequestMiddleware.php | 8 +- src/Common/Internal/Resources.php | 1 + src/Common/ServicesBuilder.php | 62 +++++++ .../Common/AnonymousAccessFunctionalTest.php | 162 ++++++++++++++++++ tests/unit/Common/ServicesBuilderTest.php | 29 ++++ 6 files changed, 260 insertions(+), 3 deletions(-) create mode 100644 tests/functional/Common/AnonymousAccessFunctionalTest.php diff --git a/ChangeLog.md b/ChangeLog.md index d97651c..9765d1d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ All * REST API version upgraded to 2016-05-31. +* Added support for anonymous read access to containers. User can now call `MicrosoftAzure\Storage\Common\ServiceBuilder::createContainerAnonymousAccess` to create service proxy to access containers/blobs without credential. Table * Deprecated ATOM support for Table service. diff --git a/src/Common/Internal/Middlewares/CommonRequestMiddleware.php b/src/Common/Internal/Middlewares/CommonRequestMiddleware.php index bd863b3..a46b2a7 100644 --- a/src/Common/Internal/Middlewares/CommonRequestMiddleware.php +++ b/src/Common/Internal/Middlewares/CommonRequestMiddleware.php @@ -57,7 +57,7 @@ class CommonRequestMiddleware extends MiddlewareBase * @param array $headers The headers to be added. */ public function __construct( - IAuthScheme $authenticationScheme, + IAuthScheme $authenticationScheme = null, array $headers = array() ) { $this->authenticationScheme = $authenticationScheme; @@ -104,8 +104,10 @@ class CommonRequestMiddleware extends MiddlewareBase if (!$result->hasHeader(Resources::X_MS_REQUEST_ID)) { $result = $result->withHeader(Resources::X_MS_REQUEST_ID, \uniqid()); } - //Signing the request. - return $this->authenticationScheme->signRequest($result); + //Sign the request if authentication scheme is not null. + $request = $this->authenticationScheme == null ? + $request : $this->authenticationScheme->signRequest($result); + return $request; } /** diff --git a/src/Common/Internal/Resources.php b/src/Common/Internal/Resources.php index d04ac9c..e60aece 100644 --- a/src/Common/Internal/Resources.php +++ b/src/Common/Internal/Resources.php @@ -141,6 +141,7 @@ class Resources const RESOURCE_RANGE_LENGTH_MUST_SET = "The start and end/length of the range must be set."; const INVALID_ACCEPT_CONTENT_TYPE = "The given accept content type is not valid."; const ERROR_CANNOT_PARSE_XML = "Cannot parse XML, reasons: %s"; + const INVALID_SCHEME = 'HTTP scheme can only be string \'http\' or \'https\'.'; // HTTP Headers const X_MS_HEADER_PREFIX = 'x-ms-'; diff --git a/src/Common/ServicesBuilder.php b/src/Common/ServicesBuilder.php index dfc682f..573d6cb 100644 --- a/src/Common/ServicesBuilder.php +++ b/src/Common/ServicesBuilder.php @@ -282,6 +282,47 @@ class ServicesBuilder return $blobWrapper; } + /** + * Builds an anonymous access object with given primary and secondary + * service endpoint. The service endpoint should contain a scheme and a + * host, e.g.: + * https://www.contoso.com + * http://mystorageaccount.blob.core.windows.net + * + * @param string $primaryServiceEndpoint Primary service endpoint. + * @param string $secondaryServiceEndpoint Secondary service endpoint. + * @param array $options Optional request options. + * + * @return \MicrosoftAzure\Storage\Blob\Internal\IBlob + */ + public function createContainerAnonymousAccess( + $primaryServiceEndpoint, + $secondaryServiceEndpoint = null, + array $options = [] + ) { + Validate::canCastAsString($primaryServiceEndpoint, '$primaryServiceEndpoint'); + if ($secondaryServiceEndpoint != null) { + Validate::canCastAsString( + $secondaryServiceEndpoint, + '$secondaryServiceEndpoint' + ); + } + + $serializer = $this->serializer(); + + $blobWrapper = new BlobRestProxy( + $primaryServiceEndpoint, + $secondaryServiceEndpoint, + self::tryParseAccountNameFromBlobEndpointURL($primaryServiceEndpoint), + $serializer, + $options + ); + + $blobWrapper->pushMiddleware(new CommonRequestMiddleware()); + + return $blobWrapper; + } + /** * Builds a file service object, it accepts the following * options: @@ -428,4 +469,25 @@ class ServicesBuilder return self::$instance; } + + /** + * Try to parse the account anme from blob endpoint URL, return null + * if pattern failed to found. + * + * @param string $url The blob endpoint URL. + * + * @return string|null + */ + private static function tryParseAccountNameFromBlobEndpointURL($url) + { + $pos = strpos($url, Resources::BLOB_BASE_DNS_NAME); + + if ($pos == false) { + return null; + } + + $slashPos = strpos($url, '//'); + + return substr($url, $slashPos + 2, $pos - $slashPos - 3); + } } diff --git a/tests/functional/Common/AnonymousAccessFunctionalTest.php b/tests/functional/Common/AnonymousAccessFunctionalTest.php new file mode 100644 index 0000000..b25426e --- /dev/null +++ b/tests/functional/Common/AnonymousAccessFunctionalTest.php @@ -0,0 +1,162 @@ + + * @copyright 2017 Microsoft Corporation + * @license https://github.com/azure/azure-storage-php/LICENSE + * @link https://github.com/azure/azure-storage-php + */ + +namespace MicrosoftAzure\Storage\Tests\functional\Common; + +use MicrosoftAzure\Storage\Common\Internal\Resources; +use MicrosoftAzure\Storage\Common\Internal\Utilities; +use MicrosoftAzure\Storage\Common\ServicesBuilder; +use MicrosoftAzure\Storage\Tests\framework\TestResources; +use MicrosoftAzure\Storage\Common\Exceptions\ServiceException; +use MicrosoftAzure\Storage\Blob\Models\PublicAccessType; + +/** + * Tests for account SAS proxy tests. + * + * @category Microsoft + * @package MicrosoftAzure\Storage\Tests\Framework + * @author Azure Storage PHP SDK + * @copyright 2017 Microsoft Corporation + * @license https://github.com/azure/azure-storage-php/LICENSE + * @link https://github.com/azure/azure-storage-php + */ +class AnonymousAccessFunctionalTest extends \PHPUnit_Framework_TestCase +{ + + private $containerName; + private static $blobRestProxy; + private static $serviceBuilder; + private static $accountName; + + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + $connectionString = TestResources::getWindowsAzureStorageServicesConnectionString(); + self::$serviceBuilder = new ServicesBuilder(); + self::$blobRestProxy = + self::$serviceBuilder->createBlobService($connectionString); + self::$accountName = self::$blobRestProxy->getAccountName(); + } + + public function setUp() + { + parent::setUp(); + $this->containerName = TestResources::getInterestingName('con'); + self::$blobRestProxy->createContainer($this->containerName); + } + + public function tearDown() + { + self::$blobRestProxy->deleteContainer($this->containerName); + parent::tearDown(); + } + + /** + * @covers MicrosoftAzure\Storage\Common\ServicesBuilder::createContainerAnonymousAccess + */ + public function testPublicAccessContainerAndBlob() + { + $acl = self::$blobRestProxy->getContainerAcl($this->containerName)->getContainerAcl(); + $acl->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS); + self::$blobRestProxy->setContainerAcl($this->containerName, $acl); + + $pEndpoint = sprintf( + '%s://%s.%s', + Resources::HTTPS_SCHEME, + self::$accountName, + Resources::BLOB_BASE_DNS_NAME + ); + $sEndpoint = sprintf( + '%s://%s.%s', + Resources::HTTPS_SCHEME, + self::$accountName . '-secondary', + Resources::BLOB_BASE_DNS_NAME + ); + + $proxy = self::$serviceBuilder->createContainerAnonymousAccess( + $pEndpoint, + $sEndpoint + ); + + $result = $proxy->listBlobs($this->containerName); + + $this->assertEquals(0, count($result->getBlobs())); + + $blob = TestResources::getInterestingName('b'); + self::$blobRestProxy->createPageBlob($this->containerName, $blob, 512); + $result = $proxy->listBlobs($this->containerName); + $this->assertEquals(1, count($result->getBlobs())); + self::$blobRestProxy->deleteBlob($this->containerName, $blob); + $result = $proxy->listBlobs($this->containerName); + $this->assertEquals(0, count($result->getBlobs())); + } + + /** + * @covers MicrosoftAzure\Storage\Common\ServicesBuilder::createContainerAnonymousAccess + * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException + * @expectedExceptionMessage 404 + */ + public function testPublicAccessBlobOnly() + { + $acl = self::$blobRestProxy->getContainerAcl($this->containerName)->getContainerAcl(); + $acl->setPublicAccess(PublicAccessType::BLOBS_ONLY); + self::$blobRestProxy->setContainerAcl($this->containerName, $acl); + + $pHost = self::$accountName . '.' . Resources::BLOB_BASE_DNS_NAME; + $sHost = self::$accountName . '-secondary' . '.' . Resources::BLOB_BASE_DNS_NAME; + $scheme = Resources::HTTPS_SCHEME; + + $pEndpoint = sprintf( + '%s://%s.%s', + Resources::HTTPS_SCHEME, + self::$accountName, + Resources::BLOB_BASE_DNS_NAME + ); + $sEndpoint = sprintf( + '%s://%s.%s', + Resources::HTTPS_SCHEME, + self::$accountName . '-secondary', + Resources::BLOB_BASE_DNS_NAME + ); + + $proxy = self::$serviceBuilder->createContainerAnonymousAccess( + $pEndpoint, + $sEndpoint + ); + + $result = self::$blobRestProxy->listBlobs($this->containerName); + $this->assertEquals(0, count($result->getBlobs())); + $blob = TestResources::getInterestingName('b'); + self::$blobRestProxy->createBlockBlob($this->containerName, $blob, 'test content'); + $result = self::$blobRestProxy->listBlobs($this->containerName); + $this->assertEquals(1, count($result->getBlobs())); + $content = stream_get_contents($proxy->getBlob($this->containerName, $blob)->getContentStream()); + $this->assertEquals('test content', $content); + self::$blobRestProxy->deleteBlob($this->containerName, $blob); + $result = self::$blobRestProxy->listBlobs($this->containerName); + $this->assertEquals(0, count($result->getBlobs())); + //The following line will generate ServiceException with 404. + $result = $proxy->listBlobs($this->containerName); + } +} diff --git a/tests/unit/Common/ServicesBuilderTest.php b/tests/unit/Common/ServicesBuilderTest.php index dadeea6..b12525f 100644 --- a/tests/unit/Common/ServicesBuilderTest.php +++ b/tests/unit/Common/ServicesBuilderTest.php @@ -124,4 +124,33 @@ class ServicesBuilderTest extends \PHPUnit_Framework_TestCase // Assert $this->assertInstanceOf('MicrosoftAzure\Storage\Common\ServicesBuilder', $actual); } + + /** + * @covers MicrosoftAzure\Storage\Common\ServicesBuilder::createContainerAnonymousAccess + */ + public function testBuildForAnonymousAccess() + { + $builder = new ServicesBuilder(); + + $pEndpoint = sprintf( + '%s://%s%s', + Resources::HTTP_SCHEME, + 'myaccount.', + Resources::BLOB_BASE_DNS_NAME + ); + $sEndpoint = sprintf( + '%s://%s%s', + Resources::HTTP_SCHEME, + 'myaccount-secondary.', + Resources::BLOB_BASE_DNS_NAME + ); + + $blobRestProxy = $builder->createContainerAnonymousAccess( + $pEndpoint, + $sEndpoint + ); + + $this->assertInstanceOf('MicrosoftAzure\Storage\Blob\Internal\IBlob', $blobRestProxy); + $this->assertEquals('myaccount', $blobRestProxy->getAccountName()); + } } From b64b2d0824ea01f6b1ef8aa17d65fd04c7e705ac Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Wed, 5 Jul 2017 17:16:59 +0800 Subject: [PATCH 4/7] Refined code logic for continuation token so user can enumerate with pagination more easily --- BreakingChanges.md | 12 ++++ ChangeLog.md | 10 +++ .../Models/BlobContinuationTokenTrait.php | 56 --------------- src/Blob/Models/ListBlobsOptions.php | 4 +- src/Blob/Models/ListBlobsResult.php | 28 ++++---- src/Blob/Models/ListContainersOptions.php | 5 +- src/Blob/Models/ListContainersResult.php | 28 ++++---- src/Common/MarkerContinuationTokenTrait.php | 24 ++++--- .../Models/MarkerContinuationToken.php} | 11 +-- src/File/Models/FileContinuationToken.php | 72 ------------------- .../Models/FileContinuationTokenTrait.php | 56 --------------- .../Models/ListDirectoriesAndFilesOptions.php | 5 +- .../Models/ListDirectoriesAndFilesResult.php | 25 ++++--- src/File/Models/ListSharesOptions.php | 5 +- src/File/Models/ListSharesResult.php | 28 +++++--- src/Queue/Models/ListQueuesOptions.php | 5 +- src/Queue/Models/ListQueuesResult.php | 27 +++---- src/Queue/Models/QueueContinuationToken.php | 72 ------------------- .../Models/QueueContinuationTokenTrait.php | 56 --------------- src/Table/Models/QueryEntitiesResult.php | 18 ++--- src/Table/Models/QueryTablesResult.php | 24 ++++--- .../Models/TableContinuationTokenTrait.php | 13 ++-- tests/framework/TestResources.php | 2 +- 23 files changed, 159 insertions(+), 427 deletions(-) delete mode 100644 src/Blob/Models/BlobContinuationTokenTrait.php rename src/{Blob/Models/BlobContinuationToken.php => Common/Models/MarkerContinuationToken.php} (85%) delete mode 100644 src/File/Models/FileContinuationToken.php delete mode 100644 src/File/Models/FileContinuationTokenTrait.php delete mode 100644 src/Queue/Models/QueueContinuationToken.php delete mode 100644 src/Queue/Models/QueueContinuationTokenTrait.php diff --git a/BreakingChanges.md b/BreakingChanges.md index 83c7160..ef51345 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -1,8 +1,20 @@ Tracking Breaking changes in 0.17.0 +All +* Refined code logic for continuation token. Now continuation token will be null if there are no more instance to be queried/listed. + +Blob +* Removed `MicrosoftAzure\Storage\Tests\unit\Blob\Models\BlobContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. + Table * Deprecated ATOM support for Table service. +Queue +* Removed `MicrosoftAzure\Storage\Tests\unit\Queue\Models\QueueContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. + +File +* Removed `MicrosoftAzure\Storage\Tests\unit\File\Models\FileContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. + Tracking Breaking changes in 0.16.0 All diff --git a/ChangeLog.md b/ChangeLog.md index 9765d1d..9b29aa3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,10 +3,20 @@ All * REST API version upgraded to 2016-05-31. * Added support for anonymous read access to containers. User can now call `MicrosoftAzure\Storage\Common\ServiceBuilder::createContainerAnonymousAccess` to create service proxy to access containers/blobs without credential. +* Refined code logic for continuation token. Now continuation token will be null if there are no more instance to be queried/listed. + +Blob +* Removed `MicrosoftAzure\Storage\Tests\unit\Blob\Models\BlobContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. Table * Deprecated ATOM support for Table service. +Queue +* Removed `MicrosoftAzure\Storage\Tests\unit\Queue\Models\QueueContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. + +File +* Removed `MicrosoftAzure\Storage\Tests\unit\File\Models\FileContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. + 2017.06 - version 0.16.0 All diff --git a/src/Blob/Models/BlobContinuationTokenTrait.php b/src/Blob/Models/BlobContinuationTokenTrait.php deleted file mode 100644 index 2849565..0000000 --- a/src/Blob/Models/BlobContinuationTokenTrait.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ - -namespace MicrosoftAzure\Storage\Blob\Models; - -use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationToken; - -/** - * Trait implementing logic for Blob continuation tokens. - * - * @category Microsoft - * @package MicrosoftAzure\Storage\Blob\Models - * @author Azure Storage PHP SDK - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ -trait BlobContinuationTokenTrait -{ - use MarkerContinuationTokenTrait; - - /** - * Creates a continuation token if current one is null. - * - * @return void - */ - private function createContinuationTokenIfNotExist() - { - if ($this->continuationToken == null) { - $this->continuationToken = new BlobContinuationToken(); - } - } -} diff --git a/src/Blob/Models/ListBlobsOptions.php b/src/Blob/Models/ListBlobsOptions.php index 5522ec1..8a54cfd 100644 --- a/src/Blob/Models/ListBlobsOptions.php +++ b/src/Blob/Models/ListBlobsOptions.php @@ -26,8 +26,6 @@ namespace MicrosoftAzure\Storage\Blob\Models; use MicrosoftAzure\Storage\Common\Internal\Validate; use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationToken; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; /** * Optional parameters for listBlobs API. @@ -41,7 +39,7 @@ use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; */ class ListBlobsOptions extends BlobServiceOptions { - use BlobContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_prefix; private $_delimiter; diff --git a/src/Blob/Models/ListBlobsResult.php b/src/Blob/Models/ListBlobsResult.php index 6f27156..882e960 100644 --- a/src/Blob/Models/ListBlobsResult.php +++ b/src/Blob/Models/ListBlobsResult.php @@ -24,11 +24,11 @@ namespace MicrosoftAzure\Storage\Blob\Models; -use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Blob\Models\Blob; +use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Internal\Utilities; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationToken; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; use MicrosoftAzure\Storage\Common\Exceptions\InvalidArgumentTypeException; /** @@ -43,7 +43,7 @@ use MicrosoftAzure\Storage\Common\Exceptions\InvalidArgumentTypeException; */ class ListBlobsResult { - use BlobContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_blobPrefixes; private $_blobs; @@ -87,15 +87,17 @@ class ListBlobsResult Resources::QP_MARKER )); - $result->setContinuationToken( - new BlobContinuationToken( - Utilities::tryGetValue( - $parsed, - Resources::QP_NEXT_MARKER - ), - $location - ) - ); + $nextMarker = + Utilities::tryGetValue($parsed, Resources::QP_NEXT_MARKER); + + if ($nextMarker != null) { + $result->setContinuationToken( + new MarkerContinuationToken( + $nextMarker, + $location + ) + ); + } $result->setMaxResults(intval( Utilities::tryGetValue($parsed, Resources::QP_MAX_RESULTS, 0) diff --git a/src/Blob/Models/ListContainersOptions.php b/src/Blob/Models/ListContainersOptions.php index ae662f8..fc26adc 100644 --- a/src/Blob/Models/ListContainersOptions.php +++ b/src/Blob/Models/ListContainersOptions.php @@ -25,8 +25,7 @@ namespace MicrosoftAzure\Storage\Blob\Models; use MicrosoftAzure\Storage\Blob\Models\BlobServiceOptions; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationToken; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; use MicrosoftAzure\Storage\Common\Internal\Validate; /** @@ -41,7 +40,7 @@ use MicrosoftAzure\Storage\Common\Internal\Validate; */ class ListContainersOptions extends BlobServiceOptions { - use BlobContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_prefix; private $_maxResults; diff --git a/src/Blob/Models/ListContainersResult.php b/src/Blob/Models/ListContainersResult.php index 227b4c2..e2cc5fc 100644 --- a/src/Blob/Models/ListContainersResult.php +++ b/src/Blob/Models/ListContainersResult.php @@ -27,8 +27,8 @@ namespace MicrosoftAzure\Storage\Blob\Models; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Internal\Utilities; use MicrosoftAzure\Storage\Blob\Models\Container; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationToken; -use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; /** * Container to hold list container response object. @@ -42,7 +42,7 @@ use MicrosoftAzure\Storage\Blob\Models\BlobContinuationTokenTrait; */ class ListContainersResult { - use BlobContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_containers; private $_prefix; @@ -80,15 +80,19 @@ class ListContainersResult $parsedResponse, Resources::QP_MARKER )); - $result->setContinuationToken( - new BlobContinuationToken( - Utilities::tryGetValue( - $parsedResponse, - Resources::QP_NEXT_MARKER - ), - $location - ) - ); + + $nextMarker = + Utilities::tryGetValue($parsedResponse, Resources::QP_NEXT_MARKER); + + if ($nextMarker != null) { + $result->setContinuationToken( + new MarkerContinuationToken( + $nextMarker, + $location + ) + ); + } + $result->setMaxResults(Utilities::tryGetValue( $parsedResponse, Resources::QP_MAX_RESULTS diff --git a/src/Common/MarkerContinuationTokenTrait.php b/src/Common/MarkerContinuationTokenTrait.php index fb0125e..d47f186 100644 --- a/src/Common/MarkerContinuationTokenTrait.php +++ b/src/Common/MarkerContinuationTokenTrait.php @@ -25,7 +25,7 @@ namespace MicrosoftAzure\Storage\Common; -use MicrosoftAzure\Storage\Common\Models\ContinuationToken; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; /** * Trait implementing logic for continuation tokens that has nextMarker. @@ -44,16 +44,19 @@ trait MarkerContinuationTokenTrait /** * Setter for continuationToken * - * @param ContinuationToken $continuationToken the continuation token to be set. + * @param MarkerContinuationToken|null $continuationToken the continuation + * token to be set. */ - public function setContinuationToken(ContinuationToken $continuationToken) + public function setContinuationToken(MarkerContinuationToken $continuationToken = null) { $this->continuationToken = $continuationToken; } public function setMarker($marker) { - $this->createContinuationTokenIfNotExist(); + if ($this->continuationToken == null) { + $this->continuationToken = new MarkerContinuationToken(); + }; $this->continuationToken->setNextMarker($marker); } @@ -74,7 +77,9 @@ trait MarkerContinuationTokenTrait */ public function getNextMarker() { - $this->createContinuationTokenIfNotExist(); + if ($this->continuationToken == null) { + return null; + } return $this->continuationToken->getNextMarker(); } @@ -85,14 +90,17 @@ trait MarkerContinuationTokenTrait */ public function getLocation() { - $this->createContinuationTokenIfNotExist(); + if ($this->continuationToken == null) { + return null; + } return $this->continuationToken->getLocation(); } public function getLocationMode() { - $this->createContinuationTokenIfNotExist(); - if ($this->continuationToken->getLocation() == '') { + if ($this->continuationToken == null) { + return parent::getLocationMode(); + } elseif ($this->continuationToken->getLocation() == '') { return parent::getLocationMode(); } else { return $this->getLocation(); diff --git a/src/Blob/Models/BlobContinuationToken.php b/src/Common/Models/MarkerContinuationToken.php similarity index 85% rename from src/Blob/Models/BlobContinuationToken.php rename to src/Common/Models/MarkerContinuationToken.php index 534dfff..cb5dace 100644 --- a/src/Blob/Models/BlobContinuationToken.php +++ b/src/Common/Models/MarkerContinuationToken.php @@ -15,29 +15,30 @@ * PHP version 5 * * @category Microsoft - * @package MicrosoftAzure\Storage\Blob\Models + * @package MicrosoftAzure\Storage\Common\Models * @author Azure Storage PHP SDK * @copyright 2017 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ -namespace MicrosoftAzure\Storage\Blob\Models; +namespace MicrosoftAzure\Storage\Common\Models; use MicrosoftAzure\Storage\Common\Internal\Validate; use MicrosoftAzure\Storage\Common\Models\ContinuationToken; /** - * Provides functionality and data structure for blob continuation token. + * Provides functionality and data structure for continuation token that + * contains next marker. * * @category Microsoft - * @package MicrosoftAzure\Storage\Blob\Models + * @package MicrosoftAzure\Storage\Common\Models * @author Azure Storage PHP SDK * @copyright 2017 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ -class BlobContinuationToken extends ContinuationToken +class MarkerContinuationToken extends ContinuationToken { private $nextMarker; diff --git a/src/File/Models/FileContinuationToken.php b/src/File/Models/FileContinuationToken.php deleted file mode 100644 index 579928e..0000000 --- a/src/File/Models/FileContinuationToken.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ - -namespace MicrosoftAzure\Storage\File\Models; - -use MicrosoftAzure\Storage\Common\Internal\Validate; -use MicrosoftAzure\Storage\Common\Models\ContinuationToken; - -/** - * Provides functionality and data structure for File continuation token. - * - * @category Microsoft - * @package MicrosoftAzure\Storage\File\Models - * @author Azure Storage PHP SDK - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ -class FileContinuationToken extends ContinuationToken -{ - private $nextMarker; - - public function __construct( - $nextMarker = '', - $location = '' - ) { - parent::__construct($location); - $this->setNextMarker($nextMarker); - } - - /** - * Setter for nextMarker - * - * @param string $nextMarker the next marker to be set. - */ - public function setNextMarker($nextMarker) - { - Validate::canCastAsString($nextMarker, 'nextMarker'); - $this->nextMarker = $nextMarker; - } - - /** - * Getter for nextMarker - * - * @return string - */ - public function getNextMarker() - { - return $this->nextMarker; - } -} diff --git a/src/File/Models/FileContinuationTokenTrait.php b/src/File/Models/FileContinuationTokenTrait.php deleted file mode 100644 index 90cb7e2..0000000 --- a/src/File/Models/FileContinuationTokenTrait.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ - -namespace MicrosoftAzure\Storage\File\Models; - -use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; -use MicrosoftAzure\Storage\File\Models\FileContinuationToken; - -/** - * Trait implementing logic for File continuation tokens. - * - * @category Microsoft - * @package MicrosoftAzure\Storage\File\Models - * @author Azure Storage PHP SDK - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ -trait FileContinuationTokenTrait -{ - use MarkerContinuationTokenTrait; - - /** - * Creates a continuation token if current one is null. - * - * @return void - */ - private function createContinuationTokenIfNotExist() - { - if ($this->continuationToken == null) { - $this->continuationToken = new FileContinuationToken(); - } - } -} diff --git a/src/File/Models/ListDirectoriesAndFilesOptions.php b/src/File/Models/ListDirectoriesAndFilesOptions.php index cd04c67..e48e5ca 100644 --- a/src/File/Models/ListDirectoriesAndFilesOptions.php +++ b/src/File/Models/ListDirectoriesAndFilesOptions.php @@ -28,8 +28,7 @@ use MicrosoftAzure\Storage\Common\Internal\Utilities; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Internal\Validate; use MicrosoftAzure\Storage\File\Models\FileServiceOptions; -use MicrosoftAzure\Storage\File\Models\FileContinuationToken; -use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; /** * The options of listing directories and files. @@ -43,7 +42,7 @@ use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; */ class ListDirectoriesAndFilesOptions extends FileServiceOptions { - use FileContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $maxResults; diff --git a/src/File/Models/ListDirectoriesAndFilesResult.php b/src/File/Models/ListDirectoriesAndFilesResult.php index fe246cd..011653d 100644 --- a/src/File/Models/ListDirectoriesAndFilesResult.php +++ b/src/File/Models/ListDirectoriesAndFilesResult.php @@ -27,8 +27,8 @@ namespace MicrosoftAzure\Storage\File\Models; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Internal\Utilities; use MicrosoftAzure\Storage\File\Models\Share; -use MicrosoftAzure\Storage\File\Models\FileContinuationToken; -use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; /** * Share to hold list directories and files response object. @@ -42,7 +42,7 @@ use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; */ class ListDirectoriesAndFilesResult { - use FileContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $directories; private $files; @@ -73,21 +73,20 @@ class ListDirectoriesAndFilesResult $serviceEndpoint )); - $result->setContinuationToken( - new FileContinuationToken( - Utilities::tryGetValue( - $parsedResponse, - Resources::QP_NEXT_MARKER - ), - $location - ) - ); - $nextMarker = Utilities::tryGetValue( $parsedResponse, Resources::QP_NEXT_MARKER ); + if ($nextMarker != null) { + $result->setContinuationToken( + new MarkerContinuationToken( + $nextMarker, + $location + ) + ); + } + $result->setMaxResults(Utilities::tryGetValue( $parsedResponse, Resources::QP_MAX_RESULTS diff --git a/src/File/Models/ListSharesOptions.php b/src/File/Models/ListSharesOptions.php index bad0a62..fcfb8a0 100644 --- a/src/File/Models/ListSharesOptions.php +++ b/src/File/Models/ListSharesOptions.php @@ -25,8 +25,7 @@ namespace MicrosoftAzure\Storage\File\Models; use MicrosoftAzure\Storage\File\Models\FileServiceOptions; -use MicrosoftAzure\Storage\File\Models\FileContinuationToken; -use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; use MicrosoftAzure\Storage\Common\Internal\Validate; /** @@ -41,7 +40,7 @@ use MicrosoftAzure\Storage\Common\Internal\Validate; */ class ListSharesOptions extends FileServiceOptions { - use FileContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $prefix; private $maxResults; diff --git a/src/File/Models/ListSharesResult.php b/src/File/Models/ListSharesResult.php index 0a28bee..8715b70 100644 --- a/src/File/Models/ListSharesResult.php +++ b/src/File/Models/ListSharesResult.php @@ -27,8 +27,8 @@ namespace MicrosoftAzure\Storage\File\Models; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Internal\Utilities; use MicrosoftAzure\Storage\File\Models\Share; -use MicrosoftAzure\Storage\File\Models\FileContinuationToken; -use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; /** * Share to hold list Share response object. @@ -42,7 +42,7 @@ use MicrosoftAzure\Storage\File\Models\FileContinuationTokenTrait; */ class ListSharesResult { - use FileContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $shares; private $prefix; @@ -80,15 +80,21 @@ class ListSharesResult $parsedResponse, Resources::QP_MARKER )); - $result->setContinuationToken( - new FileContinuationToken( - Utilities::tryGetValue( - $parsedResponse, - Resources::QP_NEXT_MARKER - ), - $location - ) + + $nextMarker = Utilities::tryGetValue( + $parsedResponse, + Resources::QP_NEXT_MARKER ); + + if ($nextMarker != null) { + $result->setContinuationToken( + new MarkerContinuationToken( + $nextMarker, + $location + ) + ); + } + $result->setMaxResults(Utilities::tryGetValue( $parsedResponse, Resources::QP_MAX_RESULTS diff --git a/src/Queue/Models/ListQueuesOptions.php b/src/Queue/Models/ListQueuesOptions.php index 938ba7d..086dfde 100644 --- a/src/Queue/Models/ListQueuesOptions.php +++ b/src/Queue/Models/ListQueuesOptions.php @@ -25,8 +25,7 @@ namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Queue\Models\QueueServiceOptions; -use MicrosoftAzure\Storage\Queue\Models\QueueContinuationToken; -use MicrosoftAzure\Storage\Queue\Models\QueueContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; use MicrosoftAzure\Storage\Common\Internal\Validate; /** @@ -41,7 +40,7 @@ use MicrosoftAzure\Storage\Common\Internal\Validate; */ class ListQueuesOptions extends QueueServiceOptions { - use QueueContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_prefix; private $_maxResults; diff --git a/src/Queue/Models/ListQueuesResult.php b/src/Queue/Models/ListQueuesResult.php index 132676c..039b242 100644 --- a/src/Queue/Models/ListQueuesResult.php +++ b/src/Queue/Models/ListQueuesResult.php @@ -26,8 +26,8 @@ namespace MicrosoftAzure\Storage\Queue\Models; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Queue\Models\Queue; -use MicrosoftAzure\Storage\Queue\Models\QueueContinuationToken; -use MicrosoftAzure\Storage\Queue\Models\QueueContinuationTokenTrait; +use MicrosoftAzure\Storage\Common\Models\MarkerContinuationToken; +use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; use MicrosoftAzure\Storage\Common\Internal\Utilities; /** @@ -42,7 +42,7 @@ use MicrosoftAzure\Storage\Common\Internal\Utilities; */ class ListQueuesResult { - use QueueContinuationTokenTrait; + use MarkerContinuationTokenTrait; private $_queues; private $_prefix; @@ -80,15 +80,18 @@ class ListQueuesResult $parsedResponse, Resources::QP_MARKER )); - $result->setContinuationToken( - new QueueContinuationToken( - Utilities::tryGetValue( - $parsedResponse, - Resources::QP_NEXT_MARKER - ), - $location - ) - ); + + $nextMarker = Utilities::tryGetValue($parsedResponse, Resources::QP_NEXT_MARKER); + + if ($nextMarker != null) { + $result->setContinuationToken( + new MarkerContinuationToken( + $nextMarker, + $location + ) + ); + } + $result->setMaxResults(Utilities::tryGetValue( $parsedResponse, Resources::QP_MAX_RESULTS diff --git a/src/Queue/Models/QueueContinuationToken.php b/src/Queue/Models/QueueContinuationToken.php deleted file mode 100644 index 2866f93..0000000 --- a/src/Queue/Models/QueueContinuationToken.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ - -namespace MicrosoftAzure\Storage\Queue\Models; - -use MicrosoftAzure\Storage\Common\Internal\Validate; -use MicrosoftAzure\Storage\Common\Models\ContinuationToken; - -/** - * Provides functionality and data structure for queue continuation token. - * - * @category Microsoft - * @package MicrosoftAzure\Storage\Queue\Models - * @author Azure Storage PHP SDK - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ -class QueueContinuationToken extends ContinuationToken -{ - private $nextMarker; - - public function __construct( - $nextMarker = '', - $location = '' - ) { - parent::__construct($location); - $this->setNextMarker($nextMarker); - } - - /** - * Setter for nextMarker - * - * @param string $nextMarker the next marker to be set. - */ - public function setNextMarker($nextMarker) - { - Validate::canCastAsString($nextMarker, 'nextMarker'); - $this->nextMarker = $nextMarker; - } - - /** - * Getter for nextMarker - * - * @return string - */ - public function getNextMarker() - { - return $this->nextMarker; - } -} diff --git a/src/Queue/Models/QueueContinuationTokenTrait.php b/src/Queue/Models/QueueContinuationTokenTrait.php deleted file mode 100644 index 29943f7..0000000 --- a/src/Queue/Models/QueueContinuationTokenTrait.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ - -namespace MicrosoftAzure\Storage\Queue\Models; - -use MicrosoftAzure\Storage\Common\MarkerContinuationTokenTrait; -use MicrosoftAzure\Storage\Queue\Models\QueueContinuationToken; - -/** - * Trait implementing logic for Queue continuation tokens. - * - * @category Microsoft - * @package MicrosoftAzure\Storage\Queue\Models - * @author Azure Storage PHP SDK - * @copyright 2017 Microsoft Corporation - * @license https://github.com/azure/azure-storage-php/LICENSE - * @link https://github.com/azure/azure-storage-php - */ -trait QueueContinuationTokenTrait -{ - use MarkerContinuationTokenTrait; - - /** - * Creates a continuation token if current one is null. - * - * @return void - */ - private function createContinuationTokenIfNotExist() - { - if ($this->continuationToken == null) { - $this->continuationToken = new QueueContinuationToken(); - } - } -} diff --git a/src/Table/Models/QueryEntitiesResult.php b/src/Table/Models/QueryEntitiesResult.php index a72031c..57ff83f 100644 --- a/src/Table/Models/QueryEntitiesResult.php +++ b/src/Table/Models/QueryEntitiesResult.php @@ -68,14 +68,16 @@ class QueryEntitiesResult Resources::X_MS_CONTINUATION_NEXTROWKEY ); - $result->setContinuationToken( - new TableContinuationToken( - '', - $nextPK, - $nextRK, - Utilities::getLocationFromHeaders($headers) - ) - ); + if ($nextRK != null && $nextPK != null) { + $result->setContinuationToken( + new TableContinuationToken( + '', + $nextPK, + $nextRK, + Utilities::getLocationFromHeaders($headers) + ) + ); + } $result->setEntities($entities); diff --git a/src/Table/Models/QueryTablesResult.php b/src/Table/Models/QueryTablesResult.php index 3a86f07..7c44783 100644 --- a/src/Table/Models/QueryTablesResult.php +++ b/src/Table/Models/QueryTablesResult.php @@ -62,17 +62,21 @@ class QueryTablesResult $result->setTables($entries); - $result->setContinuationToken( - new TableContinuationToken( - Utilities::tryGetValue( - $headers, - Resources::X_MS_CONTINUATION_NEXTTABLENAME - ), - '', - '', - Utilities::getLocationFromHeaders($headers) - ) + $nextTableName = Utilities::tryGetValue( + $headers, + Resources::X_MS_CONTINUATION_NEXTTABLENAME ); + + if ($nextTableName != null) { + $result->setContinuationToken( + new TableContinuationToken( + $nextTableName, + '', + '', + Utilities::getLocationFromHeaders($headers) + ) + ); + } return $result; } diff --git a/src/Table/Models/TableContinuationTokenTrait.php b/src/Table/Models/TableContinuationTokenTrait.php index 4970be7..8ed07c1 100644 --- a/src/Table/Models/TableContinuationTokenTrait.php +++ b/src/Table/Models/TableContinuationTokenTrait.php @@ -69,7 +69,7 @@ trait TableContinuationTokenTrait public function getLocation() { if ($this->continuationToken == null) { - $this->setContinuationToken(new TableContinuationToken()); + return null; } return $this->continuationToken->getLocation(); } @@ -77,9 +77,8 @@ trait TableContinuationTokenTrait public function getLocationMode() { if ($this->continuationToken == null) { - $this->setContinuationToken(new TableContinuationToken()); - } - if ($this->continuationToken->getLocation() == '') { + return parent::getLocationMode(); + } elseif ($this->continuationToken->getLocation() == '') { return parent::getLocationMode(); } else { return $this->getLocation(); @@ -94,7 +93,7 @@ trait TableContinuationTokenTrait public function getNextTableName() { if ($this->continuationToken == null) { - $this->setContinuationToken(new TableContinuationToken()); + return null; } return $this->continuationToken->getNextTableName(); } @@ -107,7 +106,7 @@ trait TableContinuationTokenTrait public function getNextPartitionKey() { if ($this->continuationToken == null) { - $this->setContinuationToken(new TableContinuationToken()); + return null; } return $this->continuationToken->getNextPartitionKey(); } @@ -120,7 +119,7 @@ trait TableContinuationTokenTrait public function getNextRowKey() { if ($this->continuationToken == null) { - $this->setContinuationToken(new TableContinuationToken()); + return null; } return $this->continuationToken->getNextRowKey(); } diff --git a/tests/framework/TestResources.php b/tests/framework/TestResources.php index 0ef6fad..f5bba20 100644 --- a/tests/framework/TestResources.php +++ b/tests/framework/TestResources.php @@ -1233,7 +1233,7 @@ class TestResources ) ); - $sample['NextMarker'] = ''; + $sample['NextMarker'] = 'abcdefg'; return $sample; } From b96bdbb99db08a4f37a68a4d176f617c5c5d7e3b Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Thu, 6 Jul 2017 16:19:56 +0800 Subject: [PATCH 5/7] Added support for large block blob --- ChangeLog.md | 1 + src/Blob/BlobRestProxy.php | 217 ++++++++++++++++++-------- src/Common/Internal/Resources.php | 6 + src/Common/Internal/Utilities.php | 10 ++ tests/unit/Blob/BlobRestProxyTest.php | 139 ++++++++++++++--- 5 files changed, 281 insertions(+), 92 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 9b29aa3..0e56003 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,7 @@ All Blob * Removed `MicrosoftAzure\Storage\Tests\unit\Blob\Models\BlobContinuationToken`, now use `MicrosoftAzure\Storage\Common\MarkerContinuationToken` instead for better code structure and reuse. +* Added `MicrosoftAzure\Storage\Tests\unit\Blob\BlobRestProxy::blockSize` for user to control block size. Table * Deprecated ATOM support for Table service. diff --git a/src/Blob/BlobRestProxy.php b/src/Blob/BlobRestProxy.php index 2487120..56736f4 100644 --- a/src/Blob/BlobRestProxy.php +++ b/src/Blob/BlobRestProxy.php @@ -96,7 +96,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob { use ServiceRestTrait; - private $_SingleBlobUploadThresholdInBytes = Resources::MB_IN_BYTES_32; + private $singleBlobUploadThresholdInBytes = Resources::MB_IN_BYTES_32; + private $blockSize = Resources::MB_IN_BYTES_4; /** * Get the value for SingleBlobUploadThresholdInBytes @@ -105,7 +106,17 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob */ public function getSingleBlobUploadThresholdInBytes() { - return $this->_SingleBlobUploadThresholdInBytes; + return $this->singleBlobUploadThresholdInBytes; + } + + /** + * Get the value for blockSize + * + * @return int + */ + public function getBlockSize() + { + return $this->blockSize; } /** @@ -117,14 +128,81 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob */ public function setSingleBlobUploadThresholdInBytes($val) { - if ($val > Resources::MB_IN_BYTES_64) { + if ($val > Resources::MB_IN_BYTES_256) { // What should the proper action here be? - $val = Resources::MB_IN_BYTES_64; + $val = Resources::MB_IN_BYTES_256; } elseif ($val < 1) { // another spot that could use looking at $val = Resources::MB_IN_BYTES_32; } - $this->_SingleBlobUploadThresholdInBytes = $val; + $this->singleBlobUploadThresholdInBytes = $val; + //If block size is larger than singleBlobUploadThresholdInBytes, honor + //threshold. + $this->blockSize = $val > $this->blockSize ? $this->blockSize : $val; + } + + /** + * Set the value for block size, Max 100MB + * + * @param int $val The max size for each block to be sent. + * + * @return void + */ + public function setBlockSize($val) + { + if ($val > Resources::MB_IN_BYTES_100) { + // What should the proper action here be? + $val = Resources::MB_IN_BYTES_100; + } elseif ($val < 1) { + // another spot that could use looking at + $val = Resources::MB_IN_BYTES_4; + } + //If block size is larger than singleBlobUploadThresholdInBytes, honor + //threshold. + $val = $val > $this->singleBlobUploadThresholdInBytes ? + $this->singleBlobUploadThresholdInBytes : $val; + $this->blockSize = $val; + } + + /** + * Get the block size of multiple upload block size using the provided + * content + * + * @param StreamInterface $content The content of the blocks. + * + * @return int + */ + private function getMultipleUploadBlockSizeUsingContent($content) + { + //Default value is 100 MB. + $result = Resources::MB_IN_BYTES_100; + //PHP must be ran in 64bit environment so content->getSize() could + //return a guaranteed accurate size. + if (Utilities::is64BitPHP()) { + //Content must be seekable to determine the size. + if ($content->isSeekable()) { + $size = $content->getSize(); + //When threshold is lower than 100MB, assume maximum number of + //block is used for the block blob, if the blockSize is still + //smaller than the assumed size, it means assumed size should + //be hornored, otherwise the blocks count will exceed maximum + //value allowed. + if ($this->blockSize < $result) { + $assumedSize = ceil((float)$size / + (float)(Resources::MAX_BLOB_BLOCKS)); + if ($this->blockSize <= $assumedSize) { + $result = $assumedSize; + } else { + $result = $this->blockSize; + } + } + } + } else { + // If not, we could only honor user's setting to determine + // chunk size. + $result = $this->blockSize; + } + return $result; } /** @@ -136,12 +214,12 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return string */ - private function _getCopyBlobSourceName( + private function getCopyBlobSourceName( $containerName, $blobName, Models\CopyBlobOptions $options ) { - $sourceName = $this->_getBlobUrl($containerName, $blobName); + $sourceName = $this->getBlobUrl($containerName, $blobName); if (!is_null($options->getSourceSnapshot())) { $sourceName .= '?snapshot=' . $options->getSourceSnapshot(); @@ -158,7 +236,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return string */ - private function _createPath($container, $blob = '') + private function createPath($container, $blob = '') { if (empty($blob)) { if (!empty($container)) { @@ -191,9 +269,9 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return string */ - private function _getBlobUrl($container, $blob) + private function getBlobUrl($container, $blob) { - $encodedBlob = $this->_createPath($container, $blob); + $encodedBlob = $this->createPath($container, $blob); return (string)($this->getPsrPrimaryUri()->withPath($encodedBlob)); } @@ -208,7 +286,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return \GuzzleHttp\Promise\PromiseInterface */ - private function _getContainerPropertiesAsyncImpl( + private function getContainerPropertiesAsyncImpl( $container, Models\BlobServiceOptions $options = null, $operation = null @@ -219,7 +297,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $queryParams = array(); $postParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); if (is_null($options)) { $options = new BlobServiceOptions(); @@ -269,7 +347,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return array */ - private function _addCreateBlobOptionalHeaders( + private function addCreateBlobOptionalHeaders( CreateBlobOptions $options, array $headers ) { @@ -342,7 +420,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return array */ - private function _addOptionalRangeHeader(array $headers, $start, $end) + private function ddOptionalRangeHeader(array $headers, $start, $end) { if (!is_null($start) || !is_null($end)) { $range = $start . '-' . $end; @@ -396,7 +474,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return \GuzzleHttp\Promise\PromiseInterface */ - private function _putLeaseAsyncImpl( + private function putLeaseAsyncImpl( $leaseAction, $container, $blob, @@ -419,14 +497,14 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $path; if (empty($blob)) { - $path = $this->_createPath($container); + $path = $this->createPath($container); $this->addOptionalQueryParam( $queryParams, Resources::QP_REST_TYPE, 'container' ); } else { - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); } $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'lease'); $this->addOptionalQueryParam( @@ -488,7 +566,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @return \GuzzleHttp\Promise\PromiseInterface */ - private function _updatePageBlobPagesAsyncImpl( + private function updatePageBlobPagesAsyncImpl( $action, $container, $blob, @@ -514,13 +592,13 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $queryParams = array(); $postParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new CreateBlobPagesOptions(); } - $headers = $this->_addOptionalRangeHeader( + $headers = $this->ddOptionalRangeHeader( $headers, $range->getStart(), $range->getEnd() @@ -692,7 +770,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(Resources::QP_REST_TYPE => 'container'); - $path = $this->_createPath($container); + $path = $this->createPath($container); if (is_null($options)) { $options = new CreateContainerOptions(); @@ -756,7 +834,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); if (is_null($options)) { $options = new BlobServiceOptions(); @@ -823,7 +901,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\BlobServiceOptions $options = null ) { - return $this->_getContainerPropertiesAsyncImpl($container, $options); + return $this->getContainerPropertiesAsyncImpl($container, $options); } /** @@ -858,7 +936,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $container, Models\BlobServiceOptions $options = null ) { - return $this->_getContainerPropertiesAsyncImpl($container, $options, 'metadata'); + return $this->getContainerPropertiesAsyncImpl($container, $options, 'metadata'); } /** @@ -900,7 +978,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); $statusCode = Resources::STATUS_OK; if (is_null($options)) { @@ -1008,7 +1086,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); $body = $acl->toXml($this->dataSerializer); if (is_null($options)) { @@ -1101,7 +1179,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = $this->generateMetadataHeaders($metadata); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); if (is_null($options)) { $options = new BlobServiceOptions(); @@ -1179,7 +1257,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container); + $path = $this->createPath($container); if (is_null($options)) { $options = new ListBlobsOptions(); @@ -1322,7 +1400,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $statusCode = Resources::STATUS_CREATED; if (is_null($options)) { @@ -1344,7 +1422,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Resources::X_MS_BLOB_SEQUENCE_NUMBER, $options->getSequenceNumber() ); - $headers = $this->_addCreateBlobOptionalHeaders($options, $headers); + $headers = $this->addCreateBlobOptionalHeaders($options, $headers); $options->setLocationMode(LocationMode::PRIMARY_ONLY); @@ -1414,7 +1492,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $statusCode = Resources::STATUS_CREATED; if (is_null($options)) { @@ -1426,7 +1504,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Resources::X_MS_BLOB_TYPE, BlobType::APPEND_BLOB ); - $headers = $this->_addCreateBlobOptionalHeaders($options, $headers); + $headers = $this->addCreateBlobOptionalHeaders($options, $headers); $options->setLocationMode(LocationMode::PRIMARY_ONLY); @@ -1511,7 +1589,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $promise = null; if (!Utilities::isStreamLargerThanSizeOrNotSeekable( $body, - $this->_SingleBlobUploadThresholdInBytes + $this->singleBlobUploadThresholdInBytes )) { $promise = $this->createBlockBlobBySingleUploadAsync( $container, @@ -1672,14 +1750,13 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new CreateBlobOptions(); } - - $headers = $this->_addCreateBlobOptionalHeaders($options, $headers); + $headers = $this->addCreateBlobOptionalHeaders($options, $headers); $this->addOptionalHeader( $headers, @@ -1729,6 +1806,13 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Validate::canCastAsString($container, 'container'); Validate::canCastAsString($blob, 'blob'); + if ($content->isSeekable() && Utilities::is64BitPHP()) { + Validate::isTrue( + $content->getSize() <= Resources::MAX_BLOCK_BLOB_SIZE, + Resources::CONTENT_SIZE_TOO_LARGE + ); + } + if (is_null($options)) { $options = new CreateBlobOptions(); } @@ -1739,14 +1823,11 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $method = Resources::HTTP_PUT; $headers = $this->createBlobBlockHeader($createBlobBlockOptions); $postParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $blockIds = array(); - // if threshold is lower than 4mb, honor threshold, else use 4mb - $blockSize = ( - $this->_SingleBlobUploadThresholdInBytes - < Resources::MB_IN_BYTES_4) ? - $this->_SingleBlobUploadThresholdInBytes : Resources::MB_IN_BYTES_4; + //Determine the block size according to the content and threshold. + $blockSize = $this->getMultipleUploadBlockSizeUsingContent($content); $counter = 0; //create the generator for requests. //this generator also constructs the blockId array on the fly. @@ -1854,7 +1935,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $method = Resources::HTTP_PUT; $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'page'); $this->addOptionalQueryParam( @@ -1898,7 +1979,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob } while (Utilities::allZero($pageContent)); $headers = array(); - $headers = $this->_addOptionalRangeHeader( + $headers = $this->ddOptionalRangeHeader( $headers, $start, $end @@ -1992,7 +2073,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob Range $range, Models\CreateBlobPagesOptions $options = null ) { - return $this->_updatePageBlobPagesAsyncImpl( + return $this->updatePageBlobPagesAsyncImpl( PageWriteOption::CLEAR_OPTION, $container, $blob, @@ -2068,7 +2149,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob throw new \RuntimeException(Resources::ERROR_RANGE_NOT_ALIGN_TO_512); } - return $this->_updatePageBlobPagesAsyncImpl( + return $this->updatePageBlobPagesAsyncImpl( PageWriteOption::UPDATE_OPTION, $container, $blob, @@ -2155,7 +2236,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = $this->createBlobBlockHeader($options); $postParams = array(); $queryParams = $this->createBlobBlockQueryParams($options, $blockId); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $statusCode = Resources::STATUS_CREATED; $contentStream = Psr7\stream_for($content); $body = $contentStream->getContents(); @@ -2236,7 +2317,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $statusCode = Resources::STATUS_CREATED; $contentStream = Psr7\stream_for($content); @@ -2441,7 +2522,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); $isArray = is_array($blockList); $blockList = $isArray ? BlockList::create($blockList) : $blockList; $body = $blockList->toXml($this->dataSerializer); @@ -2591,7 +2672,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new ListBlobBlocksOptions(); @@ -2685,7 +2766,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new GetBlobPropertiesOptions(); @@ -2765,7 +2846,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new GetBlobMetadataOptions(); @@ -2857,7 +2938,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $queryParams = array(); $postParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new ListPageBlobRangesOptions(); @@ -2868,7 +2949,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $options->getAccessConditions() ); - $headers = $this->_addOptionalRangeHeader( + $headers = $this->ddOptionalRangeHeader( $headers, $options->getRangeStart(), $options->getRangeEnd() @@ -2957,7 +3038,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new SetBlobPropertiesOptions(); @@ -3103,7 +3184,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new BlobServiceOptions(); @@ -3259,7 +3340,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new GetBlobOptions(); @@ -3270,7 +3351,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers, $options->getAccessConditions() ); - $headers = $this->_addOptionalRangeHeader( + $headers = $this->ddOptionalRangeHeader( $headers, $options->getRangeStart(), $options->getRangeEnd() @@ -3367,7 +3448,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new DeleteBlobOptions(); @@ -3460,7 +3541,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $path = $this->_createPath($container, $blob); + $path = $this->createPath($container, $blob); if (is_null($options)) { $options = new CreateBlobSnapshotOptions(); @@ -3559,7 +3640,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $destinationBlobPath = $this->_createPath( + $destinationBlobPath = $this->createPath( $destinationContainer, $destinationBlob ); @@ -3568,7 +3649,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $options = new CopyBlobOptions(); } - $sourceBlobPath = $this->_getCopyBlobSourceName( + $sourceBlobPath = $this->getCopyBlobSourceName( $sourceContainer, $sourceBlob, $options @@ -3677,7 +3758,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $headers = array(); $postParams = array(); $queryParams = array(); - $destinationBlobPath = $this->_createPath( + $destinationBlobPath = $this->createPath( $container, $blob ); @@ -3791,7 +3872,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $leaseDuration = -1; } - return $this->_putLeaseAsyncImpl( + return $this->putLeaseAsyncImpl( LeaseMode::ACQUIRE_ACTION, $container, $blob, @@ -3858,7 +3939,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $proposedLeaseId, Models\BlobServiceOptions $options = null ) { - return $this->_putLeaseAsyncImpl( + return $this->putLeaseAsyncImpl( LeaseMode::CHANGE_ACTION, $container, $blob, @@ -3919,7 +4000,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $leaseId, Models\BlobServiceOptions $options = null ) { - return $this->_putLeaseAsyncImpl( + return $this->putLeaseAsyncImpl( LeaseMode::RENEW_ACTION, $container, $blob, @@ -3977,7 +4058,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $leaseId, Models\BlobServiceOptions $options = null ) { - return $this->_putLeaseAsyncImpl( + return $this->putLeaseAsyncImpl( LeaseMode::RELEASE_ACTION, $container, $blob, @@ -4036,7 +4117,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob $breakPeriod = null, Models\BlobServiceOptions $options = null ) { - return $this->_putLeaseAsyncImpl( + return $this->putLeaseAsyncImpl( LeaseMode::BREAK_ACTION, $container, $blob, diff --git a/src/Common/Internal/Resources.php b/src/Common/Internal/Resources.php index e60aece..b428c10 100644 --- a/src/Common/Internal/Resources.php +++ b/src/Common/Internal/Resources.php @@ -142,6 +142,7 @@ class Resources const INVALID_ACCEPT_CONTENT_TYPE = "The given accept content type is not valid."; const ERROR_CANNOT_PARSE_XML = "Cannot parse XML, reasons: %s"; const INVALID_SCHEME = 'HTTP scheme can only be string \'http\' or \'https\'.'; + const CONTENT_SIZE_TOO_LARGE = 'The content is too large for the selected blob type.'; // HTTP Headers const X_MS_HEADER_PREFIX = 'x-ms-'; @@ -280,8 +281,13 @@ class Resources const MB_IN_BYTES_4 = 4194304; const MB_IN_BYTES_32 = 33554432; const MB_IN_BYTES_64 = 67108864; + const MB_IN_BYTES_128 = 134217728; + const MB_IN_BYTES_256 = 268435456; + const MB_IN_BYTES_100 = 104857600; const GB_IN_BYTES = 1073741824; + const GB_IN_BYTES_200 = 214748364800; const MAX_BLOB_BLOCKS = 50000; + const MAX_BLOCK_BLOB_SIZE = 5242880000000; const RETURN_CONTENT = 'return-content'; // Xml Namespaces diff --git a/src/Common/Internal/Utilities.php b/src/Common/Internal/Utilities.php index a551290..b5a4125 100644 --- a/src/Common/Internal/Utilities.php +++ b/src/Common/Internal/Utilities.php @@ -866,4 +866,14 @@ class Utilities return base64_encode(md5($content, true)); } + + /** + * Return if the environment is in 64 bit PHP. + * + * @return bool + */ + public static function is64BitPHP() + { + return PHP_INT_SIZE == 8; + } } diff --git a/tests/unit/Blob/BlobRestProxyTest.php b/tests/unit/Blob/BlobRestProxyTest.php index e28c3fa..580a760 100644 --- a/tests/unit/Blob/BlobRestProxyTest.php +++ b/tests/unit/Blob/BlobRestProxyTest.php @@ -1901,25 +1901,25 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase { // Values based on http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblobclient.singleblobuploadthresholdinbytes.aspx // Read initial value - $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), 33554432); + $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), Resources::MB_IN_BYTES_32); // Change value $this->restProxy->setSingleBlobUploadThresholdInBytes(50); $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), 50); // Test over limit - $this->restProxy->setSingleBlobUploadThresholdInBytes(65*1024*1024); - // Should be truncated to 64M - $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), 67108864); + $this->restProxy->setSingleBlobUploadThresholdInBytes(257*1024*1024); + // Should be truncated to 256MB + $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), Resources::MB_IN_BYTES_256); // Under limit $this->restProxy->setSingleBlobUploadThresholdInBytes(-50); // value can not be less than 1, so reset to default value - $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), 33554432); + $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), Resources::MB_IN_BYTES_32); $this->restProxy->setSingleBlobUploadThresholdInBytes(0); // value can not be less than 1, so reset to default value - $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), 33554432); + $this->assertEquals($this->restProxy->getSingleBlobUploadThresholdInBytes(), Resources::MB_IN_BYTES_32); } /** @@ -1965,18 +1965,6 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase // so relying on content size to be final approval $this->assertEquals(count($blocks), 0); $this->assertEquals($result->getContentLength(), strlen($content)); - - // make string even larger for automagic splitting - // This should result in a string longer than 32M, and force the blob into 2 blocks - for ($i = 0; $i < 15; $i++) { - $content .= $content; - } - $this->restProxy->createBlockBlob($name, 'bigsplit', $content, $options); - $result = $this->restProxy->listBlobBlocks($name, 'bigsplit', $boptions); - $blocks = $result->getUnCommittedBlocks(); - $this->assertEquals(count($blocks), 0); - $blocks = $result->getCommittedBlocks(); - $this->assertEquals(count($blocks), ceil(strlen($content)/(4*1024*1024))); } /** @@ -2060,7 +2048,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob */ - public function testPutGetLargeBlockBlob() + public function testPutGet2GBBlockBlob() { // Setup //create a temp file that is 2GB in size. @@ -2125,6 +2113,79 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase unlink($downloadPath); } + /** + * @group large-scale + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + */ + public function testPutGet5TBBlockBlob() + { + // Initial check for the environment. + // Does disk have enough space. + $this->assertTrue(disk_free_space('.') > (2 * Resources::TB_IN_BYTES_5)); + // Setup + //create a temp file that is 5TB in size. + $cwd = getcwd(); + $uuid = uniqid('test-file-', true); + $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; + $resource = fopen($path, 'w+'); + $count = 50000 * 100 / 64; + for ($index = 0; $index < $count; ++$index) { + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_64)); + } + rewind($resource); + //upload the blob + $name = 'getblob' . $this->createSuffix(); + $blob = 'myblob'; + $metadata = array('m1' => 'v1', 'm2' => 'v2'); + $contentType = 'text/plain; charset=UTF-8'; + $this->createContainer($name); + $options = new CreateBlobOptions(); + $options->setContentType($contentType); + $options->setMetadata($metadata); + $this->restProxy->createBlockBlob( + $name, + $blob, + $resource, + $options + ); + + // Test + $result = $this->restProxy->getBlob($name, $blob); + + //get the path for the file to be downloaded into. + $uuid = uniqid('test-file-', true); + $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; + $downloadResource = fopen($downloadPath, 'w'); + //download the file + $content = $result->getContentStream(); + + while (!feof($content)) { + fwrite( + $downloadResource, + stream_get_contents($content, Resources::MB_IN_BYTES_4) + ); + } + + // Assert + $this->assertEquals( + BlobType::BLOCK_BLOB, + $result->getProperties()->getBlobType() + ); + $this->assertEquals($metadata, $result->getMetadata()); + $originMd5 = md5_file($path); + $downloadMd5 = md5_file($downloadPath); + $this->assertEquals($originMd5, $downloadMd5); + + //clean-up. + if (is_resource($resource)) { + fclose($resource); + } + fclose($downloadResource); + unlink($path); + unlink($downloadPath); + } + /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob @@ -2198,7 +2259,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase public function testPutGet33MBBlockBlob() { // Setup - //create a temp file that is 32 in size. + //create a temp file that is 33 in size. $cwd = getcwd(); $uuid = uniqid('test-file-', true); $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; @@ -2265,12 +2326,13 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase public function testPutGet64MBBlockBlob() { // Setup - //create a temp file that is 32 in size. + //create a temp file that is 64 in size. $cwd = getcwd(); $uuid = uniqid('test-file-', true); $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); rewind($resource); //upload the blob $name = 'getblob' . $this->createSuffix(); @@ -2333,12 +2395,13 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase public function testPutGet65MBBlockBlob() { // Setup - //create a temp file that is 32 in size. + //create a temp file that is 65 in size. $cwd = getcwd(); $uuid = uniqid('test-file-', true); $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_64)); + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_1)); rewind($resource); //upload the blob @@ -2395,6 +2458,34 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase unlink($downloadPath); } + /** + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + */ + public function testPutGetBlockBlobWith5MBBlocks() + { + // Setup + $content = openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_64); + //upload the blob + $name = 'getblob' . $this->createSuffix(); + $blob = 'myblob'; + $this->createContainer($name); + $this->restProxy->setBlockSize(Resources::MB_IN_BYTES_1 * 5); + $this->restProxy->createBlockBlob( + $name, + $blob, + $content + ); + + //Get the committed blocks count. + $options = new ListBlobBlocksOptions(); + $options->setIncludeCommittedBlobs(true); + + $result = $this->restProxy->listBlobBlocks($name, $blob, $options); + + $this->assertEquals(13, \count($result->getCommittedBlocks())); + } + /** * @group large-scale * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob From b3c5f7ae5144e1fadd59e98ec750c5d0cd05e77a Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Wed, 12 Jul 2017 09:44:44 +0800 Subject: [PATCH 6/7] Refine test code for better coverage and structure. --- src/Blob/BlobRestProxy.php | 30 +- src/Blob/Internal/IBlob.php | 18 +- src/Blob/Models/AppendBlockOptions.php | 18 +- src/Blob/Models/BlockList.php | 10 +- src/Blob/Models/LeaseResult.php | 6 +- src/Blob/Models/ListBlobBlocksResult.php | 42 +- .../Internal/Serialization/XmlSerializer.php | 16 +- .../Blob/BlobServiceFunctionalTest.php | 520 ++++++++++- .../Blob/BlobServiceFunctionalTestData.php | 150 ++- .../Queue/QueueServiceFunctionalTest.php | 174 ++-- .../Table/TableServiceFunctionalTest.php | 225 +++-- tests/unit/Blob/BlobRestProxyTest.php | 858 +++--------------- .../Blob/Models/ListBlobBlocksResultTest.php | 2 +- 13 files changed, 1091 insertions(+), 978 deletions(-) diff --git a/src/Blob/BlobRestProxy.php b/src/Blob/BlobRestProxy.php index 56736f4..048f936 100644 --- a/src/Blob/BlobRestProxy.php +++ b/src/Blob/BlobRestProxy.php @@ -120,7 +120,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob } /** - * Set the value for SingleBlobUploadThresholdInBytes, Max 64MB + * Set the value for SingleBlobUploadThresholdInBytes, Max 256MB * * @param int $val The max size to send as a single blob block * @@ -560,7 +560,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * @param string $action Either clear or create. * @param string $container The container name. * @param string $blob The blob name. - * @param Range $range The page ranges. + * @param Range $range The page ranges. * @param string $content The content string. * @param CreateBlobPagesOptions $options The optional parameters. * @@ -2459,7 +2459,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @param string $container The container name. * @param string $blob The blob name. - * @param Models\BlockList|array $blockList The block entries. + * @param Models\BlockList|Block[] $blockList The block entries. * @param Models\CommitBlobBlocksOptions $options The optional parameters. * * @return Models\PutBlobResult @@ -2493,7 +2493,7 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * * @param string $container The container name. * @param string $blob The blob name. - * @param Models\BlockList|array $blockList The block entries. + * @param Models\BlockList|Block[] $blockList The block entries. * @param Models\CommitBlobBlocksOptions $options The optional parameters. * * @return \GuzzleHttp\Promise\PromiseInterface @@ -3816,9 +3816,12 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * @param string $container name of the container * @param string $blob name of the blob * @param string $proposedLeaseId lease id when acquiring - * @param int $leaseDuration the lease duration. A non-infinite - * lease can be between 15 and 60 seconds. - * Default is never to expire. + * @param int $leaseDuration the lease duration. + * A non-infinite + * lease can be between + * 15 and 60 seconds. + * Default is never + * to expire. * @param Models\BlobServiceOptions $options optional parameters * * @return Models\LeaseResult @@ -3848,9 +3851,12 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob * @param string $container name of the container * @param string $blob name of the blob * @param string $proposedLeaseId lease id when acquiring - * @param int $leaseDuration the lease duration. A non-infinite - * lease can be between 15 and 60 seconds. - * Default is never to expire. + * @param int $leaseDuration the lease duration. + * A non-infinite + * lease can be between + * 15 and 60 seconds. + * Default is never to + * expire. * @param Models\BlobServiceOptions $options optional parameters * * @return \GuzzleHttp\Promise\PromiseInterface @@ -4171,8 +4177,8 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob /** * Adds optional header to headers if set * - * @param array $headers The array of request headers. - * @param array $accessCondition The access condition object. + * @param array $headers The array of request headers. + * @param array $accessCondition The access condition object. * * @return array */ diff --git a/src/Blob/Internal/IBlob.php b/src/Blob/Internal/IBlob.php index 72bdcbb..8cf605d 100644 --- a/src/Blob/Internal/IBlob.php +++ b/src/Blob/Internal/IBlob.php @@ -762,10 +762,10 @@ interface IBlob * block list or from the uncommitted block list, or to commit the most recently * uploaded version of the block, whichever list it may belong to. * - * @param string $container name of the container - * @param string $blob name of the blob - * @param BlobModels\BlockList|array $blockList the block list entries - * @param BlobModels\CommitBlobBlocksOptions $options optional parameters + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\BlockList|BlobModels\Block[] $blockList the block list entries + * @param BlobModels\CommitBlobBlocksOptions $options optional parameters * * @return BlobModels\PutBlobResult * @@ -789,11 +789,11 @@ interface IBlob * block list or from the uncommitted block list, or to commit the most recently * uploaded version of the block, whichever list it may belong to. * - * @param string $container The container name. - * @param string $blob The blob name. - * @param BlobModels\BlockList|array $blockList The block entries. - * @param BlobModels\CommitBlobBlocksOptions $options The optional - * parameters. + * @param string $container name of the container + * @param string $blob name of the blob + * @param BlobModels\BlockList|BlobModels\Block[] $blockList the block list + * entries + * @param BlobModels\CommitBlobBlocksOptions $options optional parameters * * @return \GuzzleHttp\Promise\PromiseInterface * diff --git a/src/Blob/Models/AppendBlockOptions.php b/src/Blob/Models/AppendBlockOptions.php index 8091dbb..087b751 100644 --- a/src/Blob/Models/AppendBlockOptions.php +++ b/src/Blob/Models/AppendBlockOptions.php @@ -36,9 +36,9 @@ namespace MicrosoftAzure\Storage\Blob\Models; */ class AppendBlockOptions extends BlobServiceOptions { - private $_contentMD5; - private $_maxBlobSize; - private $_appendPosition; + private $contentMD5; + private $maxBlobSize; + private $appendPosition; /** * Gets block contentMD5. @@ -47,7 +47,7 @@ class AppendBlockOptions extends BlobServiceOptions */ public function getContentMD5() { - return $this->_contentMD5; + return $this->contentMD5; } /** @@ -59,7 +59,7 @@ class AppendBlockOptions extends BlobServiceOptions */ public function setContentMD5($contentMD5) { - $this->_contentMD5 = $contentMD5; + $this->contentMD5 = $contentMD5; } /** @@ -69,7 +69,7 @@ class AppendBlockOptions extends BlobServiceOptions */ public function getMaxBlobSize() { - return $this->_maxBlobSize; + return $this->maxBlobSize; } /** @@ -81,7 +81,7 @@ class AppendBlockOptions extends BlobServiceOptions */ public function setMaxBlobSize($maxBlobSize) { - $this->_maxBlobSize = $maxBlobSize; + $this->maxBlobSize = $maxBlobSize; } /** @@ -91,7 +91,7 @@ class AppendBlockOptions extends BlobServiceOptions */ public function getAppendPosition() { - return $this->_appendPosition; + return $this->appendPosition; } /** @@ -103,6 +103,6 @@ class AppendBlockOptions extends BlobServiceOptions */ public function setAppendPosition($appendPosition) { - $this->_appendPosition = $appendPosition; + $this->appendPosition = $appendPosition; } } diff --git a/src/Blob/Models/BlockList.php b/src/Blob/Models/BlockList.php index 528c576..50c8385 100644 --- a/src/Blob/Models/BlockList.php +++ b/src/Blob/Models/BlockList.php @@ -40,7 +40,7 @@ use MicrosoftAzure\Storage\Common\Internal\Serialization\XmlSerializer; */ class BlockList { - private $_entries; + private $entries; private static $xmlRootName = 'BlockList'; /** @@ -80,7 +80,7 @@ class BlockList $block->setBlockId($blockId); $block->setType($type); - $this->_entries[] = $block; + $this->entries[] = $block; } /** @@ -128,7 +128,7 @@ class BlockList */ public function getEntry($blockId) { - foreach ($this->_entries as $value) { + foreach ($this->entries as $value) { if ($blockId == $value->getBlockId()) { return $value; } @@ -144,7 +144,7 @@ class BlockList */ public function getEntries() { - return $this->_entries; + return $this->entries; } /** @@ -161,7 +161,7 @@ class BlockList $properties = array(XmlSerializer::ROOT_NAME => self::$xmlRootName); $array = array(); - foreach ($this->_entries as $value) { + foreach ($this->entries as $value) { $array[] = array( $value->getType() => $value->getBlockId() ); diff --git a/src/Blob/Models/LeaseResult.php b/src/Blob/Models/LeaseResult.php index 0e7c4b9..d60444c 100644 --- a/src/Blob/Models/LeaseResult.php +++ b/src/Blob/Models/LeaseResult.php @@ -39,7 +39,7 @@ use MicrosoftAzure\Storage\Common\Internal\Utilities; */ class LeaseResult { - private $_leaseId; + private $leaseId; /** * Creates LeaseResult from response headers @@ -68,7 +68,7 @@ class LeaseResult */ public function getLeaseId() { - return $this->_leaseId; + return $this->leaseId; } /** @@ -80,6 +80,6 @@ class LeaseResult */ protected function setLeaseId($leaseId) { - $this->_leaseId = $leaseId; + $this->leaseId = $leaseId; } } diff --git a/src/Blob/Models/ListBlobBlocksResult.php b/src/Blob/Models/ListBlobBlocksResult.php index f27b132..95dda30 100644 --- a/src/Blob/Models/ListBlobBlocksResult.php +++ b/src/Blob/Models/ListBlobBlocksResult.php @@ -40,12 +40,12 @@ use MicrosoftAzure\Storage\Common\Internal\Utilities; */ class ListBlobBlocksResult { - private $_lastModified; - private $_etag; - private $_contentType; - private $_contentLength; - private $_committedBlocks; - private $_uncommittedBlocks; + private $lastModified; + private $etag; + private $contentType; + private $contentLength; + private $committedBlocks; + private $uncommittedBlocks; /** * Gets block entries from parsed response @@ -55,7 +55,7 @@ class ListBlobBlocksResult * * @return array */ - private static function _getEntries(array $parsed, $type) + private static function getEntries(array $parsed, $type) { $entries = array(); @@ -107,11 +107,11 @@ class ListBlobBlocksResult Utilities::tryGetValue($clean, Resources::CONTENT_TYPE) ); - $result->_uncommittedBlocks = self::_getEntries( + $result->uncommittedBlocks = self::getEntries( $parsed, 'UncommittedBlocks' ); - $result->_committedBlocks = self::_getEntries($parsed, 'CommittedBlocks'); + $result->committedBlocks = self::getEntries($parsed, 'CommittedBlocks'); return $result; } @@ -123,7 +123,7 @@ class ListBlobBlocksResult */ public function getLastModified() { - return $this->_lastModified; + return $this->lastModified; } /** @@ -136,7 +136,7 @@ class ListBlobBlocksResult protected function setLastModified(\DateTime $lastModified) { Validate::isDate($lastModified); - $this->_lastModified = $lastModified; + $this->lastModified = $lastModified; } /** @@ -146,7 +146,7 @@ class ListBlobBlocksResult */ public function getETag() { - return $this->_etag; + return $this->etag; } /** @@ -158,7 +158,7 @@ class ListBlobBlocksResult */ protected function setETag($etag) { - $this->_etag = $etag; + $this->etag = $etag; } /** @@ -168,7 +168,7 @@ class ListBlobBlocksResult */ public function getContentType() { - return $this->_contentType; + return $this->contentType; } /** @@ -180,7 +180,7 @@ class ListBlobBlocksResult */ protected function setContentType($contentType) { - $this->_contentType = $contentType; + $this->contentType = $contentType; } /** @@ -190,7 +190,7 @@ class ListBlobBlocksResult */ public function getContentLength() { - return $this->_contentLength; + return $this->contentLength; } /** @@ -203,7 +203,7 @@ class ListBlobBlocksResult protected function setContentLength($contentLength) { Validate::isInteger($contentLength, 'contentLength'); - $this->_contentLength = $contentLength; + $this->contentLength = $contentLength; } /** @@ -213,7 +213,7 @@ class ListBlobBlocksResult */ public function getUncommittedBlocks() { - return $this->_uncommittedBlocks; + return $this->uncommittedBlocks; } /** @@ -225,7 +225,7 @@ class ListBlobBlocksResult */ protected function setUncommittedBlocks(array $uncommittedBlocks) { - $this->_uncommittedBlocks = $uncommittedBlocks; + $this->uncommittedBlocks = $uncommittedBlocks; } /** @@ -235,7 +235,7 @@ class ListBlobBlocksResult */ public function getCommittedBlocks() { - return $this->_committedBlocks; + return $this->committedBlocks; } /** @@ -247,6 +247,6 @@ class ListBlobBlocksResult */ protected function setCommittedBlocks(array $committedBlocks) { - $this->_committedBlocks = $committedBlocks; + $this->committedBlocks = $committedBlocks; } } diff --git a/src/Common/Internal/Serialization/XmlSerializer.php b/src/Common/Internal/Serialization/XmlSerializer.php index 650560c..df0e23d 100644 --- a/src/Common/Internal/Serialization/XmlSerializer.php +++ b/src/Common/Internal/Serialization/XmlSerializer.php @@ -54,11 +54,11 @@ class XmlSerializer implements ISerializer * * @return array */ - private function _sxml2arr($sxml, array $arr = null) + private function sxml2arr($sxml, array $arr = null) { foreach ((array) $sxml as $key => $value) { if (is_object($value) || (is_array($value))) { - $arr[$key] = $this->_sxml2arr($value); + $arr[$key] = $this->sxml2arr($value); } else { $arr[$key] = $value; } @@ -77,7 +77,7 @@ class XmlSerializer implements ISerializer * * @return void */ - private function _arr2xml(\XMLWriter $xmlw, array $data, $defaultTag = null) + private function arr2xml(\XMLWriter $xmlw, array $data, $defaultTag = null) { foreach ($data as $key => $value) { if ($key === Resources::XTAG_ATTRIBUTES) { @@ -93,7 +93,7 @@ class XmlSerializer implements ISerializer } } - $this->_arr2xml($xmlw, $value); + $this->arr2xml($xmlw, $value); if (!is_int($key)) { $xmlw->endElement(); @@ -113,7 +113,7 @@ class XmlSerializer implements ISerializer * * @return mixed */ - private static function _getInstanceAttributes($targetObject, array $methodArray) + private static function getInstanceAttributes($targetObject, array $methodArray) { foreach ($methodArray as $method) { if ($method->name == 'getAttributes') { @@ -141,7 +141,7 @@ class XmlSerializer implements ISerializer $xmlWriter->setIndent(true); $reflectionClass = new \ReflectionClass($targetObject); $methodArray = $reflectionClass->getMethods(); - $attributes = self::_getInstanceAttributes( + $attributes = self::getInstanceAttributes( $targetObject, $methodArray ); @@ -222,7 +222,7 @@ class XmlSerializer implements ISerializer } unset($array[Resources::XTAG_NAMESPACE]); - self::_arr2xml($xmlw, $array, $defaultTag); + self::arr2xml($xmlw, $array, $defaultTag); $xmlw->endElement(); @@ -240,6 +240,6 @@ class XmlSerializer implements ISerializer { $sxml = new \SimpleXMLElement($serialized); - return $this->_sxml2arr($sxml); + return $this->sxml2arr($sxml); } } diff --git a/tests/functional/Blob/BlobServiceFunctionalTest.php b/tests/functional/Blob/BlobServiceFunctionalTest.php index 26e7b2c..9110b94 100644 --- a/tests/functional/Blob/BlobServiceFunctionalTest.php +++ b/tests/functional/Blob/BlobServiceFunctionalTest.php @@ -27,14 +27,23 @@ namespace MicrosoftAzure\Storage\Tests\functional\Blob; use MicrosoftAzure\Storage\Tests\Framework\TestResources; use MicrosoftAzure\Storage\Blob\Models\BlobServiceOptions; use MicrosoftAzure\Storage\Blob\Models\CopyBlobOptions; +use MicrosoftAzure\Storage\Blob\Models\BlobType; +use MicrosoftAzure\Storage\Blob\Models\BlobBlockType; +use MicrosoftAzure\Storage\Blob\Models\Block; +use MicrosoftAzure\Storage\Blob\Models\BlockList; use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotOptions; use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions; +use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions; use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions; use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataOptions; +use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesOptions; use MicrosoftAzure\Storage\Blob\Models\GetBlobOptions; use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesOptions; +use MicrosoftAzure\Storage\Blob\Models\AppendBlockOptions; +use MicrosoftAzure\Storage\Blob\Models\CreateBlobPagesOptions; use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions; use MicrosoftAzure\Storage\Blob\Models\ListContainersOptions; +use MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksOptions; use MicrosoftAzure\Storage\Blob\Models\PublicAccessType; use MicrosoftAzure\Storage\Common\Exceptions\ServiceException; use MicrosoftAzure\Storage\Common\Internal\Resources; @@ -3034,18 +3043,505 @@ class BlobServiceFunctionalTest extends FunctionalTestBase ); } - // createBlockBlob - // createBlobBlock - // commitBlobBlocks - // listBlobBlocks + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobAsync + */ + public function testCreateBlockBlobNormal() + { + $attrs = BlobServiceFunctionalTestData::getCreateBlockBlobAttributes(); + $container = BlobServiceFunctionalTestData::getContainerName(); - // createPageBlob - // createBlobPages - // clearBlobPages - // listBlobRegions + foreach ($attrs as $attr) { + $threshold = array_key_exists('threshold', $attr)? + $attr['threshold'] : Resources::MB_IN_BYTES_32; + $size = $attr['size']; + $this->createBlockBlobWorker($container, $threshold, $size); + } + } - // acquireLease - // renewLease - // releaseLease - // breakLease + private function createBlockBlobWorker($container, $threshold, $size) + { + //create a temp file of size $size. + $cwd = getcwd(); + $uuid = uniqid('test-file-', true); + $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; + $resource = fopen($path, 'w+'); + + $count = $size / Resources::MB_IN_BYTES_32; + for ($i = 0; $i < $count; ++$i) { + fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); + } + $remain = $size - (Resources::MB_IN_BYTES_32 * $count); + fwrite($resource, openssl_random_pseudo_bytes($remain)); + rewind($resource); + + //upload the blob + $blobName = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $metadata = array('m1' => 'v1', 'm2' => 'v2'); + $contentType = 'text/plain; charset=UTF-8'; + $options = new CreateBlobOptions(); + $options->setContentType($contentType); + $options->setMetadata($metadata); + $this->restProxy->setSingleBlobUploadThresholdInBytes($threshold); + $this->restProxy->createBlockBlob( + $container, + $blobName, + $resource, + $options + ); + + // Test + $result = $this->restProxy->getBlob($container, $blobName); + + //get the path for the file to be downloaded into. + $uuid = uniqid('test-file-', true); + $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; + $downloadResource = fopen($downloadPath, 'w'); + //download the file + $content = $result->getContentStream(); + + while (!feof($content)) { + fwrite( + $downloadResource, + stream_get_contents($content, Resources::MB_IN_BYTES_32) + ); + } + + // Assert + $this->assertEquals( + BlobType::BLOCK_BLOB, + $result->getProperties()->getBlobType() + ); + $this->assertEquals($metadata, $result->getMetadata()); + $originMd5 = md5_file($path); + $downloadMd5 = md5_file($downloadPath); + $this->assertEquals($originMd5, $downloadMd5); + + //clean-up. + if (is_resource($resource)) { + fclose($resource); + } + fclose($downloadResource); + unlink($path); + unlink($downloadPath); + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobBlockAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocksAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocksAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesAsync + */ + public function testBlockBlobBlocks() + { + //create block blob + $container = BlobServiceFunctionalTestData::getContainerName(); + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createBlockBlob($container, $blob, ''); + + //create blocks + $blockIds = array(); + $contents = array(); + for ($i = 0; $i < 5; ++$i) { + $blockId = BlobServiceFunctionalTestData::getInterestingBlockId(); + $content = openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4); + $this->restProxy->createBlobBlock($container, $blob, $blockId, $content); + $blockIds[] = $blockId; + $contents[] = $content; + } + $this->verifyBlocks($container, $blob, $blockIds, false); + //commit blocks 1 and 3. + $latest = BlobBlockType::LATEST_TYPE; + $committed = BlobBlockType::COMMITTED_TYPE; + $blockList = [ + new Block($blockIds[1], $latest), + new Block($blockIds[3], $latest) + ]; + $this->restProxy->commitBlobBlocks($container, $blob, $blockList); + //verify MD5 and uncommitted. + $this->verifyBlobMd5($container, $blob, $contents[1] . $contents[3]); + $this->verifyBlocks( + $container, + $blob, + [$blockIds[1], $blockIds[3]] + ); + + //update blob with blocks 3 and 4. + for ($i = 0; $i < 5; ++$i) { + $this->restProxy->createBlobBlock( + $container, + $blob, + $blockIds[$i], + $contents[$i] + ); + } + $blockList = [ + new Block($blockIds[3], $latest), + new Block($blockIds[4], $latest), + ]; + $this->restProxy->commitBlobBlocks($container, $blob, $blockList); + //verify MD5 and uncommitted. + $this->verifyBlobMd5($container, $blob, $contents[3] . $contents[4]); + $this->verifyBlocks( + $container, + $blob, + [$blockIds[3], $blockIds[4]] + ); + + //commit a blob with same id with block 3 + $this->restProxy->createBlobBlock($container, $blob, $blockIds[0], $contents[0]); + $content = openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4); + $this->restProxy->createBlobBlock($container, $blob, $blockIds[3], $content); + //test BlobBlockType::COMMITTED_TYPE + $blockList = [ + new Block($blockIds[3], $committed), + new Block($blockIds[0], $latest), + ]; + $this->restProxy->commitBlobBlocks($container, $blob, $blockList); + //verify MD5 and uncommitted. + $this->verifyBlobMd5($container, $blob, $contents[3] . $contents[0]); + $this->verifyBlocks( + $container, + $blob, + [$blockIds[0], $blockIds[3]] + ); + //test BlobBlockType::LATEST_TYPE + $this->restProxy->createBlobBlock($container, $blob, $blockIds[0], $contents[0]); + $content = openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4); + $this->restProxy->createBlobBlock($container, $blob, $blockIds[3], $content); + $blockList = [ + new Block($blockIds[3], $latest), + new Block($blockIds[0], $latest), + ]; + $this->restProxy->commitBlobBlocks($container, $blob, $blockList); + //verify MD5 and uncommitted. + $this->verifyBlobMd5($container, $blob, $content . $contents[0]); + $this->verifyBlocks( + $container, + $blob, + [$blockIds[3], $blockIds[0]] + ); + } + + private function verifyBlobMd5($container, $blob, $content) + { + $c = stream_get_contents($this->restProxy->getBlob($container, $blob)->getContentStream()); + $expectedMd5 = md5($content); + $actualMd5 = md5($c); + $this->assertEquals($expectedMd5, $actualMd5); + } + + private function verifyBlocks($container, $blob, $list, $isCommitted = true) + { + $options = new ListBlobBlocksOptions(); + if ($isCommitted) { + $options->setIncludeCommittedBlobs(true); + } else { + $options->setIncludeUncommittedBlobs(true); + } + $result = $this->restProxy->listBlobBlocks($container, $blob, $options); + $blocks = $isCommitted? $result->getCommittedBlocks() : $result->getUncommittedBlocks(); + foreach ($list as $blockId) { + $this->assertTrue(array_key_exists($blockId, $blocks)); + } + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPages + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPagesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::clearBlobPages + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::clearBlobPagesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsync + */ + public function testPutListClearPageRanges() + { + $rangesArray = BlobServiceFunctionalTestData::getRangesArray(); + $container = BlobServiceFunctionalTestData::getInterestingContainerName(); + $this->createContainer($container); + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createPageBlob($container, $blob, 2048); + foreach ($rangesArray as $array) { + $this->putListClearPageRangesWorker( + $container, + $blob, + $array['putRange'], + $array['clearRange'], + $array['listRange'], + $array['resultListRange'] + ); + } + $this->deleteContainer($container); + } + + private function putListClearPageRangesWorker( + $container, + $blob, + $putRange, + $clearRange, + $listRange, + $resultListRange + ) { + if ($putRange != null) { + $length = $putRange->getLength(); + if ($length == null) { + $length = 2048 - $putRange->getStart(); + } + $content = \openssl_random_pseudo_bytes($length); + $options = new CreateBlobPagesOptions(); + //setting the wrong md5. + $options->setContentMD5(Utilities::calculateContentMD5('')); + $message = ''; + try { + $this->restProxy->createBlobPages( + $container, + $blob, + $putRange, + $content, + $options + ); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('400', $message); + $this->assertContains( + 'The MD5 value specified in the request did not match with the MD5 value calculated by the server.', + $message + ); + //Ends debug code snippet + // Now set the correct content MD5 + $options->setContentMD5(Utilities::calculateContentMD5($content)); + $this->restProxy->createBlobPages( + $container, + $blob, + $putRange, + $content, + $options + ); + $getOptions = new GetBlobOptions(); + $getOptions->setRangeStart($putRange->getStart()); + $getOptions->setRangeEnd($putRange->getEnd()); + $getOptions->setComputeRangeMD5(true); + $result = $this->restProxy->getBlob($container, $blob, $getOptions); + $actualContent = stream_get_contents($result->getContentStream()); + $actualMD5 = $result->getProperties()->getContentMD5(); + //Validate + $this->assertEquals(Utilities::calculateContentMD5($content), $actualMD5); + $this->assertEquals($content, $actualContent); + } + if ($clearRange != null) { + $this->restProxy->clearBlobPages($container, $blob, $clearRange); + } + //Validate result + $listRangeOptions = new ListPageBlobRangesOptions(); + if ($listRange != null) { + $listRangeOptions->setRangeStart($listRange->getStart()); + $listRangeOptions->setRangeEnd($listRange->getEnd()); + } + $listResult = + $this->restProxy->listPageBlobRanges($container, $blob, $listRangeOptions); + $this->assertEquals(2048, $listResult->getContentLength()); + $resultRanges = $listResult->getRanges(); + for ($i = 0; $i < count($resultRanges); ++$i) { + $this->assertEquals($resultListRange[$i], $resultRanges[$i]); + } + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync + */ + public function testAppendBlob() + { + $container = BlobServiceFunctionalTestData::getInterestingContainerName(); + $this->createContainer($container); + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createAppendBlob($container, $blob); + + $setupArrays = BlobServiceFunctionalTestData::getAppendBlockSetup(); + foreach ($setupArrays as $setupArray) { + $content = openssl_random_pseudo_bytes($setupArray['size']); + $options = $setupArray['options']; + $errorMsg = $setupArray['error']; + $message = ''; + try { + $this->restProxy->appendBlock( + $container, + $blob, + $content, + $options + ); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + if ($errorMsg == '') { + $this->assertEquals('', $message); + } else { + $this->assertContains($errorMsg, $message); + } + } + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLeaseAsync + */ + public function testLeaseContainer() + { + $container = BlobServiceFunctionalTestData::getInterestingContainerName(); + $this->restProxy->createContainer($container); + $leaseId = Utilities::getGuid(); + $result = $this->restProxy->acquireLease($container, '', $leaseId); + $this->assertEquals($leaseId, $result->getLeaseId()); + $message = ''; + try { + $this->restProxy->deleteContainer($container); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('There is currently a lease on the container and no lease ID was specified in the request', $message); + $options = new BlobServiceOptions(); + $options->setLeaseId($leaseId); + $this->restProxy->deleteContainer($container, $options); + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLeaseAsync + */ + public function testLeaseBlob() + { + $container = BlobServiceFunctionalTestData::getInterestingContainerName(); + $this->restProxy->createContainer($container); + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createPageBlob($container, $blob, 1024); + $leaseId = Utilities::getGuid(); + $result = $this->restProxy->acquireLease($container, $blob, $leaseId); + $this->assertEquals($leaseId, $result->getLeaseId()); + $message = ''; + try { + $this->restProxy->deleteBlob($container, $blob); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('There is currently a lease on the blob and no lease ID was specified in the request.', $message); + $options = new DeleteBlobOptions(); + $options->setLeaseId($leaseId); + $this->restProxy->deleteBlob($container, $blob, $options); + } + + /** + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLeaseAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::renewLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::renewLeaseAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::releaseLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::releaseLeaseAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::changeLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::changeLeaseAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::breakLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::breakLeaseAsync + */ + public function testLeaseOperations() + { + $container = BlobServiceFunctionalTestData::getInterestingContainerName(); + $this->restProxy->createContainer($container); + //configure + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createPageBlob($container, $blob, 1024); + $leaseId = Utilities::getGuid(); + + $message = ''; + //test acquire lease duration no in bound + try { + $this->restProxy->acquireLease($container, $blob, $leaseId, 14); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains(' The value for one of the HTTP headers is not in the correct format.', $message); + try { + $this->restProxy->acquireLease($container, $blob, $leaseId, 61); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains(' The value for one of the HTTP headers is not in the correct format.', $message); + $result = $this->restProxy->acquireLease($container, $blob, $leaseId, 15); + $this->assertEquals($leaseId, $result->getLeaseId()); + //test lease duration expire + \sleep(15); + $this->restProxy->deleteBlob($container, $blob); + + //re-configure + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createPageBlob($container, $blob, 1024); + $leaseId = Utilities::getGuid(); + $this->restProxy->acquireLease($container, $blob, $leaseId); + //test change lease + $newLeaseId = Utilities::getGuid(); + $result = $this->restProxy->changeLease($container, $blob, $leaseId, $newLeaseId); + $options = new DeleteBlobOptions(); + $options->setLeaseId($newLeaseId); + $this->restProxy->deleteBlob($container, $blob, $options); + + $result = $this->restProxy->listBlobs($container); + $this->assertTrue(empty($result->getBlobs())); + + //test renew lease + //re-configure + $blob = BlobServiceFunctionalTestData::getInterestingBlobName($container); + $this->restProxy->createPageBlob($container, $blob, 1024); + $leaseId = Utilities::getGuid(); + $this->restProxy->acquireLease($container, $blob, $leaseId, 15); + \sleep(15); + $this->restProxy->renewLease($container, $blob, $leaseId); + try { + $this->restProxy->deleteBlob($container, $blob); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('There is currently a lease on the blob and no lease ID was specified in the request.', $message); + + //test release lease + $this->restProxy->releaseLease($container, $blob, $leaseId); + //acquire a lease immediately after. + $leaseId = Utilities::getGuid(); + $this->restProxy->acquireLease($container, $blob, $leaseId); + try { + $this->restProxy->deleteBlob($container, $blob); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('There is currently a lease on the blob and no lease ID was specified in the request.', $message); + + //test break lease + $result = $this->restProxy->breakLease($container, $blob, 10); + $leaseId = Utilities::getGuid(); + try { + $this->restProxy->acquireLease($container, $blob, $leaseId); + } catch (ServiceException $e) { + $message = $e->getMessage(); + } + $this->assertContains('There is currently a lease on the blob and no lease ID was specified in the request.', $message); + \sleep(10); + $this->restProxy->acquireLease($container, $blob, $leaseId); + $options = new DeleteBlobOptions(); + $options->setLeaseId($leaseId); + $this->restProxy->deleteBlob($container, $blob, $options); + + $result = $this->restProxy->listBlobs($container); + $this->assertTrue(empty($result->getBlobs())); + } } diff --git a/tests/functional/Blob/BlobServiceFunctionalTestData.php b/tests/functional/Blob/BlobServiceFunctionalTestData.php index c87566f..fa3320b 100644 --- a/tests/functional/Blob/BlobServiceFunctionalTestData.php +++ b/tests/functional/Blob/BlobServiceFunctionalTestData.php @@ -32,6 +32,7 @@ use MicrosoftAzure\Storage\Blob\Models\BlobServiceOptions; use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions; use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotOptions; use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions; +use MicrosoftAzure\Storage\Blob\Models\AppendBlockOptions; use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions; use MicrosoftAzure\Storage\Blob\Models\GetBlobOptions; use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesOptions; @@ -40,6 +41,8 @@ use MicrosoftAzure\Storage\Blob\Models\ListContainersOptions; use MicrosoftAzure\Storage\Blob\Models\PublicAccessType; use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesOptions; use MicrosoftAzure\Storage\Common\Internal\Resources; +use MicrosoftAzure\Storage\Common\Internal\Utilities; +use MicrosoftAzure\Storage\Common\Models\Range; use MicrosoftAzure\Storage\Common\Models\Logging; use MicrosoftAzure\Storage\Common\Models\Metrics; use MicrosoftAzure\Storage\Common\Models\CORS; @@ -54,6 +57,7 @@ class BlobServiceFunctionalTestData public static $nonExistBlobPrefix; public static $testContainerNames; public static $testBlobNames; + private static $blockIdCount; private static $accountName; private static $badETag = '0x123456789ABCDEF'; @@ -66,6 +70,7 @@ class BlobServiceFunctionalTestData self::$nonExistBlobPrefix = 'qa-' . ($rint . 2) . '-'; self::$testContainerNames = array( self::$testUniqueId . 'a1', self::$testUniqueId . 'a2', self::$testUniqueId . 'b1' ); self::$testBlobNames = array( 'b' . self::$testUniqueId . 'a1', 'b' . self::$testUniqueId . 'a2', 'b' . self::$testUniqueId . 'b1' ); + self::$blockIdCount = 0; } public static function getInterestingContainerName() @@ -104,6 +109,14 @@ class BlobServiceFunctionalTestData return $blobname; } + public static function getInterestingBlockId() + { + //Block ID must be base64 encoded. + return base64_encode( + str_pad(self::$blockIdCount++, 6, '0', STR_PAD_LEFT) + ); + } + public static function getSimpleMessageText() { return 'simple message text #' . (self::$tempBlobCounter++); @@ -812,11 +825,6 @@ class BlobServiceFunctionalTestData $options->setSnapshot('placeholder'); array_push($ret, $options); - // TODO: Handle Lease ID - // $options = new GetBlobOptions(); - // $options->setLeaseId('setLeaseId'); - // array_push($ret, $options); - return $ret; } @@ -853,11 +861,6 @@ class BlobServiceFunctionalTestData $options->setSnapshot('placeholder'); array_push($ret, $options); - // TODO: Handle Lease ID - // $options = new DeleteBlobOptions(); - // $options->setLeaseId('setLeaseId'); - // array_push($ret, $options); - return $ret; } @@ -886,11 +889,6 @@ class BlobServiceFunctionalTestData $options->setMetadata(self::getNiceMetadata()); array_push($ret, $options); - // TODO: Handle Lease ID - // $options = new CreateBlobSnapshotOptions(); - // $options->setLeaseId('setLeaseId'); - // array_push($ret, $options); - return $ret; } @@ -932,15 +930,121 @@ class BlobServiceFunctionalTestData $options = new CopyBlobOptions(); $options->setSourceSnapshot('placeholder'); array_push($ret, $options); + + return $ret; + } - // TODO: Handle Lease ID - // $options = new CopyBlobOptions(); - // $options->setLeaseId('setLeaseId'); - // array_push($ret, $options); - // - // $options = new CopyBlobOptions(); - // $options->setSourceLeaseId('setSourceLeaseId'); - // array_push($ret, $options); + public static function getCreateBlockBlobAttributes() + { + $ret = array(); + $ret[] = ['size' => Resources::MB_IN_BYTES_4]; + $ret[] = ['size' => Resources::MB_IN_BYTES_32]; + $ret[] = ['size' => Resources::MB_IN_BYTES_32 + Resources::MB_IN_BYTES_1]; + $ret[] = ['size' => Resources::MB_IN_BYTES_128]; + $ret[] = ['size' => Resources::MB_IN_BYTES_256]; + $ret[] = [ + 'threshold' => Resources::MB_IN_BYTES_4, + 'size' => Resources::MB_IN_BYTES_4 * 2 + ]; + $ret[] = [ + 'threshold' => Resources::MB_IN_BYTES_64, + 'size' => Resources::MB_IN_BYTES_64 + ]; + $ret[] = [ + 'threshold' => Resources::MB_IN_BYTES_64, + 'size' => Resources::MB_IN_BYTES_64 + Resources::MB_IN_BYTES_1 + ]; + + return $ret; + } + + public static function getRangesArray() + { + $ret = array(); + + $ret[] = [ + 'putRange' => new Range(0, 511), + 'clearRange' => null, + 'listRange' => null, + 'resultListRange' => [new Range(0, 511)] + ]; + + $ret[] = [ + 'putRange' => new Range(1024, 1535), + 'clearRange' => null, + 'listRange' => null, + 'resultListRange' => [new Range(0, 511), new Range(1024, 1535)] + ]; + + $ret[] = [ + 'putRange' => new Range(512, 1023), + 'clearRange' => null, + 'listRange' => null, + 'resultListRange' => [new Range(0, 1535)] + ]; + + $ret[] = [ + 'putRange' => null, + 'clearRange' => new Range(1024, 1535), + 'listRange' => null, + 'resultListRange' => [new Range(0, 1023)] + ]; + + $ret[] = [ + 'putRange' => null, + 'clearRange' => null, + 'listRange' => new Range(0, 511), + 'resultListRange' => [new Range(0, 511)] + ]; + + $ret[] = [ + 'putRange' => new Range(1024, 2047), + 'clearRange' => new Range(512, 1023), + 'listRange' => null, + 'resultListRange' => [new Range(0, 511), new Range(1024, 2047)] + ]; + + $ret[] = [ + 'putRange' => null, + 'clearRange' => new Range(0, 2047), + 'listRange' => null, + 'resultListRange' => array() + ]; + + return $ret; + } + + public static function getAppendBlockSetup() + { + $ret = array(); + + $size = Resources::MB_IN_BYTES_4; + $options = new AppendBlockOptions(); + $errorMsg = ''; + $ret[] = ['size' => $size, 'options' => $options, 'error' => $errorMsg]; + + $size = Resources::MB_IN_BYTES_1; + $options = new AppendBlockOptions(); + $options->setContentMD5(Utilities::calculateContentMD5('')); + $errorMsg = 'The MD5 value specified in the request did not match with the MD5 value calculated by the server.'; + $ret[] = ['size' => $size, 'options' => $options, 'error' => $errorMsg]; + + $size = Resources::MB_IN_BYTES_1; + $options = new AppendBlockOptions(); + $options->setMaxBlobSize(Resources::MB_IN_BYTES_4); + $errorMsg = 'The max blob size condition specified was not met'; + $ret[] = ['size' => $size, 'options' => $options, 'error' => $errorMsg]; + + $size = Resources::MB_IN_BYTES_1; + $options = new AppendBlockOptions(); + $options->setAppendPosition(Resources::MB_IN_BYTES_1); + $errorMsg = 'The append position condition specified was not met.'; + $ret[] = ['size' => $size, 'options' => $options, 'error' => $errorMsg]; + + $size = Resources::MB_IN_BYTES_1 + Resources::MB_IN_BYTES_4; + $options = new AppendBlockOptions(); + $errorMsg = 'The request body is too large and exceeds the maximum permissible limit.'; + $ret[] = ['size' => $size, 'options' => $options, 'error' => $errorMsg]; return $ret; } diff --git a/tests/functional/Queue/QueueServiceFunctionalTest.php b/tests/functional/Queue/QueueServiceFunctionalTest.php index 07be017..5a4b964 100644 --- a/tests/functional/Queue/QueueServiceFunctionalTest.php +++ b/tests/functional/Queue/QueueServiceFunctionalTest.php @@ -43,7 +43,9 @@ class QueueServiceFunctionalTest extends FunctionalTestBase { /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServicePropertiesAsync */ public function testGetServicePropertiesNoOptions() { @@ -71,7 +73,9 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServicePropertiesAsync */ public function testGetServiceProperties() { @@ -103,9 +107,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getServiceProperties - */ private function getServicePropertiesWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -204,19 +205,12 @@ class QueueServiceFunctionalTest extends FunctionalTestBase ); } -// /** -// * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServiceProperties -// * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServiceProperties -// */ -// public function testSetServicePropertiesNoOptions() -// { -// $serviceProperties = QueueServiceFunctionalTestData::getDefaultServiceProperties(); -// $this->setServicePropertiesWorker($serviceProperties, null); -// } /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setServicePropertiesAsync */ public function testSetServiceProperties() { @@ -235,10 +229,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getServiceProperties - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::setServiceProperties - */ private function setServicePropertiesWorker($serviceProperties, $options) { try { @@ -288,6 +278,7 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testListQueuesNoOptions() { @@ -296,6 +287,7 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testListQueues() { @@ -305,9 +297,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listQueues - */ private function listQueuesWorker($options) { $finished = false; @@ -442,9 +431,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testCreateQueueNoOptions() { @@ -453,9 +446,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testCreateQueue() { @@ -465,12 +462,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getQueueMetadata - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listQueues - */ private function createQueueWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -552,8 +543,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testDeleteQueueNoOptions() { @@ -562,8 +556,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync */ public function testDeleteQueue() { @@ -575,11 +572,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listQueues - */ private function deleteQueueWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -644,14 +636,17 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - // TODO: Negative tests, like accessing a non-existant queue, or recreating an existing queue? - /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadataAsync */ public function testGetQueueMetadataNoOptions() { @@ -663,10 +658,15 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadataAsync */ public function testGetQueueMetadata() { @@ -682,13 +682,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getQueueMetadata - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::setQueueMetadata - */ private function getQueueMetadataWorker($options, $metadata) { self::println('Trying $options: ' . self::tmptostring($options) . @@ -760,9 +753,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadataAsync */ public function testSetQueueMetadataNoOptions() { @@ -778,9 +775,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueue + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteQueueAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::getQueueMetadataAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadata + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::setQueueMetadataAsync */ public function testSetQueueMetadata() { @@ -800,12 +801,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteQueue - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::getQueueMetadata - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::setQueueMetadata - */ private function setQueueMetadataWorker($options, $metadata) { self::println('Trying $options: ' . self::tmptostring($options) . @@ -852,8 +847,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testCreateMessageEmpty() { @@ -862,8 +860,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testCreateMessageUnicodeMessage() { @@ -885,8 +886,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testCreateMessageXmlMessage() { @@ -898,8 +902,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testCreateMessageWithSmallTTL() { @@ -929,8 +936,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testCreateMessage() { @@ -959,11 +969,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - */ private function createMessageWorker($messageText, $options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -1042,9 +1047,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::updateMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::updateMessageAsync */ public function testUpdateMessageNoOptions() { @@ -1071,9 +1080,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::updateMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::updateMessageAsync */ public function testUpdateMessage() { @@ -1104,12 +1117,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::updateMessage - */ private function updateMessageWorker($messageText, $startingMessage, $visibilityTimeoutInSeconds, $options) { self::println('Trying $options: ' . self::tmptostring($options) . @@ -1203,9 +1210,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testDeleteMessageNoOptions() { @@ -1214,9 +1225,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::deleteMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testDeleteMessage() { @@ -1228,12 +1243,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::deleteMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - */ private function deleteMessageWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -1282,9 +1291,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessagesAsync */ public function testListMessagesNoOptions() { @@ -1293,9 +1306,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessagesAsync */ public function testListMessages() { @@ -1319,12 +1336,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::peekMessages - */ private function listMessagesWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -1422,9 +1433,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessagesAsync */ public function testPeekMessagesNoOptions() { @@ -1433,9 +1448,13 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::peekMessagesAsync */ public function testPeekMessages() { @@ -1455,12 +1474,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::peekMessages - */ private function peekMessagesWorker($options) { self::println('Trying $options: ' . self::tmptostring($options)); @@ -1525,8 +1538,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testClearMessagesNoOptions() { @@ -1535,8 +1551,11 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::clearMessagesAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessage + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::createMessageAsync * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessages + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listMessagesAsync */ public function testClearMessages() { @@ -1548,11 +1567,6 @@ class QueueServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::clearMessages - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::createMessage - * @covers MicrosoftAzure\Storage\ServiceBus\ServiceBusRestProxy::listMessages - */ private function clearMessagesWorker($options) { self::println('Trying $options: ' . @@ -1610,6 +1624,7 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::createHandlerStack */ public function testMiddlewares() @@ -1662,6 +1677,7 @@ class QueueServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueues + * @covers MicrosoftAzure\Storage\Queue\QueueRestProxy::listQueuesAsync * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::createHandlerStack */ public function testRetryFromSecondary() diff --git a/tests/functional/Table/TableServiceFunctionalTest.php b/tests/functional/Table/TableServiceFunctionalTest.php index b346ff2..b5869ab 100644 --- a/tests/functional/Table/TableServiceFunctionalTest.php +++ b/tests/functional/Table/TableServiceFunctionalTest.php @@ -56,7 +56,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase { /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServicePropertiesAsync */ public function testGetServicePropertiesNoOptions() { @@ -84,7 +86,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServicePropertiesAsync */ public function testGetServiceProperties() { @@ -105,6 +109,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync */ private function getServicePropertiesWorker($options) { @@ -196,7 +201,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServicePropertiesAsync */ public function testSetServicePropertiesNoOptions() { @@ -206,7 +213,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServicePropertiesAsync */ public function testSetServiceProperties() { @@ -224,7 +233,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getServicePropertiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServiceProperties + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::setServicePropertiesAsync */ private function setServicePropertiesWorker($serviceProperties, $options) { @@ -255,6 +266,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testQueryTablesNoOptions() { @@ -263,6 +275,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testQueryTables() { @@ -275,6 +288,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ private function queryTablesWorker($options) { @@ -372,8 +386,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testCreateTableNoOptions() { @@ -382,8 +399,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testCreateTable() { @@ -391,11 +411,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase $this->createTableWorker($options); } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables - */ private function createTableWorker($options) { $table = TableServiceFunctionalTestData::getInterestingTableName(); @@ -437,8 +452,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testDeleteTableNoOptions() { @@ -447,8 +465,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ public function testDeleteTable() { @@ -458,8 +479,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync */ private function deleteTableWorker($options) { @@ -518,8 +542,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTableAsync */ public function testGetTableNoOptions() { @@ -528,8 +555,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTableAsync */ public function testGetTable() { @@ -539,8 +569,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::createTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteTableAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTable + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getTableAsync */ private function getTableWorker($options) { @@ -571,7 +604,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync */ public function testGetEntity() { @@ -584,7 +619,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync */ private function getEntityWorker($ent, $isGood, $options) { @@ -696,8 +733,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync */ public function testDeleteEntity() { @@ -712,8 +752,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync */ private function deleteEntityWorker($ent, $useETag, $options) { @@ -754,7 +797,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntity() { @@ -767,7 +812,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertBadEntity() { @@ -786,7 +833,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityBoolean() { @@ -799,30 +848,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } -// /** -// * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity -// * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities -// */ -// public function testInsertEntityBooleanNegative() -// { -// foreach(TableServiceFunctionalTestData::getInterestingBadBooleans() as $o) { -// $ent = new Entity(); -// $ent->setPartitionKey(TableServiceFunctionalTestData::getNewKey()); -// $ent->setRowKey(TableServiceFunctionalTestData::getNewKey()); -// try { -// $ent->addProperty('BOOLEAN', EdmType::BOOLEAN, $o); -// $this->fail('Should get an exception when trying to parse this value'); -// $this->insertEntityWorker($ent, false, null, $o); -// } catch (\Exception $e) { -// $this->assertEquals(0, $e->getCode(), 'getCode'); -// $this->assertTrue(true, 'got expected exception'); -// } -// } -// } - /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityDate() { @@ -837,7 +867,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityDateNegative() { @@ -858,7 +890,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityDouble() { @@ -873,7 +907,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityDoubleNegative() { @@ -894,7 +930,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityGuid() { @@ -909,7 +947,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityGuidNegative() { @@ -930,7 +970,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityInt() { @@ -945,7 +987,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityIntNegative() { @@ -966,7 +1010,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityLong() { @@ -981,7 +1027,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityLongNegative() { @@ -1002,7 +1050,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityBinary() { @@ -1017,7 +1067,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityBinaryNegative() { @@ -1038,7 +1090,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertEntityString() { @@ -1053,7 +1107,9 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ private function insertEntityWorker($ent, $isGood, $options, $specialValue = null) { @@ -1102,8 +1158,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testUpdateEntity() { @@ -1120,8 +1179,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ private function updateEntityWorker($initialEnt, $ent, $options) { @@ -1153,8 +1215,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testMergeEntity() { @@ -1171,8 +1236,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ private function mergeEntityWorker($initialEnt, $ent, $options) { @@ -1205,8 +1273,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertOrReplaceEntity() { @@ -1233,8 +1304,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ private function insertOrReplaceEntityWorker($initialEnt, $ent, $options) { @@ -1266,8 +1340,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ public function testInsertOrMergeEntity() { @@ -1294,8 +1371,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntities + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryEntitiesAsync */ private function insertOrMergeEntityWorker($initialEnt, $ent, $options) { @@ -1328,11 +1408,17 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testCRUDdeleteEntity() { @@ -1350,11 +1436,17 @@ class TableServiceFunctionalTest extends FunctionalTestBase /* /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testCRUDinsertEntity() { @@ -1372,11 +1464,17 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testCRUDinsertOrMergeEntity() { @@ -1396,11 +1494,17 @@ class TableServiceFunctionalTest extends FunctionalTestBase /* /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testCRUDinsertOrReplaceEntity() { @@ -1420,11 +1524,17 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync */ public function testCRUDmergeEntity() { @@ -1442,11 +1552,19 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntityAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testCRUDupdateEntity() { @@ -1462,14 +1580,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity - */ private function crudWorker($opType, $concurType, $mutatePivot, $ent, $options) { $exptErr = $this->expectConcurrencyFailure($opType, $concurType); @@ -1503,7 +1613,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batchAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testBatchPositiveFirstNoKeyMatch() { @@ -1512,7 +1626,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batchAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testBatchPositiveFirstKeyMatchNoETag() { @@ -1521,7 +1639,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batchAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testBatchPositiveFirstKeyMatchETagMismatch() { @@ -1531,7 +1653,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batchAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testBatchPositiveFirstKeyMatchETagMatch() { @@ -1540,7 +1666,11 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batchAsync * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntityAsync + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntityAsync */ public function testBatchNegative() { @@ -1668,10 +1798,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity - */ private function batchPositiveOuter($firstConcurType, $seed) { // The random here is not to generate random values, but to @@ -1738,10 +1864,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity - */ private function batchWorker($configs, $options) { $exptErrs = array(); @@ -1840,9 +1962,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase $this->clearTable($table); } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity - */ private function verifyEntryData($table, $exptErr, $targetEnt, $opResult) { if ($opResult instanceof InsertEntityResult) { @@ -1919,14 +2038,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::deleteEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrMergeEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertOrReplaceEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::mergeEntity - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity - */ private function executeCrudMethod($table, $targetEnt, $opType, $concurType, $options) { switch ($opType) { @@ -1982,9 +2093,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::getEntity - */ private function verifyCrudWorker($opType, $table, $initialEnt, $targetEnt, $expectedSuccess) { $entInTable = null; @@ -2036,9 +2144,6 @@ class TableServiceFunctionalTest extends FunctionalTestBase } } - /** - * @covers MicrosoftAzure\Storage\Table\TableRestProxy::updateEntity - */ private function createTargetEntity($table, $initialEnt, $concurType, $mutatePivot) { $targetEnt = TableServiceFunctionalTestUtils::cloneEntity($initialEnt); @@ -2139,6 +2244,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::createHandlerStack */ public function testMiddlewares() @@ -2191,6 +2297,7 @@ class TableServiceFunctionalTest extends FunctionalTestBase /** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTables + * @covers MicrosoftAzure\Storage\Table\TableRestProxy::queryTablesAsync * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::createHandlerStack */ public function testRetryFromSecondary() diff --git a/tests/unit/Blob/BlobRestProxyTest.php b/tests/unit/Blob/BlobRestProxyTest.php index 580a760..8f985cb 100644 --- a/tests/unit/Blob/BlobRestProxyTest.php +++ b/tests/unit/Blob/BlobRestProxyTest.php @@ -98,7 +98,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers - * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::send + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync */ public function testListContainersSimple() { @@ -123,8 +125,11 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase } /** - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers - */ + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync + */ public function testListContainersWithOptions() { // Setup @@ -155,8 +160,11 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase } /** - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers - */ + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync + */ public function testListContainersWithNextMarker() { // Setup @@ -190,6 +198,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 400 */ @@ -215,6 +226,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync */ public function testListContainersWithNoContainers() { @@ -228,6 +240,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainers + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listContainersAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync */ public function testListContainersWithOneResult() { @@ -245,6 +260,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync */ public function testCreateContainerSimple() { @@ -263,6 +279,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync */ public function testCreateContainerWithoutOptions() { @@ -281,6 +298,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync */ public function testCreateContainerWithMetadata() { @@ -305,7 +323,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer - $this->setExpectedException(get_class(new ServiceException('400'))); + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 400 */ @@ -320,6 +338,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createContainerAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 409 */ @@ -335,6 +354,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteContainerAsync */ public function testDeleteContainer() { @@ -353,6 +373,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteContainer + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteContainerAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 404 */ @@ -367,7 +388,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerProperties - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getContainerPropertiesImpl + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerPropertiesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerPropertiesImpl */ public function testGetContainerProperties() { @@ -386,7 +408,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerMetadata - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getContainerPropertiesImpl + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerMetadataAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerPropertiesImpl */ public function testGetContainerMetadata() { @@ -411,6 +434,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerAcl + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getContainerAclAsync */ public function testGetContainerAcl() { @@ -428,6 +452,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setContainerAcl + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setContainerAclAsync */ public function testSetContainerAcl() { @@ -451,6 +476,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setContainerMetadata + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setContainerMetadataAsync */ public function testSetContainerMetadata() { @@ -473,6 +499,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync * @expectedException \InvalidArgumentException * @expectedExceptionMessage can't be NULL. */ @@ -483,6 +512,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::send */ public function testListBlobsSimple() @@ -516,6 +548,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync */ public function testListBlobsWithOptions() { @@ -553,6 +588,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync */ public function testListBlobsWithOptionsWithDelimiter() { @@ -590,6 +628,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync */ public function testListBlobsWithNextMarker() { @@ -624,6 +665,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync */ public function testListBlobsWithNoBlobs() { @@ -638,6 +680,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync */ public function testListBlobsWithOneResult() { @@ -653,7 +698,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addCreateBlobOptionalHeaders + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::addCreateBlobOptionalHeaders */ public function testCreatePageBlob() { @@ -673,7 +719,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesAsync */ public function testCreateAppendBlob() { @@ -695,9 +743,13 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobsAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesAsync */ public function testAppendBlock() { @@ -743,7 +795,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync */ public function testAppendBlockSuccessWithAppendPosition() { @@ -766,7 +820,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 412 */ @@ -786,7 +842,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync */ public function testAppendBlockSuccessWithMaxBlobSize() { @@ -805,7 +863,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createAppendBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::appendBlockAsync * @expectedException MicrosoftAzure\Storage\Common\Exceptions\ServiceException * @expectedExceptionMessage 412 */ @@ -825,7 +885,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addCreateBlobOptionalHeaders + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::addCreateBlobOptionalHeaders */ public function testCreatePageBlobWithExtraOptions() { @@ -848,7 +909,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addCreateBlobOptionalHeaders + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::addCreateBlobOptionalHeaders */ public function testCreateBlockBlobWithBinary() { @@ -871,7 +933,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addCreateBlobOptionalHeaders + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::addCreateBlobOptionalHeaders */ public function testCreateBlockBlobWithPlainText() { @@ -895,7 +958,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addCreateBlobOptionalHeaders + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::addCreateBlobOptionalHeaders */ public function testCreateBlockBlobWithStream() { @@ -921,7 +985,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getBlobPropertiesResultFromResponse + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesResultFromResponse * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult::create */ public function testGetBlobProperties() @@ -941,8 +1006,10 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobProperties + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobProperties - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getBlobPropertiesResultFromResponse + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobPropertiesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesResultFromResponse * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult::create */ public function testSetBlobProperties() @@ -966,7 +1033,8 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobProperties - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getBlobPropertiesResultFromResponse + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobPropertiesAsync + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobPropertiesResultFromResponse * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult::create */ public function testSetBlobPropertiesWithNoOptions() @@ -987,6 +1055,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobMetadata + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobMetadataAsync * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult::create */ public function testGetBlobMetadata() @@ -1009,6 +1078,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobMetadata + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::setBlobMetadataAsync * @covers MicrosoftAzure\Storage\Blob\Models\SetBlobMetadataResult::create * @covers MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy::addMetadataHeaders */ @@ -1031,6 +1101,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create */ @@ -1087,6 +1158,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create */ @@ -1122,6 +1194,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create */ @@ -1156,6 +1229,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader * @covers MicrosoftAzure\Storage\Blob\Models\GetBlobResult::create */ @@ -1187,6 +1261,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlobAsync */ public function testDeleteBlob() { @@ -1209,6 +1284,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlobAsync */ public function testDeleteBlobSnapshot() { @@ -1238,6 +1314,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::deleteBlobAsync */ public function testDeleteBlobSnapshotsOnly() { @@ -1267,6 +1344,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_createPath */ @@ -1291,6 +1369,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::acquireLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_createPath */ @@ -1318,6 +1397,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::changeLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::changeLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_createPath */ @@ -1344,6 +1424,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::renewLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::renewLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl */ public function testRenewLease() @@ -1367,6 +1448,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::releaseLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::releaseLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl */ public function testReleaseLease() @@ -1391,6 +1473,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::breakLease + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::breakLeaseAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_putLeaseImpl */ public function testBreakLease() @@ -1417,6 +1500,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPages + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPagesAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_updatePageBlobPagesImpl * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader */ @@ -1443,6 +1527,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::clearBlobPages + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::clearBlobPagesAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_updatePageBlobPagesImpl * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_addOptionalRangeHeader */ @@ -1470,6 +1555,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsync * @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult::create */ public function testListPageBlobRanges() @@ -1497,6 +1583,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsync * @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult::create */ public function testListPageBlobRangesEmpty() @@ -1518,6 +1605,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobBlock + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobBlockAsync */ public function testCreateBlobBlock() { @@ -1537,6 +1625,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocksAsync * @covers MicrosoftAzure\Storage\Blob\Models\BlockList::toXml */ public function testCommitBlobBlocks() @@ -1564,6 +1653,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::commitBlobBlocksAsync * @covers MicrosoftAzure\Storage\Blob\Models\BlockList::toXml */ public function testCommitBlobBlocksWithArray() @@ -1594,6 +1684,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocksAsync * @covers MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult::create * @covers MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult::getContentLength * @covers MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult::getUncommittedBlocks @@ -1622,6 +1713,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocks + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobBlocksAsync * @covers MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult::create * @covers MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult::_getEntries */ @@ -1646,6 +1738,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getCopyBlobSourceName */ public function testCopyBlobDifferentContainer() @@ -1725,6 +1818,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getCopyBlobSourceName */ public function testCopyBlobSameContainer() @@ -1765,6 +1859,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getCopyBlobSourceName */ public function testCopyBlobExistingBlob() @@ -1807,7 +1902,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase } /** - * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::copyBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::_getCopyBlobSourceName */ public function testCopyBlobSnapshot() @@ -1844,6 +1939,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobSnapshot + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobSnapshotAsync * @covers MicrosoftAzure\Storage\Blob\Models\createBlobSnapshotResult::create */ public function testCreateBlobSnapshot() @@ -1872,6 +1968,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob */ public function testSingleBlobUploadZeroBytes() @@ -1924,6 +2021,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob + * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlobAsync **/ public function testCreateBlobLargerThanSingleBlock() { @@ -1969,6 +2067,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFileAsync */ public function testGetBlockBlobToFile() { @@ -2009,6 +2108,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFileAsync */ public function testGetPageBlobToFile() { @@ -2043,727 +2143,9 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase unlink($path); } - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet2GBBlockBlob() - { - // Setup - //create a temp file that is 2GB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 2 * 1024 / 4; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); - } - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet5TBBlockBlob() - { - // Initial check for the environment. - // Does disk have enough space. - $this->assertTrue(disk_free_space('.') > (2 * Resources::TB_IN_BYTES_5)); - // Setup - //create a temp file that is 5TB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 50000 * 100 / 64; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_64)); - } - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet32MBBlockBlob() - { - // Setup - //create a temp file that is 32 in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet33MBBlockBlob() - { - // Setup - //create a temp file that is 33 in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_1)); - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet64MBBlockBlob() - { - // Setup - //create a temp file that is 64 in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->setSingleBlobUploadThresholdInBytes(Resources::MB_IN_BYTES_64); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - $this->restProxy->setSingleBlobUploadThresholdInBytes(Resources::MB_IN_BYTES_32); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGet65MBBlockBlob() - { - // Setup - //create a temp file that is 65 in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_32)); - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_1)); - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->setSingleBlobUploadThresholdInBytes(Resources::MB_IN_BYTES_64); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - $this->restProxy->setSingleBlobUploadThresholdInBytes(Resources::MB_IN_BYTES_32); - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - //clean-up. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testPutGetBlockBlobWith5MBBlocks() - { - // Setup - $content = openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_64); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $this->createContainer($name); - $this->restProxy->setBlockSize(Resources::MB_IN_BYTES_1 * 5); - $this->restProxy->createBlockBlob( - $name, - $blob, - $content - ); - - //Get the committed blocks count. - $options = new ListBlobBlocksOptions(); - $options->setIncludeCommittedBlobs(true); - - $result = $this->restProxy->listBlobBlocks($name, $blob, $options); - - $this->assertEquals(13, \count($result->getCommittedBlocks())); - } - - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPages - */ - public function testGetLargePageBlob() - { - //Setup - //create a temp file that is 2GB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 2 * 1024 / 4; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); - } - rewind($resource); - //upload the blob - $name = 'createblobpages' . $this->createSuffix(); - $blob = 'myblob'; - $length = $count * Resources::MB_IN_BYTES_4; - $this->createContainer($name); - $this->restProxy->createPageBlob($name, $blob, $length); - //upload the blob for 4MB a chunk - $chunkSize = Resources::MB_IN_BYTES_4; - $uploadCount = $length / $chunkSize; - for ($chunkIdx = 0; $chunkIdx < $uploadCount; ++$chunkIdx) { - $range = new Range( - $chunkSize * $chunkIdx, - ($chunkSize * ($chunkIdx + 1)) - 1 - ); - $body = fread($resource, $chunkSize); - $actual = $this->restProxy->createBlobPages( - $name, - $blob, - $range, - $body - ); - } - - // Test - $result = $this->restProxy->getBlob($name, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - //download the file - $content = $result->getContentStream(); - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::PAGE_BLOB, - $result->getProperties()->getBlobType() - ); - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - // Delete file after assertion. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::getBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlobFromContent - */ - public function testCreateLargePageBlobFromContent() - { - //Setup - //create a temp file that is 2GB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 2 * 1024 / 4; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); - } - rewind($resource); - - //upload the blob - $container = 'createpageblobfromcontent' . $this->createSuffix(); - $blob = 'myblob'; - $length = $count * Resources::MB_IN_BYTES_4; - $this->createContainer($container); - - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - - $createPageBlobResult = $this->restProxy->createPageBlobFromContent($container, $blob, $length, $resource, $options); - - $originMd5 = md5_file($path); - $this->assertEquals("PageBlob", $createPageBlobResult->getProperties()->getBlobType()); - $this->assertEquals($contentType, $createPageBlobResult->getProperties()->getContentType()); - $this->assertEquals(2, count($createPageBlobResult->getMetadata())); - $this->assertEquals($metadata["m1"], $createPageBlobResult->getMetadata()["m1"]); - $this->assertEquals($metadata["m2"], $createPageBlobResult->getMetadata()["m2"]); - - // Test - $result = $this->restProxy->getBlob($container, $blob); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $downloadResource = fopen($downloadPath, 'w'); - - //download the file - $content = $result->getContentStream(); - while (!feof($content)) { - fwrite( - $downloadResource, - stream_get_contents($content, Resources::MB_IN_BYTES_4) - ); - } - - // Assert - $this->assertEquals( - BlobType::PAGE_BLOB, - $result->getProperties()->getBlobType() - ); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - // Delete file after assertion. - if (is_resource($resource)) { - fclose($resource); - } - fclose($downloadResource); - unlink($path); - unlink($downloadPath); - } - - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlockBlob - */ - public function testGetLargeBlockBlobToFile() - { - // Setup - //create a temp file that is 2GB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 2 * 1024 / 4; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); - } - rewind($resource); - //upload the blob - $name = 'getblob' . $this->createSuffix(); - $blob = 'myblob'; - $metadata = array('m1' => 'v1', 'm2' => 'v2'); - $contentType = 'text/plain; charset=UTF-8'; - $this->createContainer($name); - $options = new CreateBlobOptions(); - $options->setContentType($contentType); - $options->setMetadata($metadata); - $this->restProxy->createBlockBlob( - $name, - $blob, - $resource, - $options - ); - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - - // Test - $result = $this->restProxy->saveBlobToFile($downloadPath, $name, $blob); - - - // Assert - $this->assertEquals( - BlobType::BLOCK_BLOB, - $result->getProperties()->getBlobType() - ); - $this->assertEquals($metadata, $result->getMetadata()); - if (is_resource($resource)) { - fclose($resource); - } - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - // Delete file after assertion. - unlink($path); - unlink($downloadPath); - } - - /** - * @group large-scale - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createPageBlob - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPages - */ - public function testGetLargePageBlobToFile() - { - //Setup - //create a temp file that is 2GB in size. - $cwd = getcwd(); - $uuid = uniqid('test-file-', true); - $path = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - $resource = fopen($path, 'w+'); - $count = 2 * 1024 / 4; - for ($index = 0; $index < $count; ++$index) { - fwrite($resource, openssl_random_pseudo_bytes(Resources::MB_IN_BYTES_4)); - } - rewind($resource); - //upload the blob - $name = 'createblobpages' . $this->createSuffix(); - $blob = 'myblob'; - $length = $count * Resources::MB_IN_BYTES_4; - $this->createContainer($name); - $this->restProxy->createPageBlob($name, $blob, $length); - //upload the blob for 4MB a chunk - $chunkSize = Resources::MB_IN_BYTES_4; - $uploadCount = $length / $chunkSize; - for ($chunkIdx = 0; $chunkIdx < $uploadCount; ++$chunkIdx) { - $range = new Range( - $chunkSize * $chunkIdx, - ($chunkSize * ($chunkIdx + 1)) - 1 - ); - $body = fread($resource, $chunkSize); - $actual = $this->restProxy->createBlobPages( - $name, - $blob, - $range, - $body - ); - } - - //get the path for the file to be downloaded into. - $uuid = uniqid('test-file-', true); - $downloadPath = $cwd.DIRECTORY_SEPARATOR.$uuid.'.txt'; - - // Test - $result = $this->restProxy->saveBlobToFile($downloadPath, $name, $blob); - - // Assert - $this->assertEquals( - BlobType::PAGE_BLOB, - $result->getProperties()->getBlobType() - ); - if (is_resource($resource)) { - fclose($resource); - } - $originMd5 = md5_file($path); - $downloadMd5 = md5_file($downloadPath); - $this->assertEquals($originMd5, $downloadMd5); - - // Delete file after assertion. - unlink($path); - unlink($downloadPath); - } - /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPages + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobPagesAsync */ public function testRangeCreationWithInvalidRange() { @@ -2792,6 +2174,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFileAsync */ public function testsaveBlobToFileWithInvalidPath() { @@ -2830,6 +2213,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase /** * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFileAsync */ public function testsaveBlobToFileWithBlobNotExist() { @@ -2854,7 +2238,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase } /** - * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFile + * @covers \MicrosoftAzure\Storage\Blob\BlobRestProxy::saveBlobToFileAsync */ public function testsaveBlobToFileWithContainerNotExist() { diff --git a/tests/unit/Blob/Models/ListBlobBlocksResultTest.php b/tests/unit/Blob/Models/ListBlobBlocksResultTest.php index c98035d..63a7549 100644 --- a/tests/unit/Blob/Models/ListBlobBlocksResultTest.php +++ b/tests/unit/Blob/Models/ListBlobBlocksResultTest.php @@ -60,7 +60,7 @@ class ListBlobBlocksResultTest extends \PHPUnit_Framework_TestCase $sampleHeaders = TestResources::listBlocksMultipleEntriesHeaders(); $sampleBody = TestResources::listBlocksMultipleEntriesBody(); $expectedDate = Utilities::rfc1123ToDateTime($sampleHeaders['Last-Modified']); - $getEntry = self::getMethod('_getEntries'); + $getEntry = self::getMethod('getEntries'); $uncommittedBlocks = $getEntry->invokeArgs(null, array($sampleBody, 'UncommittedBlocks')); $committedBlocks = $getEntry->invokeArgs(null, array($sampleBody, 'CommittedBlocks')); From c62dfa3824ef749789b35821eceaf72fc778664b Mon Sep 17 00:00:00 2001 From: Tank Tang Date: Thu, 3 Aug 2017 13:54:52 +0800 Subject: [PATCH 7/7] Changing version number from 0.17.0 to 1.0.0-beta.1 --- BreakingChanges.md | 2 +- ChangeLog.md | 2 +- src/Common/Internal/Resources.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BreakingChanges.md b/BreakingChanges.md index ef51345..2fb738e 100644 --- a/BreakingChanges.md +++ b/BreakingChanges.md @@ -1,4 +1,4 @@ -Tracking Breaking changes in 0.17.0 +Tracking Breaking changes in 1.0.0-beta.1 All * Refined code logic for continuation token. Now continuation token will be null if there are no more instance to be queried/listed. diff --git a/ChangeLog.md b/ChangeLog.md index 0e56003..d0f421e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,4 @@ -2017.07 - version 0.17.0 +2017.07 - version 1.0.0-beta.1 All * REST API version upgraded to 2016-05-31. diff --git a/src/Common/Internal/Resources.php b/src/Common/Internal/Resources.php index b428c10..2a1f6a7 100644 --- a/src/Common/Internal/Resources.php +++ b/src/Common/Internal/Resources.php @@ -301,7 +301,7 @@ class Resources const DEAFULT_RETRY_INTERVAL = 1000;//Milliseconds // Header values - const SDK_VERSION = '0.17.0'; + const SDK_VERSION = '1.0.0-beta.1'; const STORAGE_API_LATEST_VERSION = '2016-05-31'; const DATA_SERVICE_VERSION_VALUE = '3.0'; const MAX_DATA_SERVICE_VERSION_VALUE = '3.0;NetFx';