diff --git a/README.md b/README.md index 3522522..f2b72a2 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,12 @@ PHP Laravel Queue Driver package to support Microsoft Azure Storage Queues ## Prerequisites -- PHP 5.6+, PHP 7+ for Laravel 5.5+, PHP 7.1+ for Laravel 5.6+ +- PHP 5.6+, PHP 7+ for Laravel 5.5+, PHP 7.1+ for Laravel 5.6+, PHP 7.2+ for Laravel 6+ - Laravel 5.2 - 7.x (not tested on previous versions) -- Microsoft Azure Storage account and API key -- Queue container created through Azure Portal or via Azure CLI / PowerShell +- Microsoft Azure Storage Account and Storage Account Key +- Queue container created through Azure Portal or via +[Azure CLI](https://docs.microsoft.com/en-us/cli/azure/storage/queue?view=azure-cli-latest#az-storage-queue-create) +or [PowerShell](https://docs.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues#create-a-queue) ## Installation @@ -22,31 +24,34 @@ PHP Laravel Queue Driver package to support Microsoft Azure Storage Queues You can find this library on [Packagist](https://packagist.org/packages/squigg/azure-queue-laravel). Require this package in your `composer.json`. The version numbers will follow Laravel. -#### Laravel 5.2.x - "squigg/azure-queue-laravel": "5.2.*" - composer require squigg/azure-queue-laravel:5.2.* -#### Laravel 5.3.x - "squigg/azure-queue-laravel": "5.3.*" - composer require squigg/azure-queue-laravel:5.3.* -#### Laravel 5.4.x - "squigg/azure-queue-laravel": "5.4.*" - composer require squigg/azure-queue-laravel:5.4.* -#### Laravel 5.5.x - "squigg/azure-queue-laravel": "5.5.*" - composer require squigg/azure-queue-laravel:5.5.* -#### Laravel 5.6.x - "squigg/azure-queue-laravel": "5.6.*" - composer require squigg/azure-queue-laravel:5.6.* -#### Laravel 5.7.x - "squigg/azure-queue-laravel": "5.7.*" - composer require squigg/azure-queue-laravel:5.7.* +#### Laravel 7.x + "squigg/azure-queue-laravel": "^7.0" + composer require squigg/azure-queue-laravel:^7.0 +#### Laravel 6.x + "squigg/azure-queue-laravel": "^6.0" + composer require squigg/azure-queue-laravel:^6.0 #### Laravel 5.8.x "squigg/azure-queue-laravel": "5.8.*" composer require squigg/azure-queue-laravel:5.8.* -#### Laravel 6.x - "squigg/azure-queue-laravel": "6.*" - composer require squigg/azure-queue-laravel:6.* - +#### Laravel 5.7.x + "squigg/azure-queue-laravel": "5.7.*" + composer require squigg/azure-queue-laravel:5.7.* +#### Laravel 5.6.x + "squigg/azure-queue-laravel": "5.6.*" + composer require squigg/azure-queue-laravel:5.6.* +#### Laravel 5.5.x + "squigg/azure-queue-laravel": "5.5.*" + composer require squigg/azure-queue-laravel:5.5.* +#### Laravel 5.4.x + "squigg/azure-queue-laravel": "5.4.*" + composer require squigg/azure-queue-laravel:5.4.* +#### Laravel 5.3.x + "squigg/azure-queue-laravel": "5.3.*" + composer require squigg/azure-queue-laravel:5.3.* +#### Laravel 5.2.x + "squigg/azure-queue-laravel": "5.2.*" + composer require squigg/azure-queue-laravel:5.2.* + ##### For versions 5.3 and older only Add the following pear repository in your `composer.json` file required for the Microsoft Azure SDK (v5.4+ uses the `microsoft/azure-storage` package instead, and v5.6+ uses `microsoft/azure-storage-queue`): @@ -107,6 +112,8 @@ Remember to update the default queue by setting the `QUEUE_DRIVER` value in your ## Changelog +2020-06-04 - V7.0 - Support for Laravel 7.x (composer dependency and test refactoring only) + 2020-06-04 - V6.0 - Support for Laravel 6.x (composer dependency changes only) 2019-07-13 - V5.8 - Support for Laravel 5.8 (composer dependency and test changes only) diff --git a/composer.json b/composer.json index 1ddbbd5..cc65700 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,16 @@ } ], "require": { - "php": "^7.2", - "illuminate/queue": "^6.0", + "php": "^7.2.5", + "illuminate/queue": "^7.0", "microsoft/azure-storage-queue": "~1.3.0" }, "require-dev": { "phpunit/phpunit": "^8.0|^9.0", - "orchestra/testbench": "^4.0", + "orchestra/testbench": "^5.0", "mockery/mockery": "~1.0", - "php-coveralls/php-coveralls": "~2.0" + "php-coveralls/php-coveralls": "~2.0", + "ext-json": "*" }, "autoload": { "psr-4": { diff --git a/tests/AzureQueueTest.php b/tests/AzureQueueTest.php index 0b18067..a92ee06 100644 --- a/tests/AzureQueueTest.php +++ b/tests/AzureQueueTest.php @@ -9,6 +9,7 @@ class AzureQueueTest extends TestCase { + /** * @var \Mockery\Mock */ @@ -39,11 +40,11 @@ protected function setListMessagesReturnExpectation($mock, $count = 1) /** @test */ public function it_can_push_message_to_queue() { - $this->azure->shouldReceive('createMessage')->once()->withArgs([ - "myqueue", - '{"displayName":"job","job":"job","maxTries":null,"delay":null,"timeout":null,"data":"data"}' - ]); - $this->queue->push('job', 'data'); + $this->azure->shouldReceive('createMessage')->once()->withArgs(function ($queue, $payload) { + $payload = json_decode($payload, true); + return $queue == "myqueue" && $payload['displayName'] == 'foojob' && $payload['job'] == 'foojob' && $payload['data'] == 'bardata'; + }); + $this->queue->push('foojob', 'bardata'); } /** @test */ @@ -77,13 +78,11 @@ public function it_returns_null_if_no_messages_to_pop() /** @test */ public function it_passes_visibility_timeout_set_in_config() { - $this->setListMessagesReturnExpectation( - $this->azure->shouldReceive('listMessages')->once()->withArgs( - function ($queue, ListMessagesOptions $options) { - return $queue == 'myqueue' && $options->getVisibilityTimeoutInSeconds() == 5; - } - ) - ); + $mockClient = $this->azure->shouldReceive('listMessages')->once()->withArgs(function ($queue, + ListMessagesOptions $options) { + return $queue == 'myqueue' && $options->getVisibilityTimeoutInSeconds() == 5; + }); + $this->setListMessagesReturnExpectation($mockClient); $this->queue->pop('myqueue'); } @@ -91,14 +90,11 @@ function ($queue, ListMessagesOptions $options) { /** @test */ public function it_only_fetches_first_message() { - $this->setListMessagesReturnExpectation( - $this->azure->shouldReceive('listMessages')->once()->withArgs( - function ($queue, ListMessagesOptions $options) { - return $queue == 'myqueue' && $options->getNumberOfMessages() == 1; - } - ) - ); - + $mockClient = $this->azure->shouldReceive('listMessages')->once()->withArgs(function ($queue, + ListMessagesOptions $options) { + return $queue == 'myqueue' && $options->getNumberOfMessages() == 1; + }); + $this->setListMessagesReturnExpectation($mockClient); $this->queue->pop('myqueue'); } @@ -111,13 +107,14 @@ public function it_can_get_visibility_timeout() /** @test */ public function it_can_queue_a_job_for_later() { - $this->azure->shouldReceive('createMessage')->once()->withArgs( - function ($queue, $payload, CreateMessageOptions $options) { - return $queue == 'myqueue' && $payload == '{"displayName":"job","job":"job","maxTries":null,"delay":null,"timeout":null,"data":"data"}' && $options->getVisibilityTimeoutInSeconds() == 10; - } - ); - - $this->queue->later(10, 'job', 'data', 'myqueue'); + $this->azure->shouldReceive('createMessage')->once()->withArgs(function ($queue, + $payload, + CreateMessageOptions $options) { + $payload = json_decode($payload, true); + return $queue == "myqueue" && $payload['displayName'] == 'foojob' && $payload['job'] == 'foojob' && $payload['data'] == 'bardata' && $options->getVisibilityTimeoutInSeconds() == 10; + }); + + $this->queue->later(10, 'foojob', 'bardata', 'myqueue'); } /** @test */