From 28cb3a5377c2b76e35258e995930ba1fbea9bf13 Mon Sep 17 00:00:00 2001 From: Diego Luces Date: Fri, 10 Nov 2017 10:26:36 -0700 Subject: [PATCH 01/12] Do not set blob md5 to the block md5 --- src/Blob/Models/CreateBlobBlockOptions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Blob/Models/CreateBlobBlockOptions.php b/src/Blob/Models/CreateBlobBlockOptions.php index f19c5a3b9..d4bbe8589 100644 --- a/src/Blob/Models/CreateBlobBlockOptions.php +++ b/src/Blob/Models/CreateBlobBlockOptions.php @@ -92,7 +92,6 @@ public static function create(CreateBlobOptions $createBlobOptions) { $result = new CreateBlobBlockOptions(); $result->setTimeout($createBlobOptions->getTimeout()); - $result->setContentMD5($createBlobOptions->getContentMD5()); $result->setLeaseId($createBlobOptions->getLeaseId()); $result->setNumberOfConcurrency( $createBlobOptions->getNumberOfConcurrency() From 8d23974580dcd7ea5706628918e096df07d9505d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Fri, 8 Dec 2017 17:04:29 +0100 Subject: [PATCH 02/12] Import Resources from correct namespace MicrosoftAzure\Storage\Common\Internal\Logger was moved to MicrosoftAzure\Storage\Common\Logger --- src/Common/Logger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Common/Logger.php b/src/Common/Logger.php index 96f06e9d6..0441ab076 100644 --- a/src/Common/Logger.php +++ b/src/Common/Logger.php @@ -24,6 +24,8 @@ namespace MicrosoftAzure\Storage\Common; +use MicrosoftAzure\Storage\Common\Internal\Resources; + /** * Logger class for debugging purpose. * From 84b96caf486ecdf1fa5c75ec050360632b6f09cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Sat, 30 Dec 2017 19:39:41 +0100 Subject: [PATCH 03/12] Change type according to EdmType specified when serializing Fixes #114 --- src/Table/Models/EdmType.php | 8 ++++-- tests/Unit/Table/Models/EdmTypeTest.php | 34 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/Table/Models/EdmType.php b/src/Table/Models/EdmType.php index 06044b6dd..facb18614 100644 --- a/src/Table/Models/EdmType.php +++ b/src/Table/Models/EdmType.php @@ -170,12 +170,16 @@ public static function validateEdmValue($type, $value, &$condition = null) public static function serializeValue($type, $value) { switch ($type) { + case null: + return $value; + case EdmType::INT32: + return intval($value); + case EdmType::INT64: case EdmType::GUID: case EdmType::STRING: - case null: - return $value; + return strval($value); case EdmType::DOUBLE: return strval($value); diff --git a/tests/Unit/Table/Models/EdmTypeTest.php b/tests/Unit/Table/Models/EdmTypeTest.php index b6a4d26de..96eeeeac2 100644 --- a/tests/Unit/Table/Models/EdmTypeTest.php +++ b/tests/Unit/Table/Models/EdmTypeTest.php @@ -348,6 +348,40 @@ public function testSerializeValueWithInt() $this->assertEquals($expected, $actual); } + /** + * @covers MicrosoftAzure\Storage\Table\Models\EdmType::serializeValue + */ + public function testSerializeValueWithIntAsString() + { + // Setup + $type = EdmType::INT32; + $value = '123'; + $expected = 123; + + // Test + $actual = EdmType::serializeValue($type, $value); + + // Assert + $this->assertSame($expected, $actual); + } + + /** + * @covers MicrosoftAzure\Storage\Table\Models\EdmType::serializeValue + */ + public function testSerializeValueWithStringAsInt() + { + // Setup + $type = EdmType::STRING; + $value = 123; + $expected = '123'; + + // Test + $actual = EdmType::serializeValue($type, $value); + + // Assert + $this->assertSame($expected, $actual); + } + /** * @covers MicrosoftAzure\Storage\Table\Models\EdmType::serializeValue */ From 95fe06479335c0ee521d2638f39e0089a9796fa7 Mon Sep 17 00:00:00 2001 From: Xiaoning Liu Date: Wed, 13 Dec 2017 17:24:19 +0800 Subject: [PATCH 04/12] Fixed BlobRestProxy::breakLease ignore breakPeriod parameter bug --- src/Blob/BlobRestProxy.php | 14 +++++++++----- .../Functional/Blob/BlobServiceFunctionalTest.php | 2 +- .../Functional/Blob/BlobServiceIntegrationTest.php | 2 +- tests/Unit/Blob/BlobRestProxyTest.php | 5 ++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Blob/BlobRestProxy.php b/src/Blob/BlobRestProxy.php index 8f5a690e5..61bf93996 100644 --- a/src/Blob/BlobRestProxy.php +++ b/src/Blob/BlobRestProxy.php @@ -433,8 +433,8 @@ private function addOptionalRangeHeader(array $headers, $start, $end) * Get the expected status code of a given lease action. * * @param string $leaseAction The given lease action - * * @return string + * @throws \Exception */ private static function getStatusCodeOfLeaseAction($leaseAction) { @@ -465,7 +465,10 @@ private static function getStatusCodeOfLeaseAction($leaseAction) * @param string $leaseAction Lease action string. * @param string $container Container name. * @param string $blob Blob to lease name. + * @param string $proposedLeaseId Proposed lease id. + * @param int $leaseDuration Lease duration, in seconds. * @param string $leaseId Existing lease id. + * @param int $breakPeriod Break period, in seconds. * @param string $expectedStatusCode Expected status code. * @param Models\BlobServiceOptions $options Optional parameters. * @param Models\AccessCondition $accessCondition Access conditions. @@ -492,7 +495,6 @@ private function putLeaseAsyncImpl( $headers = array(); $queryParams = array(); $postParams = array(); - $path; if (empty($blob)) { $path = $this->createPath($container); @@ -4299,6 +4301,7 @@ public function breakLease( return $this->breakLeaseAsync( $container, $blob, + $breakPeriod, $options )->wait(); } @@ -4307,9 +4310,10 @@ public function breakLease( * Creates promise to end the lease but ensure that another client cannot * acquire a new lease until the current lease period has expired. * - * @param string $container name of the container - * @param string $blob name of the blob - * @param Models\BlobServiceOptions $options optional parameters + * @param string $container name of the container + * @param string $blob name of the blob + * @param int $breakPeriod break period, in seconds + * @param Models\BlobServiceOptions $options optional parameters * * @return \GuzzleHttp\Promise\PromiseInterface * diff --git a/tests/Functional/Blob/BlobServiceFunctionalTest.php b/tests/Functional/Blob/BlobServiceFunctionalTest.php index dd29f6a70..58a447c60 100644 --- a/tests/Functional/Blob/BlobServiceFunctionalTest.php +++ b/tests/Functional/Blob/BlobServiceFunctionalTest.php @@ -3630,7 +3630,7 @@ public function testLeaseOperations() } 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); + $this->assertContains('There is already a lease present.', $message); \sleep(10); $this->restProxy->acquireLease($container, $blob, $leaseId); $options = new DeleteBlobOptions(); diff --git a/tests/Functional/Blob/BlobServiceIntegrationTest.php b/tests/Functional/Blob/BlobServiceIntegrationTest.php index b737522b2..8e501f4b8 100644 --- a/tests/Functional/Blob/BlobServiceIntegrationTest.php +++ b/tests/Functional/Blob/BlobServiceIntegrationTest.php @@ -1715,7 +1715,7 @@ public function testBreakLeaseWorks() $content = 'some content2'; $this->restProxy->createBlockBlob(self::$_test_container_for_blobs, 'test6', $content); $leaseId = $this->restProxy->acquireLease(self::$_test_container_for_blobs, 'test6')->getLeaseId(); - $this->restProxy->breakLease(self::$_test_container_for_blobs, 'test6', $leaseId); + $this->restProxy->breakLease(self::$_test_container_for_blobs, 'test6'); $this->restProxy->releaseLease(self::$_test_container_for_blobs, 'test6', $leaseId); // Assert diff --git a/tests/Unit/Blob/BlobRestProxyTest.php b/tests/Unit/Blob/BlobRestProxyTest.php index 521632b0d..4c3cc9c12 100644 --- a/tests/Unit/Blob/BlobRestProxyTest.php +++ b/tests/Unit/Blob/BlobRestProxyTest.php @@ -24,6 +24,7 @@ namespace MicrosoftAzure\Storage\Tests\Unit\Blob; +use MicrosoftAzure\Storage\Blob\Models\BlobServiceOptions; use MicrosoftAzure\Storage\Tests\Framework\VirtualFileSystem; use MicrosoftAzure\Storage\Tests\Framework\BlobServiceRestProxyTestBase; use MicrosoftAzure\Storage\Tests\Framework\TestResources; @@ -1441,7 +1442,7 @@ public function testAcquireContainerLease() $this->assertEquals($proposedLeaseId, $result->getLeaseId()); // Break the lease so that the clean-up can delete the container - $result = $this->restProxy->breakLease($name, null, $result->getLeaseId()); + $result = $this->restProxy->breakLease($name, null, null); } /** @@ -1543,8 +1544,6 @@ public function testBreakLease() // Assert $this->assertInstanceOf('MicrosoftAzure\Storage\Blob\Models\BreakLeaseResult', $result); $this->assertNotNull($result->getLeaseTime()); - $result = $this->restProxy->acquireLease($name, $blob); - $this->assertNotNull($result->getLeaseId()); } /** From 51742add3d2d4c12d6072fb3b120bbec2c5bb539 Mon Sep 17 00:00:00 2001 From: Xiaoning Liu Date: Wed, 13 Dec 2017 16:59:36 +0800 Subject: [PATCH 05/12] Cleanup build.xml and remove phpdox dependency --- build.xml | 73 ++++++++++++++++++++----------------- composer.json | 1 - phpunit.functional.xml.dist | 28 -------------- phpunit.xml.dist | 7 +++- 4 files changed, 45 insertions(+), 64 deletions(-) delete mode 100644 phpunit.functional.xml.dist diff --git a/build.xml b/build.xml index 12ec8abb4..b35a0c039 100644 --- a/build.xml +++ b/build.xml @@ -1,10 +1,10 @@ +