Added `BlobRestProxy::listPageBlobRangesDiff` and `BlobRestProxy::listPageBlobRangesDiffAsync` for getting page ranges difference. Refer to https://msdn.microsoft.com/en-us/library/azure/mt736912.aspx for more detailed information.
This commit is contained in:
Родитель
6252474b3a
Коммит
3c119befba
|
@ -1,5 +1,6 @@
|
|||
All
|
||||
* Fixed wrong PHPUnit `@covers` tags in unit and functional test.
|
||||
* Added `BlobRestProxy::listPageBlobRangesDiff` and `BlobRestProxy::listPageBlobRangesDiffAsync` for getting page ranges difference. Refer to https://msdn.microsoft.com/en-us/library/azure/mt736912.aspx for more detailed information.
|
||||
|
||||
Blob
|
||||
* Following methods of `MicrosoftAzure\Storage\Blob\BlobRestProxy` now return the x-ms-request-server-encrypted response header. This header is set to true if the contents of the request have been successfully encrypted.
|
||||
|
|
|
@ -24,59 +24,60 @@
|
|||
|
||||
namespace MicrosoftAzure\Storage\Blob;
|
||||
|
||||
use MicrosoftAzure\Storage\Common\Internal\ServiceRestTrait;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Utilities;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Resources;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Validate;
|
||||
use MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy;
|
||||
use MicrosoftAzure\Storage\Common\LocationMode;
|
||||
use MicrosoftAzure\Storage\Common\Models\Range;
|
||||
use GuzzleHttp\Psr7;
|
||||
use MicrosoftAzure\Storage\Blob\Internal\IBlob;
|
||||
use MicrosoftAzure\Storage\Blob\Models\AppendBlockOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\AppendBlockResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BlobServiceOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListContainersOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListContainersResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetContainerPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetContainerACLResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobsResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BlobType;
|
||||
use MicrosoftAzure\Storage\Blob\Models\Block;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BlockList;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BreakLeaseResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CopyBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CopyBlobResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobBlockOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobMetadataResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\LeaseMode;
|
||||
use MicrosoftAzure\Storage\Blob\Models\LeaseResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobPagesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobPagesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PageWriteOption;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobBlockOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BlockList;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CopyBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateBlobSnapshotResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CopyBlobResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\BreakLeaseResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PutBlockResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\DeleteBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobMetadataResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetBlobResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetContainerACLResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\GetContainerPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\LeaseMode;
|
||||
use MicrosoftAzure\Storage\Blob\Models\LeaseResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobBlocksResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListBlobsResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListContainersOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListContainersResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PageWriteOption;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PutBlobResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\PutBlockResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobMetadataResult;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Http\HttpFormatter;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Resources;
|
||||
use MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy;
|
||||
use MicrosoftAzure\Storage\Common\Internal\ServiceRestTrait;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Utilities;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Validate;
|
||||
use MicrosoftAzure\Storage\Common\LocationMode;
|
||||
use MicrosoftAzure\Storage\Common\Models\Range;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use GuzzleHttp\Psr7;
|
||||
|
||||
/**
|
||||
* This class constructs HTTP requests and receive HTTP responses for blob
|
||||
|
@ -2925,6 +2926,106 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob
|
|||
$container,
|
||||
$blob,
|
||||
Models\ListPageBlobRangesOptions $options = null
|
||||
) {
|
||||
return $this->listPageBlobRangesAsyncImpl($container, $blob, null, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of page ranges that have been updated or cleared.
|
||||
*
|
||||
* Returns a list of page ranges that have been updated or cleared since
|
||||
* the snapshot specified by `previousSnapshotTime`. Gets all of the page
|
||||
* ranges by default, or only the page ranges over a specific range of
|
||||
* bytes if `rangeStart` and `rangeEnd` in the `options` are specified.
|
||||
*
|
||||
* @param string $container name of the container
|
||||
* @param string $blob name of the blob
|
||||
* @param string $previousSnapshotTime previous snapshot time
|
||||
* for comparison which
|
||||
* should be prior to the
|
||||
* snapshot time defined
|
||||
* in `options`
|
||||
* @param Models\ListPageBlobRangesOptions $options optional parameters
|
||||
*
|
||||
* @return Models\ListPageBlobRangesDiffResult
|
||||
*
|
||||
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/version-2015-07-08
|
||||
*/
|
||||
public function listPageBlobRangesDiff(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
Models\ListPageBlobRangesOptions $options = null
|
||||
) {
|
||||
return $this->listPageBlobRangesDiffAsync(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
$options
|
||||
)->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates promise to return a list of page ranges that have been updated
|
||||
* or cleared.
|
||||
*
|
||||
* Creates promise to return a list of page ranges that have been updated
|
||||
* or cleared since the snapshot specified by `previousSnapshotTime`. Gets
|
||||
* all of the page ranges by default, or only the page ranges over a specific
|
||||
* range of bytes if `rangeStart` and `rangeEnd` in the `options` are specified.
|
||||
*
|
||||
* @param string $container name of the container
|
||||
* @param string $blob name of the blob
|
||||
* @param string $previousSnapshotTime previous snapshot time
|
||||
* for comparison which
|
||||
* should be prior to the
|
||||
* snapshot time defined
|
||||
* in `options`
|
||||
* @param Models\ListPageBlobRangesOptions $options optional parameters
|
||||
*
|
||||
* @return \GuzzleHttp\Promise\PromiseInterface
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
|
||||
*/
|
||||
public function listPageBlobRangesDiffAsync(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
Models\ListPageBlobRangesOptions $options = null
|
||||
) {
|
||||
return $this->listPageBlobRangesAsyncImpl(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates promise to return a list of page ranges.
|
||||
|
||||
* If `previousSnapshotTime` is specified, the response will include
|
||||
* only the pages that differ between the target snapshot or blob and
|
||||
* the previous snapshot.
|
||||
*
|
||||
* @param string $container name of the container
|
||||
* @param string $blob name of the blob
|
||||
* @param string $previousSnapshotTime previous snapshot time
|
||||
* for comparison which
|
||||
* should be prior to the
|
||||
* snapshot time defined
|
||||
* in `options`
|
||||
* @param Models\ListPageBlobRangesOptions $options optional parameters
|
||||
*
|
||||
* @return \GuzzleHttp\Promise\PromiseInterface
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
|
||||
*/
|
||||
private function listPageBlobRangesAsyncImpl(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime = null,
|
||||
Models\ListPageBlobRangesOptions $options = null
|
||||
) {
|
||||
Validate::canCastAsString($container, 'container');
|
||||
Validate::canCastAsString($blob, 'blob');
|
||||
|
@ -2966,7 +3067,12 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob
|
|||
Resources::QP_COMP,
|
||||
'pagelist'
|
||||
);
|
||||
|
||||
$this->addOptionalQueryParam(
|
||||
$queryParams,
|
||||
Resources::QP_PRE_SNAPSHOT,
|
||||
$previousSnapshotTime
|
||||
);
|
||||
|
||||
$dataSerializer = $this->dataSerializer;
|
||||
|
||||
return $this->sendAsync(
|
||||
|
@ -2978,12 +3084,19 @@ class BlobRestProxy extends ServiceRestProxy implements IBlob
|
|||
Resources::STATUS_OK,
|
||||
Resources::EMPTY_STRING,
|
||||
$options
|
||||
)->then(function ($response) use ($dataSerializer) {
|
||||
)->then(function ($response) use ($dataSerializer, $previousSnapshotTime) {
|
||||
$parsed = $dataSerializer->unserialize($response->getBody());
|
||||
return ListPageBlobRangesResult::create(
|
||||
HttpFormatter::formatHeaders($response->getHeaders()),
|
||||
$parsed
|
||||
);
|
||||
if (is_null($previousSnapshotTime)) {
|
||||
return ListPageBlobRangesResult::create(
|
||||
HttpFormatter::formatHeaders($response->getHeaders()),
|
||||
$parsed
|
||||
);
|
||||
} else {
|
||||
return ListPageBlobRangesDiffResult::create(
|
||||
HttpFormatter::formatHeaders($response->getHeaders()),
|
||||
$parsed
|
||||
);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -962,6 +962,63 @@ interface IBlob
|
|||
BlobModels\ListPageBlobRangesOptions $options = null
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns a list of page ranges that have been updated or cleared.
|
||||
*
|
||||
* Returns a list of page ranges that have been updated or cleared since
|
||||
* the snapshot specified by `previousSnapshotTime`. Gets all of the page
|
||||
* ranges by default, or only the page ranges over a specific range of
|
||||
* bytes if `rangeStart` and `rangeEnd` in the `options` are specified.
|
||||
*
|
||||
* @param string $container name of the container
|
||||
* @param string $blob name of the blob
|
||||
* @param string $previousSnapshotTime previous snapshot time
|
||||
* for comparison which
|
||||
* should be prior to the
|
||||
* snapshot time defined
|
||||
* in `options`
|
||||
* @param BlobModels\ListPageBlobRangesOptions $options optional parameters
|
||||
*
|
||||
* @return BlobModels\ListPageBlobRangesDiffResult
|
||||
*
|
||||
* @see https://docs.microsoft.com/en-us/rest/api/storageservices/version-2015-07-08
|
||||
*/
|
||||
public function listPageBlobRangesDiff(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
BlobModels\ListPageBlobRangesOptions $options = null
|
||||
);
|
||||
|
||||
/**
|
||||
* Creates promise to return a list of page ranges that have been updated
|
||||
* or cleared.
|
||||
*
|
||||
* Creates promise to return a list of page ranges that have been updated
|
||||
* or cleared since the snapshot specified by `previousSnapshotTime`. Gets
|
||||
* all of the page ranges by default, or only the page ranges over a specific
|
||||
* range of bytes if `rangeStart` and `rangeEnd` in the `options` are specified.
|
||||
*
|
||||
* @param string $container name of the container
|
||||
* @param string $blob name of the blob
|
||||
* @param string $previousSnapshotTime previous snapshot time
|
||||
* for comparison which
|
||||
* should be prior to the
|
||||
* snapshot time defined
|
||||
* in `options`
|
||||
* @param BlobModels\ListPageBlobRangesOptions $options optional parameters
|
||||
*
|
||||
* @return \GuzzleHttp\Promise\PromiseInterface
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
|
||||
*/
|
||||
public function listPageBlobRangesDiffAsync(
|
||||
$container,
|
||||
$blob,
|
||||
$previousSnapshotTime,
|
||||
BlobModels\ListPageBlobRangesOptions $options = null
|
||||
);
|
||||
|
||||
/**
|
||||
* Sets system properties defined for a blob.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: The MIT License (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://github.com/azure/azure-storage-php/LICENSE
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Blob\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @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\Internal\Utilities;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Resources;
|
||||
use MicrosoftAzure\Storage\Common\Models\RangeDiff;
|
||||
|
||||
/**
|
||||
* Holds result of calling listPageBlobRangesDiff wrapper
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Blob\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @copyright 2017 Microsoft Corporation
|
||||
* @license https://github.com/azure/azure-storage-php/LICENSE
|
||||
* @link https://github.com/azure/azure-storage-php
|
||||
*/
|
||||
class ListPageBlobRangesDiffResult extends ListPageBlobRangesResult
|
||||
{
|
||||
/**
|
||||
* Creates ListPageBlobRangesDiffResult object from $parsed response in array representation
|
||||
*
|
||||
* @param array $headers HTTP response headers
|
||||
* @param array $parsed parsed response in array format.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return ListPageBlobRangesDiffResult
|
||||
*/
|
||||
public static function create(array $headers, array $parsed = null)
|
||||
{
|
||||
$result = new ListPageBlobRangesDiffResult();
|
||||
$headers = array_change_key_case($headers);
|
||||
|
||||
$date = $headers[Resources::LAST_MODIFIED];
|
||||
$date = Utilities::rfc1123ToDateTime($date);
|
||||
$blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]);
|
||||
|
||||
$result->setContentLength($blobLength);
|
||||
$result->setLastModified($date);
|
||||
$result->setETag($headers[Resources::ETAG]);
|
||||
|
||||
if (is_null($parsed)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$parsed = array_change_key_case($parsed);
|
||||
|
||||
$rawRanges = array();
|
||||
if (!empty($parsed[strtolower(Resources::XTAG_PAGE_RANGE)])) {
|
||||
$rawRanges = Utilities::getArray($parsed[strtolower(Resources::XTAG_PAGE_RANGE)]);
|
||||
}
|
||||
|
||||
$pageRanges = array();
|
||||
foreach ($rawRanges as $value) {
|
||||
$pageRanges[] = new RangeDiff(
|
||||
intval($value[Resources::XTAG_RANGE_START]),
|
||||
intval($value[Resources::XTAG_RANGE_END])
|
||||
);
|
||||
}
|
||||
|
||||
$rawRanges = array();
|
||||
if (!empty($parsed[strtolower(Resources::XTAG_CLEAR_RANGE)])) {
|
||||
$rawRanges = Utilities::getArray($parsed[strtolower(Resources::XTAG_CLEAR_RANGE)]);
|
||||
}
|
||||
|
||||
foreach ($rawRanges as $value) {
|
||||
$pageRanges[] = new RangeDiff(
|
||||
intval($value[Resources::XTAG_RANGE_START]),
|
||||
intval($value[Resources::XTAG_RANGE_END]),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$result->setRanges($pageRanges);
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -66,16 +66,16 @@ class ListPageBlobRangesResult
|
|||
$blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]);
|
||||
$rawRanges = array();
|
||||
|
||||
if (!empty($parsed['PageRange'])) {
|
||||
if (!empty($parsed[Resources::XTAG_PAGE_RANGE])) {
|
||||
$parsed = array_change_key_case($parsed);
|
||||
$rawRanges = Utilities::getArray($parsed['pagerange']);
|
||||
$rawRanges = Utilities::getArray($parsed[strtolower(RESOURCES::XTAG_PAGE_RANGE)]);
|
||||
}
|
||||
|
||||
$pageRanges = array();
|
||||
foreach ($rawRanges as $value) {
|
||||
$pageRanges[] = new Range(
|
||||
intval($value['Start']),
|
||||
intval($value['End'])
|
||||
intval($value[Resources::XTAG_RANGE_START]),
|
||||
intval($value[Resources::XTAG_RANGE_END])
|
||||
);
|
||||
}
|
||||
$result->setRanges($pageRanges);
|
||||
|
|
|
@ -332,6 +332,7 @@ class Resources
|
|||
const QP_DELIMITER = 'Delimiter';
|
||||
const QP_REST_TYPE = 'restype';
|
||||
const QP_SNAPSHOT = 'snapshot';
|
||||
const QP_PRE_SNAPSHOT = 'prevsnapshot';
|
||||
const QP_BLOCKID = 'blockid';
|
||||
const QP_BLOCK_LIST_TYPE = 'blocklisttype';
|
||||
const QP_SELECT = '$select';
|
||||
|
@ -481,6 +482,10 @@ class Resources
|
|||
const XTAG_GEO_REPLICATION = 'GeoReplication';
|
||||
const XTAG_LAST_SYNC_TIME = 'LastSyncTime';
|
||||
const XTAG_SHARE_USAGE = 'ShareUsage';
|
||||
const XTAG_PAGE_RANGE = 'PageRange';
|
||||
const XTAG_CLEAR_RANGE = 'ClearRange';
|
||||
const XTAG_RANGE_START = 'Start';
|
||||
const XTAG_RANGE_END = 'End';
|
||||
|
||||
//JSON Tags
|
||||
const JSON_TABLE_NAME = 'TableName';
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: The MIT License (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://github.com/azure/azure-storage-php/LICENSE
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Common\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @copyright 2017 Microsoft Corporation
|
||||
* @license https://github.com/azure/azure-storage-php/LICENSE
|
||||
* @link https://github.com/azure/azure-storage-php
|
||||
*/
|
||||
|
||||
namespace MicrosoftAzure\Storage\Common\Models;
|
||||
|
||||
/**
|
||||
* Holds info about page blob range diffs
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Common\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @copyright 2017 Microsoft Corporation
|
||||
* @license https://github.com/azure/azure-storage-php/LICENSE
|
||||
* @link https://github.com/azure/azure-storage-php
|
||||
*/
|
||||
class RangeDiff extends Range
|
||||
{
|
||||
private $isClearedPageRange;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param integer $start the resource start value
|
||||
* @param integer $end the resource end value
|
||||
* @param bool $isClearedPageRange true if the page range is a cleared range, false otherwise.
|
||||
*/
|
||||
public function __construct($start, $end = null, $isClearedPageRange = false)
|
||||
{
|
||||
parent::__construct($start, $end);
|
||||
$this->isClearedPageRange = $isClearedPageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the page range is a cleared range, false otherwise
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClearedPageRange()
|
||||
{
|
||||
return $this->isClearedPageRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isClearedPageRange property
|
||||
*
|
||||
* @param bool $isClearedPageRange
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setIsClearedPageRange($isClearedPageRange)
|
||||
{
|
||||
$this->isClearedPageRange = $isClearedPageRange;
|
||||
}
|
||||
}
|
|
@ -1346,7 +1346,19 @@ class TestResources
|
|||
0 => array('Start' => '0', 'End' => '4194303'),
|
||||
1 => array('Start' => '4194304', 'End' => '8388607'),
|
||||
2 => array('Start' => '8388608', 'End' => '12582911'),
|
||||
3 => array('Start' => '12582911', 'End' => '13606911'),
|
||||
3 => array('Start' => '12582912', 'End' => '13606911'),
|
||||
));
|
||||
}
|
||||
|
||||
public static function listPageRangeDiffBodyInArray()
|
||||
{
|
||||
return array('PageRange' => array(
|
||||
0 => array('Start' => '0', 'End' => '4194303'),
|
||||
1 => array('Start' => '4194304', 'End' => '8388607'),
|
||||
2 => array('Start' => '8388608', 'End' => '12582911'),
|
||||
3 => array('Start' => '12582912', 'End' => '13606911'),
|
||||
), 'PageClear' => array(
|
||||
0 => array('Start' => '13606912', 'End' => '17801215')
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ 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\Models\Range;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Resources;
|
||||
use MicrosoftAzure\Storage\Common\Internal\StorageServiceSettings;
|
||||
use MicrosoftAzure\Storage\Common\Internal\Utilities;
|
||||
|
@ -3264,6 +3265,7 @@ class BlobServiceFunctionalTest extends FunctionalTestBase
|
|||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::clearBlobPagesAsync
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsync
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsyncImpl
|
||||
*/
|
||||
public function testPutListClearPageRanges()
|
||||
{
|
||||
|
@ -3358,6 +3360,93 @@ class BlobServiceFunctionalTest extends FunctionalTestBase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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::listPageBlobRangesDiff
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesDiffAsync
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsyncImpl
|
||||
*/
|
||||
public function testPutListClearPageRangesDiff()
|
||||
{
|
||||
$rangesArray = BlobServiceFunctionalTestData::getRangesDiffArray();
|
||||
$container = BlobServiceFunctionalTestData::getInterestingContainerName();
|
||||
$this->createContainer($container);
|
||||
$length = 2048;
|
||||
|
||||
foreach ($rangesArray as $array) {
|
||||
$blob = BlobServiceFunctionalTestData::getInterestingBlobName($container);
|
||||
$this->restProxy->createPageBlob($container, $blob, $length);
|
||||
$content = \openssl_random_pseudo_bytes($length);
|
||||
$this->restProxy->createBlobPages(
|
||||
$container,
|
||||
$blob,
|
||||
new Range(0, $length - 1),
|
||||
$content
|
||||
);
|
||||
|
||||
$snapshot = $this->restProxy->createBlobSnapshot($container, $blob)->getSnapshot();
|
||||
|
||||
$this->putListClearPageRangesDiffWorker(
|
||||
$container,
|
||||
$blob,
|
||||
$array['putRange'],
|
||||
$array['clearRange'],
|
||||
$array['listRange'],
|
||||
$array['resultListRange'],
|
||||
$snapshot,
|
||||
$length
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function putListClearPageRangesDiffWorker(
|
||||
$container,
|
||||
$blob,
|
||||
$putRange,
|
||||
$clearRange,
|
||||
$listRange,
|
||||
$resultListRange,
|
||||
$snapshot,
|
||||
$length
|
||||
) {
|
||||
if ($putRange != null) {
|
||||
$rangeLength = $putRange->getLength();
|
||||
if ($rangeLength == null) {
|
||||
$rangeLength = $length - $putRange->getStart();
|
||||
}
|
||||
$content = \openssl_random_pseudo_bytes($rangeLength);
|
||||
|
||||
$this->restProxy->createBlobPages(
|
||||
$container,
|
||||
$blob,
|
||||
$putRange,
|
||||
$content
|
||||
);
|
||||
}
|
||||
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->listPageBlobRangesDiff($container, $blob, $snapshot, $listRangeOptions);
|
||||
$this->assertEquals($length, $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
|
||||
|
|
|
@ -43,6 +43,7 @@ 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\RangeDiff;
|
||||
use MicrosoftAzure\Storage\Common\Models\Logging;
|
||||
use MicrosoftAzure\Storage\Common\Models\Metrics;
|
||||
use MicrosoftAzure\Storage\Common\Models\CORS;
|
||||
|
@ -1014,6 +1015,76 @@ class BlobServiceFunctionalTestData
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getRangesDiffArray()
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => null,
|
||||
'clearRange' => null,
|
||||
'listRange' => null,
|
||||
'resultListRange' => []
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => new Range(0, 511),
|
||||
'clearRange' => null,
|
||||
'listRange' => null,
|
||||
'resultListRange' => [new RangeDiff(0, 511)]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => new Range(1024, 1535),
|
||||
'clearRange' => null,
|
||||
'listRange' => null,
|
||||
'resultListRange' => [new RangeDiff(1024, 1535)]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => null,
|
||||
'clearRange' => new Range(1024, 1535),
|
||||
'listRange' => null,
|
||||
'resultListRange' => [new RangeDiff(1024, 1535, true)]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => new Range(0, 1023),
|
||||
'clearRange' => new Range(0, 511),
|
||||
'listRange' => null,
|
||||
'resultListRange' => [
|
||||
new RangeDiff(512, 1023),
|
||||
new RangeDiff(0, 511, true)
|
||||
]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => new Range(0, 2047),
|
||||
'clearRange' => null,
|
||||
'listRange' => new Range(0, 511),
|
||||
'resultListRange' => [new RangeDiff(0, 511)]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => new Range(0, 2047),
|
||||
'clearRange' => new Range(512, 1023),
|
||||
'listRange' => new Range(512, 1535),
|
||||
'resultListRange' => [
|
||||
new RangeDiff(1024, 1535),
|
||||
new RangeDiff(512, 1023, true)
|
||||
]
|
||||
];
|
||||
|
||||
$ret[] = [
|
||||
'putRange' => null,
|
||||
'clearRange' => new Range(0, 2047),
|
||||
'listRange' => null,
|
||||
'resultListRange' => [new RangeDiff(0, 2047, true)]
|
||||
];
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function getAppendBlockSetup()
|
||||
{
|
||||
$ret = array();
|
||||
|
|
|
@ -31,6 +31,7 @@ use MicrosoftAzure\Storage\Common\Internal\Resources;
|
|||
use MicrosoftAzure\Storage\Common\Internal\Utilities;
|
||||
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
|
||||
use MicrosoftAzure\Storage\Common\Models\Range;
|
||||
use MicrosoftAzure\Storage\Common\Models\RangeDiff;
|
||||
use MicrosoftAzure\Storage\Common\Models\ServiceProperties;
|
||||
use MicrosoftAzure\Storage\Blob\Models\AppendBlockOptions;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListContainersOptions;
|
||||
|
@ -1579,6 +1580,7 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase
|
|||
/**
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsync
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsyncImpl
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesResult::create
|
||||
*/
|
||||
public function testListPageBlobRanges()
|
||||
|
@ -1603,6 +1605,61 @@ class BlobRestProxyTest extends BlobServiceRestProxyTestBase
|
|||
$this->assertNotNull($result->getETag());
|
||||
$this->assertCount(1, $result->getRanges());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesDiff
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesDiffAsync
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRangesAsyncImpl
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::create
|
||||
*/
|
||||
public function testListPageBlobRangesDiff()
|
||||
{
|
||||
// Setup
|
||||
$name = 'listpageblobranges' . $this->createSuffix();
|
||||
$blob = 'myblob';
|
||||
$length = 512 * 8;
|
||||
$range = new Range(0, $length - 1);
|
||||
$content = Resources::EMPTY_STRING;
|
||||
$this->createContainer($name);
|
||||
$this->restProxy->createPageBlob($name, $blob, $length);
|
||||
|
||||
// Create snapshot for original page blob
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$content .= 'A';
|
||||
}
|
||||
$this->restProxy->createBlobPages($name, $blob, $range, $content);
|
||||
$snapshotResult = $this->restProxy->createBlobSnapshot($name, $blob);
|
||||
|
||||
// Clear range 0->511
|
||||
$clearRange = new Range(0, 511);
|
||||
$this->restProxy->clearBlobPages($name, $blob, $clearRange);
|
||||
|
||||
// Update range 512->1023
|
||||
$updateRange = new Range(512, 1023);
|
||||
$updateContent = Resources::EMPTY_STRING;
|
||||
for ($i = 0; $i < 512; $i++) {
|
||||
$updateContent .= 'B';
|
||||
}
|
||||
$this->restProxy->createBlobPages($name, $blob, $updateRange, $updateContent);
|
||||
|
||||
// Clear range 1024->1535
|
||||
$clearRange = new Range(1024, 1535);
|
||||
$this->restProxy->clearBlobPages($name, $blob, $clearRange);
|
||||
|
||||
$exceptedRangesDiff = [
|
||||
new RangeDiff(512, 1023, false),
|
||||
new RangeDiff(0, 511, true),
|
||||
new RangeDiff(1024, 1535, true)
|
||||
];
|
||||
|
||||
// Test
|
||||
$result = $this->restProxy->listPageBlobRangesDiff($name, $blob, $snapshotResult->getSnapshot());
|
||||
|
||||
// Assert
|
||||
$this->assertNotNull($result->getETag());
|
||||
$this->assertCount(3, $result->getRanges());
|
||||
$this->assertEquals($exceptedRangesDiff, $result->getRanges());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listPageBlobRanges
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: The MIT License (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://github.com/azure/azure-storage-php/LICENSE
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Tests\Unit\Blob\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @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\unit\Blob\Models;
|
||||
|
||||
use MicrosoftAzure\Storage\Common\Internal\Utilities;
|
||||
use MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult;
|
||||
use MicrosoftAzure\Storage\Common\Models\RangeDiff;
|
||||
use MicrosoftAzure\Storage\Tests\Framework\TestResources;
|
||||
|
||||
/**
|
||||
* Unit tests for class ListPageBlobRangesDiffResult
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Tests\Unit\Blob\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @copyright 2017 Microsoft Corporation
|
||||
* @license https://github.com/azure/azure-storage-php/LICENSE
|
||||
* @link https://github.com/azure/azure-storage-php
|
||||
*/
|
||||
class ListPageBlobRangesDiffResultTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::getRanges
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::setRanges
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::setContentLength
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::getContentLength
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::setETag
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::getETag
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::setLastModified
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::getLastModified
|
||||
* @covers MicrosoftAzure\Storage\Blob\Models\ListPageBlobRangesDiffResult::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
// Setup
|
||||
$headers = TestResources::listPageRangeHeaders();
|
||||
$bodyArray = TestResources::listPageRangeDiffBodyInArray();
|
||||
// Prepare expected page range
|
||||
$rawPageRanges = array();
|
||||
if (!empty($bodyArray['PageRange'])) {
|
||||
$rawPageRanges = Utilities::getArray($bodyArray['PageRange']);
|
||||
}
|
||||
|
||||
$rawClearRanges = array();
|
||||
if (!empty($bodyArray['ClearRange'])) {
|
||||
$rawClearRanges = Utilities::getArray($bodyArray['ClearRange']);
|
||||
}
|
||||
|
||||
$pageRanges = array();
|
||||
|
||||
foreach ($rawPageRanges as $value) {
|
||||
$pageRanges[] = new RangeDiff(
|
||||
intval($value['Start']),
|
||||
intval($value['End']),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($rawClearRanges as $value) {
|
||||
$rawClearRanges[] = new RangeDiff(
|
||||
intval($value['Start']),
|
||||
intval($value['End']),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// Prepare expected last modified date
|
||||
$expectedLastModified = Utilities::rfc1123ToDateTime($headers['Last-Modified']);
|
||||
|
||||
// Test
|
||||
$result = ListPageBlobRangesDiffResult::create($headers, $bodyArray);
|
||||
|
||||
//Assert
|
||||
$this->assertEquals($pageRanges, $result->getRanges());
|
||||
$this->assertEquals($expectedLastModified, $result->getLastModified());
|
||||
$this->assertEquals($headers['Etag'], $result->getETag());
|
||||
$this->assertEquals($headers['x-ms-blob-content-length'], $result->getContentLength());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: The MIT License (the "License")
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://github.com/azure/azure-storage-php/LICENSE
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Tests\Unit\Common\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @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\unit\Common\Models;
|
||||
|
||||
use MicrosoftAzure\Storage\Common\Models\RangeDiff;
|
||||
|
||||
/**
|
||||
* Unit tests for class RangeDiff
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package MicrosoftAzure\Storage\Tests\Unit\Common\Models
|
||||
* @author Azure Storage PHP SDK <dmsh@microsoft.com>
|
||||
* @copyright 2017 Microsoft Corporation
|
||||
* @license https://github.com/azure/azure-storage-php/LICENSE
|
||||
* @link https://github.com/azure/azure-storage-php
|
||||
*/
|
||||
class RangeDiffTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @covers MicrosoftAzure\Storage\Common\Models\RangeDiff::__construct
|
||||
* @covers MicrosoftAzure\Storage\Common\Models\RangeDiff::getStart
|
||||
* @covers MicrosoftAzure\Storage\Common\Models\RangeDiff::getEnd
|
||||
*/
|
||||
public function testConstruct()
|
||||
{
|
||||
// Setup
|
||||
$expectedStart = 0;
|
||||
$expectedEnd = 512;
|
||||
$expectedIsClearedPageRange = false;
|
||||
|
||||
// Test
|
||||
$actual = new RangeDiff($expectedStart, $expectedEnd, $expectedIsClearedPageRange);
|
||||
|
||||
// Assert
|
||||
$this->assertEquals($expectedStart, $actual->getStart());
|
||||
$this->assertEquals($expectedEnd, $actual->getEnd());
|
||||
$this->assertEquals($expectedIsClearedPageRange, $actual->isClearedPageRange());
|
||||
|
||||
return $actual;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MicrosoftAzure\Storage\Common\Models\RangeDiff::setIsClearedPageRange
|
||||
* @covers MicrosoftAzure\Storage\Common\Models\RangeDiff::isClearedPageRange
|
||||
* @depends testConstruct
|
||||
*/
|
||||
public function testIsClearedPageRange($obj)
|
||||
{
|
||||
// Setup
|
||||
$excepted = true;
|
||||
$obj->setIsClearedPageRange($excepted);
|
||||
|
||||
// Test
|
||||
$actual = $obj->isClearedPageRange();
|
||||
|
||||
// Assert
|
||||
$this->assertEquals($excepted, $actual);
|
||||
|
||||
// Setup
|
||||
$excepted = false;
|
||||
$obj->setIsClearedPageRange($excepted);
|
||||
|
||||
// Test
|
||||
$actual = $obj->isClearedPageRange();
|
||||
|
||||
// Assert
|
||||
$this->assertEquals($excepted, $actual);
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче