Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PHP Laravel Queue Driver package to support Microsoft Azure Storage Queues
- PHP 8.0+ for Laravel 9+
- PHP 8.1+ for Laravel 10+
- PHP 8.1+ for Laravel 11+
- PHP 8.2+ for Laravel 12+
- 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)
Expand All @@ -32,6 +33,9 @@ You can find this library on [Packagist](https://packagist.org/packages/squigg/a

Require this package in your `composer.json`. The version numbers will follow Laravel.

#### Laravel 12.x
"squigg/azure-queue-laravel": "^12.0"
composer require squigg/azure-queue-laravel:^12.0
#### Laravel 11.x
"squigg/azure-queue-laravel": "^11.0"
composer require squigg/azure-queue-laravel:^11.0
Expand Down Expand Up @@ -136,7 +140,9 @@ Remember to update the default queue by setting the `QUEUE_DRIVER` value in your

## Changelog

2023-03-30 - V11.0 - Support for Laravel 11.x
2025-07-25 - V11.0 - Support for Laravel 12.x

2024-03-30 - V11.0 - Support for Laravel 11.x

2023-03-17 - V10.0 - Support for Laravel 10.x

Expand Down
35 changes: 18 additions & 17 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<!-- List of source files for code coverage checker -->
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<logging/>
<!-- List of files with tests inside -->
<testsuites>
<testsuite name="Package Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<phpunit beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true"
cacheDirectory=".phpunit.cache">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<coverage>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<logging/>
<testsuites>
<testsuite name="Package Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
7 changes: 4 additions & 3 deletions tests/AzureConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use MicrosoftAzure\Storage\Queue\QueueRestProxy;
use Mockery;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\Test;
use Squigg\AzureQueueLaravel\AzureConnector;
use Squigg\AzureQueueLaravel\AzureQueue;

Expand All @@ -31,7 +32,7 @@ protected function setUp(): void
$this->queueRestProxy = Mockery::mock('alias:' . QueueRestProxy::class);
}

/** @test */
#[Test]
public function it_can_create_azure_queue()
{
$connectionString = 'DefaultEndpointsProtocol=https;AccountName=foo;AccountKey=bar';
Expand All @@ -44,7 +45,7 @@ public function it_can_create_azure_queue()
$this->assertEquals(25, $azureQueue->getVisibilityTimeout());
}

/** @test */
#[Test]
public function it_can_create_azure_queue_with_endpoint()
{
$this->config['endpoint'] = 'mysuffix';
Expand All @@ -57,7 +58,7 @@ public function it_can_create_azure_queue_with_endpoint()
$this->connector->connect($this->config);
}

/** @test */
#[Test]
public function it_can_create_azure_queue_with_queue_endpoint()
{
$this->config['queue_endpoint'] = 'http://localhost:10001/test';
Expand Down
18 changes: 9 additions & 9 deletions tests/AzureJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use MicrosoftAzure\Storage\Queue\Internal\IQueue;
use MicrosoftAzure\Storage\Queue\Models\QueueMessage;
use Mockery;
use Mockery\Mock;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\Test;
use Squigg\AzureQueueLaravel\AzureJob;
use Squigg\AzureQueueLaravel\AzureQueue;

Expand Down Expand Up @@ -34,51 +34,51 @@ protected function setUp(): void
$this->job = new AzureJob($this->app, $this->azure, $this->message, 'myconnection', 'myqueue');
}

/** @test */
#[Test]
public function it_can_get_job_id()
{
$this->assertEquals('1234', $this->job->getJobId());
}

/** @test */
#[Test]
public function it_can_delete_job_from_queue()
{
$this->azure->shouldReceive('deleteMessage')->once()->withArgs(['myqueue', '1234', '9876']);
$this->job->delete();
}

/** @test */
#[Test]
public function it_can_release_job_back_to_queue()
{
$this->azure->shouldReceive('updateMessage')->once()->withArgs(['myqueue', '1234', '9876', null, 10]);
$this->job->release(10);
}

/** @test */
#[Test]
public function it_can_get_azure_job()
{
$this->assertEquals($this->message, $this->job->getAzureJob());
}

/** @test */
#[Test]
public function it_can_get_raw_body()
{
$this->assertEquals('{"abcd":"efgh"}', $this->job->getRawBody());
}

/** @test */
#[Test]
public function it_can_get_azure_proxy()
{
$this->assertInstanceOf(IQueue::class, $this->job->getAzure());
}

/** @test */
#[Test]
public function it_can_get_number_of_attempts()
{
$this->assertEquals(2, $this->job->attempts());
}

