Skip to content

Commit

Permalink
Merge pull request #12 from squigg/7.x
Browse files Browse the repository at this point in the history
Support for Laravel 7.x
  • Loading branch information
squigg authored Jun 4, 2020
2 parents f3ffc90 + f4df89f commit c70c57b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 56 deletions.
57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,47 @@ 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

### Install using composer
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`):
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
51 changes: 24 additions & 27 deletions tests/AzureQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class AzureQueueTest extends TestCase
{

/**
* @var \Mockery\Mock
*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -77,28 +78,23 @@ 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');
}

/** @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');
}

Expand All @@ -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 */
Expand Down

0 comments on commit c70c57b

Please sign in to comment.