diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..35b72866c --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,45 @@ +# PHP +# Test and package your PHP project. +# Add steps that run tests, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/php + +pr: +- master +- dev + +pool: + vmImage: 'Ubuntu-16.04' + +variables: + phpVersion: 7.0 + +steps: +- script: | + sudo update-alternatives --set php /usr/bin/php$(phpVersion) + sudo update-alternatives --set phar /usr/bin/phar$(phpVersion) + sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion) + sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion) + sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion) + php -version + displayName: 'Use PHP version $(phpVersion)' + +- script: composer install --no-interaction --prefer-dist + displayName: 'composer install' + +- script: php clean_up.php + env: { AZURE_STORAGE_CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING), + AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT: $(AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT), + AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT: $(AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT)} + displayName: 'clean up test environment' + + +- task: Ant@1 + inputs: + antBuildFile: 'build.linux.xml' + options: + targets: 'full-build-parallel' + publishJUnitResults: false + env: { AZURE_STORAGE_CONNECTION_STRING: $(AZURE_STORAGE_CONNECTION_STRING), + AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT: $(AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT), + AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT: $(AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT)} + diff --git a/azure-storage-table/src/Table/Models/BatchResult.php b/azure-storage-table/src/Table/Models/BatchResult.php index bc01addcd..0c3b42059 100644 --- a/azure-storage-table/src/Table/Models/BatchResult.php +++ b/azure-storage-table/src/Table/Models/BatchResult.php @@ -67,8 +67,7 @@ private static function _constructResponses($body, IMimeReaderWriter $mimeSerial $response = new \stdClass(); // Split lines - $lines = explode("\r\n", $parts[$i]); - + $lines = preg_split("/\\r\\n|\\r|\\n/", $parts[$i]); // Version Status Reason $statusTokens = explode(' ', $lines[0], 3); $response->version = $statusTokens[0]; @@ -84,7 +83,7 @@ private static function _constructResponses($body, IMimeReaderWriter $mimeSerial isset($headerTokens[1]) ? trim($headerTokens[1]) : null; } while (Resources::EMPTY_STRING != $headerLine); $response->headers = $headers; - $response->body = implode("\r\n", array_slice($lines, $j)); + $response->body = implode(PHP_EOL, array_slice($lines, $j)); $responses[] = $response; } @@ -134,7 +133,6 @@ public static function create( $callbackName = __CLASS__ . '::_compareUsingContentId'; $count = count($responses); $entries = array(); - // Sort $responses based on Content-ID so they match order of $operations. uasort($responses, $callbackName); diff --git a/build.linux.xml b/build.linux.xml new file mode 100644 index 000000000..125108abb --- /dev/null +++ b/build.linux.xml @@ -0,0 +1,407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/clean_up.php b/clean_up.php new file mode 100644 index 000000000..e1e72d435 --- /dev/null +++ b/clean_up.php @@ -0,0 +1,88 @@ + + * @copyright 2019 Microsoft Corporation + * @license https://github.com/azure/azure-storage-php/LICENSE + * @link https://github.com/azure/azure-storage-php + */ + +require_once "./vendor/autoload.php"; + +use MicrosoftAzure\Storage\Blob\BlobRestProxy; +use MicrosoftAzure\Storage\File\FileRestProxy; +use MicrosoftAzure\Storage\Table\TableRestProxy; +use MicrosoftAzure\Storage\Queue\QueueRestProxy; + +$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING"); +$blobClient = BlobRestProxy::createBlobService($connectionString); +$queueClient = QueueRestProxy::createQueueService($connectionString); +$fileClient = FileRestProxy::createFileService($connectionString); +$tableClient = TableRestProxy::createTableService($connectionString); + +//clean up containers +$result = $blobClient->listContainers(); + +foreach ($result->getContainers() as $container) { + $blobClient->deleteContainer($container->getName()); +} + +//clean up queues +$result = $queueClient->listQueues(); +foreach ($result->getQueues() as $queue) { + $queueClient->deleteQueue($queue->getName()); +} + +//clean up fileshares +$result = $fileClient->listShares(); +foreach ($result->getShares() as $share) { + $fileClient->deleteShare($share->getName()); +} + +//clean up tables +$result = $tableClient->queryTables(); +foreach ($result->getTables() as $table) { + $tableClient->deleteTable($table); +} + +//clean up premium blobs +$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING_PREMIUM_ACCOUNT"); + +if (!empty($connectionString)) { + $blobClient = BlobRestProxy::createBlobService($connectionString); + + //clean up containers + $result = $blobClient->listContainers(); + + foreach ($result->getContainers() as $container) { + $blobClient->deleteContainer($container->getName()); + } +} + + +//clean up blob storage blobs +$connectionString = \getenv("AZURE_STORAGE_CONNECTION_STRING_BLOB_ACCOUNT"); + +if (!empty($connectionString)) { + $blobClient = BlobRestProxy::createBlobService($connectionString); + + //clean up containers + $result = $blobClient->listContainers(); + + foreach ($result->getContainers() as $container) { + $blobClient->deleteContainer($container->getName()); + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index b71bb2026..16f5d7fd8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ }, "require-dev": { "phpunit/phpunit": "~4.8.35", - "mikey179/vfsStream": "~1.6", + "mikey179/vfsstream": "~1.6", "pdepend/pdepend" : "~2.2", "sebastian/phpcpd": "~2.0", "squizlabs/php_codesniffer": "@stable", diff --git a/tests/Functional/Queue/QueueServiceFunctionalTest.php b/tests/Functional/Queue/QueueServiceFunctionalTest.php index 1d4e0e13b..e62f27396 100644 --- a/tests/Functional/Queue/QueueServiceFunctionalTest.php +++ b/tests/Functional/Queue/QueueServiceFunctionalTest.php @@ -799,7 +799,7 @@ public function testCreateMessageWithSmallTTL() public function testCreateMessage() { - $interestingTimes = array( null, -1, 0, QueueServiceFunctionalTestData::INTERESTING_TTL, 1000 ); + $interestingTimes = array( null, -2, 0, QueueServiceFunctionalTestData::INTERESTING_TTL, 1000 ); foreach ($interestingTimes as $timeToLiveInSeconds) { foreach ($interestingTimes as $visibilityTimeoutInSeconds) { $timeout = null; diff --git a/tests/Unit/Blob/BlobRestProxyTest.php b/tests/Unit/Blob/BlobRestProxyTest.php index ab7c05920..c0f340963 100644 --- a/tests/Unit/Blob/BlobRestProxyTest.php +++ b/tests/Unit/Blob/BlobRestProxyTest.php @@ -2073,7 +2073,7 @@ public function testsaveBlobToFileWithInvalidPath() // Test //get the path for the file to be downloaded into. $uuid = uniqid('test-file-', true); - $downloadPath = 'Zasdf:\\\\\\\\Invalid.PATH'.$uuid.'.txt'; + $downloadPath = '\0/0@$%@!Zasdf:\\\\\\\\Invalid.PATH'.$uuid.'.txt'; error_reporting(E_ALL ^ E_WARNING); try { $result = $this->restProxy->saveBlobToFile($downloadPath, $name, $blob);