/** @test */
#[Test]
public function it_can_get_app_container()
{
$this->assertEquals($this->app, $this->job->getContainer());
Expand Down
3 changes: 2 additions & 1 deletion tests/AzureQueueServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
use Illuminate\Foundation\Application;
use Illuminate\Queue\QueueManager;
use Mockery;
use PHPUnit\Framework\Attributes\Test;
use Squigg\AzureQueueLaravel\AzureConnector;
use Squigg\AzureQueueLaravel\AzureQueueServiceProvider;

class AzureQueueServiceProviderTest extends TestCase
{

/** @test */
#[Test]
public function it_can_boot_and_setup_queue_manager()
{
$mockApp = Mockery::mock(Application::class);
Expand Down
21 changes: 11 additions & 10 deletions tests/AzureQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Mockery;
use Mockery\ExpectationInterface;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\Test;
use Squigg\AzureQueueLaravel\AzureJob;
use Squigg\AzureQueueLaravel\AzureQueue;
use Squigg\AzureQueueLaravel\Tests\Fixtures\ListMessagesResult;
Expand All @@ -32,7 +33,7 @@ protected function setListMessagesReturnExpectation(ExpectationInterface $mock,
return $mock->andReturn(new ListMessagesResult($count));
}

/** @test */
#[Test]
public function it_can_push_message_to_queue()
{
$this->azure->shouldReceive('createMessage')->once()->withArgs(function ($queue, $payload) {
Expand All @@ -42,7 +43,7 @@ public function it_can_push_message_to_queue()
$this->queue->push('foojob', 'bardata');
}

/** @test */
#[Test]
public function it_can_pop_message_from_queue()
{
$this->setListMessagesReturnExpectation($this->azure->shouldReceive('listMessages')->once());
Expand All @@ -51,7 +52,7 @@ public function it_can_pop_message_from_queue()
$this->assertInstanceOf(AzureJob::class, $message);
}

/** @test */
#[Test]
public function it_can_pop_message_from_queue_using_default()
{
$this->setListMessagesReturnExpectation($this->azure->shouldReceive('listMessages')->once());
Expand All @@ -61,7 +62,7 @@ public function it_can_pop_message_from_queue_using_default()
$this->assertEquals('myqueue', $message->getQueue());
}

/** @test */
#[Test]
public function it_returns_null_if_no_messages_to_pop()
{
$this->setListMessagesReturnExpectation($this->azure->shouldReceive('listMessages')->once(), 0);
Expand All @@ -70,7 +71,7 @@ public function it_returns_null_if_no_messages_to_pop()
$this->assertNull($message);
}

/** @test */
#[Test]
public function it_passes_visibility_timeout_set_in_config()
{
$mockClient = $this->azure->shouldReceive('listMessages')->once()->withArgs(function ($queue,
Expand All @@ -82,7 +83,7 @@ public function it_passes_visibility_timeout_set_in_config()
$this->queue->pop('myqueue');
}

/** @test */
#[Test]
public function it_only_fetches_first_message()
{
$mockClient = $this->azure->shouldReceive('listMessages')->once()->withArgs(function ($queue,
Expand All @@ -93,13 +94,13 @@ public function it_only_fetches_first_message()
$this->queue->pop('myqueue');
}

/** @test */
#[Test]
public function it_can_get_visibility_timeout()
{
$this->assertEquals(5, $this->queue->getVisibilityTimeout());
}

/** @test */
#[Test]
public function it_can_queue_a_job_for_later()
{
$this->azure->shouldReceive('createMessage')->once()->withArgs(function ($queue,
Expand All @@ -112,15 +113,15 @@ public function it_can_queue_a_job_for_later()
$this->queue->later(10, 'foojob', 'bardata', 'myqueue');
}

/** @test */
#[Test]
public function it_can_get_queue_size()
{
$this->azure->shouldReceive('getQueueMetadata')->with('myqueue')->andReturn(new GetQueueMetadataResult(5, []));

$this->assertEquals(5, $this->queue->size('myqueue'));
}

/** @test */
#[Test]
public function it_can_get_azure_instance()
{
$this->assertInstanceOf(IQueue::class, $this->queue->getAzure());
Expand Down
2 changes: 2 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Squigg\AzureQueueLaravel\Tests;

use Illuminate\Foundation\Bootstrap\HandleExceptions;
use Mockery;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Squigg\AzureQueueLaravel\AzureQueueServiceProvider;
Expand All @@ -24,6 +25,7 @@ protected function tearDown(): void
{
$this->addToAssertionCount(Mockery::getContainer()->mockery_getExpectationCount());
Mockery::close();
HandleExceptions::flushState();
}

}