From c4e01b678d872d306eba9298149ce980b365b0e8 Mon Sep 17 00:00:00 2001 From: ItprojektRepo Date: Thu, 13 Jun 2024 11:49:35 +0300 Subject: [PATCH 01/12] Update composer.json Laravel 11 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cc6dc3e..4332226 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": "^7.3|^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52|^9.0|^10.0" + "illuminate/support": "^8.52|^9.0|^10.0|^11.0" }, "require-dev": { "orchestra/testbench": "^6.0|^7.0" From 3a05fbff40cdd6f93a7d1f6193455511f4c95de1 Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Fri, 6 Sep 2024 08:52:28 +0200 Subject: [PATCH 02/12] WIP --- .github/workflows/run-tests.yml | 9 ++------- composer.json | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e3cc518..596a9cc 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,13 +8,8 @@ jobs: strategy: fail-fast: true matrix: - php: [ 7.3, 7.4, 8.0, 8.1 ] - laravel: [ 8.*, 9.* ] - exclude: - - php: 7.3 - laravel: 9.* - - php: 7.4 - laravel: 9.* + php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] + laravel: [ 8.*, 9.*, 10.*, 11.* ] name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} diff --git a/composer.json b/composer.json index 4332226..557785e 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ } ], "require": { - "php": "^7.3|^8.0", + "php": "^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", "illuminate/support": "^8.52|^9.0|^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "^6.0|^7.0" + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0" }, "autoload": { "psr-4": { From b663dce45bf8b756d711e39be20459936ceeaa45 Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Fri, 6 Sep 2024 08:59:26 +0200 Subject: [PATCH 03/12] WIP --- tests/Sub/Queue/SqsSnsQueueTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index ad067ee..031361c 100644 --- a/tests/Sub/Queue/SqsSnsQueueTest.php +++ b/tests/Sub/Queue/SqsSnsQueueTest.php @@ -91,7 +91,10 @@ public function readOnlyDataProvider(): array ]; } - /** @test @dataProvider readOnlyDataProvider */ + /** + * @test + * @dataProvider readOnlyDataProvider + */ public function it_is_a_read_only_queue_driver_and_will_not_push_messages_onto_a_queue(string $method, ...$args) { Log::shouldReceive('error')->once()->with('Unsupported: sqs-sns queue driver is read-only'); From f134129006f72f89c36ce339aaf2b2e1fbc097e4 Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Fri, 6 Sep 2024 09:02:41 +0200 Subject: [PATCH 04/12] WIP --- .github/workflows/run-tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 596a9cc..e61d12d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,6 +10,13 @@ jobs: matrix: php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] laravel: [ 8.*, 9.*, 10.*, 11.* ] + exclude: + - php: 8.0 + laravel: 10.* + - php: 8.0 + laravel: 11.* + - php: 8.1 + laravel: 11.* name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} From 7d7f98f2d2153022a5cc9675a47c427c651a3288 Mon Sep 17 00:00:00 2001 From: Clem Blanco Date: Fri, 6 Sep 2024 09:06:29 +0200 Subject: [PATCH 05/12] WIP --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e61d12d..48d7113 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,7 +6,7 @@ jobs: test: runs-on: ubuntu-latest strategy: - fail-fast: true + fail-fast: false matrix: php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] laravel: [ 8.*, 9.*, 10.*, 11.* ] From d670fbcdbed36d4880d0b8fe41326e9bb618c429 Mon Sep 17 00:00:00 2001 From: clemblanco Date: Fri, 6 Sep 2024 09:45:26 +0200 Subject: [PATCH 06/12] WIP --- .github/workflows/run-tests.yml | 50 ++++++++++++++--------------- .gitignore | 8 +++-- composer.json | 12 ++++++- phpunit.xml.dist | 13 ++++---- tests/EventServiceProviderTest.php | 19 ++++++----- tests/Sub/Queue/SqsSnsQueueTest.php | 2 +- 6 files changed, 57 insertions(+), 47 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 48d7113..49224c9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,8 +8,8 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.0, 8.1, 8.2, 8.3, 8.4 ] - laravel: [ 8.*, 9.*, 10.*, 11.* ] + php: [8.0, 8.1, 8.2, 8.3, 8.4] + laravel: [8.*, 9.*, 10.*, 11.*] exclude: - php: 8.0 laravel: 10.* @@ -21,26 +21,26 @@ jobs: name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache/files - key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip - coverage: none - - - name: Install dependencies - run: | - composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update - composer update --prefer-dist --no-interaction --no-progress - - - name: Execute tests - run: vendor/bin/phpunit + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-progress + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index cc31cac..9d3d1da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ -/vendor +vendor composer.lock -/phpunit.xml +phpunit.xml +.phpunit.cache/ .phpunit.result.cache -.idea +.phpunit.cache/test-results +.idea/ diff --git a/composer.json b/composer.json index 557785e..67d18fe 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,17 @@ { "name": "pod-point/laravel-aws-pubsub", "description": "A Laravel broadcasting driver and queue driver that broadcasts and listens to published events utilising AWS SNS, EventBridge and SQS.", - "keywords": ["laravel", "broadcasting", "broadcast", "queue", "listeners", "pubsub", "aws", "sns", "sqs"], + "keywords": [ + "laravel", + "broadcasting", + "broadcast", + "queue", + "listeners", + "pubsub", + "aws", + "sns", + "sqs" + ], "homepage": "https://github.com/pod-point/laravel-aws-pubsub", "license": "MIT", "authors": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 167e3f8..a06b9de 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,17 @@ - - ./tests/ + ./tests/ diff --git a/tests/EventServiceProviderTest.php b/tests/EventServiceProviderTest.php index ca32fb4..c3e87ef 100644 --- a/tests/EventServiceProviderTest.php +++ b/tests/EventServiceProviderTest.php @@ -61,53 +61,53 @@ public function it_can_make_sure_some_aws_credentials_are_provided_before_prepar $this->assertArrayNotHasKey('credentials', $config); } - public function invalidCredentialsDataProvider() + public static function invalidCredentialsDataProvider() { return [ 'key_is_empty' => [ - 'creds' => [ + [ 'key' => '', 'secret' => 'some_secret', ], ], 'secret_is_empty' => [ - 'creds' => [ + [ 'key' => 'some_key', 'secret' => '', ], ], 'key_and_secret_are_empty' => [ - 'creds' => [ + [ 'key' => '', 'secret' => '', ], ], 'key_is_null' => [ - 'creds' => [ + [ 'key' => null, 'secret' => 'some_secret', ], ], 'secret_is_null' => [ - 'creds' => [ + [ 'key' => 'some_key', 'secret' => null, ], ], 'key_and_secret_are_null' => [ - 'creds' => [ + [ 'key' => null, 'secret' => null, ], ], 'key_is_empty_and_secret_is_null' => [ - 'creds' => [ + [ 'key' => '', 'secret' => null, ], ], 'key_is_null_and_secret_is_empty' => [ - 'creds' => [ + [ 'key' => null, 'secret' => '', ], @@ -117,7 +117,6 @@ public function invalidCredentialsDataProvider() /** * @test - * * @dataProvider invalidCredentialsDataProvider */ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(array $invalidCredentials) diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index 031361c..9ba05ba 100644 --- a/tests/Sub/Queue/SqsSnsQueueTest.php +++ b/tests/Sub/Queue/SqsSnsQueueTest.php @@ -82,7 +82,7 @@ public function it_properly_handles_empty_message_when_popping_it_off_the_queue( $this->assertNull($queue->pop()); } - public function readOnlyDataProvider(): array + public static function readOnlyDataProvider(): array { return [ 'pushRaw' => ['pushRaw', ['foo' => 'bar']], From f5d8010ca630cae52b9d261f170f6ee664dbdcda Mon Sep 17 00:00:00 2001 From: clemblanco Date: Fri, 6 Sep 2024 10:13:46 +0200 Subject: [PATCH 07/12] WIP --- composer.json | 3 ++- tests/Console/InstallCommandTest.php | 10 ++++------ tests/Console/ListenerMakeCommandTest.php | 5 +++-- tests/EventServiceProviderTest.php | 18 ++++++++---------- tests/Pub/BasicEvents/EventBridgeTest.php | 13 +++++++------ tests/Pub/BasicEvents/SnsTest.php | 15 ++++++++------- .../EventBridgeBroadcasterTest.php | 7 ++++--- .../Broadcasters/SnsBroadcasterTest.php | 7 ++++--- tests/Pub/ModelEventsTest.php | 19 ++++++++++--------- .../Queue/Connectors/SqsSnsConnectorTest.php | 11 ++++++----- .../Queue/Jobs/SnsEventDispatcherJobTest.php | 17 +++++++++-------- tests/Sub/Queue/SqsSnsQueueTest.php | 16 ++++++++-------- tests/TestCase.php | 4 +--- 13 files changed, 74 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index 67d18fe..99498e7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "php": "^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52|^9.0|^10.0|^11.0" + "illuminate/support": "^8.52|^9.0|^10.0|^11.0", + "laravel/framework": "11.*" }, "require-dev": { "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0" diff --git a/tests/Console/InstallCommandTest.php b/tests/Console/InstallCommandTest.php index 3d48edc..f42414c 100644 --- a/tests/Console/InstallCommandTest.php +++ b/tests/Console/InstallCommandTest.php @@ -2,6 +2,7 @@ namespace PodPoint\AwsPubSub\Tests\Console; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Tests\TestCase; class InstallCommandTest extends TestCase @@ -21,33 +22,30 @@ public function tearDown(): void copy(config_path('app.original'), config_path('app.php')); } - /** @test */ + #[Test] public function it_can_install_the_service_provider() { $this->assertFileDoesNotExist(app_path('Providers').'/PubSubEventServiceProvider.php'); - $this->assertStringNotContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php'))); $this->artisan('pubsub:install') ->expectsOutput('PubSubEventServiceProvider created successfully.') ->assertExitCode(0); $this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php'); - $this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php'))); } - /** @test */ + + #[Test] public function it_does_not_install_the_service_provider_if_already_existing() { $this->artisan('pubsub:install')->assertExitCode(0); $this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php'); - $this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php'))); $this->artisan('pubsub:install') ->expectsOutput('PubSubEventServiceProvider already exists!') ->assertExitCode(1); $this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php'); - $this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php'))); } } diff --git a/tests/Console/ListenerMakeCommandTest.php b/tests/Console/ListenerMakeCommandTest.php index 4240c7e..10bf2b3 100644 --- a/tests/Console/ListenerMakeCommandTest.php +++ b/tests/Console/ListenerMakeCommandTest.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Str; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Tests\TestCase; class ListenerMakeCommandTest extends TestCase @@ -22,7 +23,7 @@ public function tearDown(): void $this->cleanup(); } - /** @test */ + #[Test] public function it_can_generate_pubsub_event_listeners() { $this->assertFileDoesNotExist(app_path('Listeners/PubSub/SomeListener.php')); @@ -35,7 +36,7 @@ public function it_can_generate_pubsub_event_listeners() $this->assertFileExists(app_path('Listeners/PubSub/SomeListener.php')); } - /** @test */ + #[Test] public function it_cannot_generate_pubsub_event_listeners_which_already_exist() { $this->assertFileDoesNotExist(app_path('Listeners/PubSub/SomeListener.php')); diff --git a/tests/EventServiceProviderTest.php b/tests/EventServiceProviderTest.php index c3e87ef..8d26601 100644 --- a/tests/EventServiceProviderTest.php +++ b/tests/EventServiceProviderTest.php @@ -3,11 +3,13 @@ namespace PodPoint\AwsPubSub\Tests; use Illuminate\Support\Facades\Event; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\EventServiceProvider; class EventServiceProviderTest extends TestCase { - /** @test */ + #[Test] public function it_can_prepare_configuration_credentials() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -27,7 +29,7 @@ public function it_can_prepare_configuration_credentials() ], $config); } - /** @test */ + #[Test] public function it_can_prepare_configuration_credentials_with_a_token() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -50,7 +52,7 @@ public function it_can_prepare_configuration_credentials_with_a_token() ], $config); } - /** @test */ + #[Test] public function it_can_make_sure_some_aws_credentials_are_provided_before_preparing_the_credentials() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -115,10 +117,8 @@ public static function invalidCredentialsDataProvider() ]; } - /** - * @test - * @dataProvider invalidCredentialsDataProvider - */ + #[Test] + #[DataProvider('invalidCredentialsDataProvider')] public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(array $invalidCredentials) { $config = EventServiceProvider::prepareConfigurationCredentials(array_merge([ @@ -129,9 +129,7 @@ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(arr $this->assertArrayNotHasKey('credentials', $config); } - /** - * @test - */ + #[Test] public function it_can_register_listeners_when_listen_array_is_populated() { $this->app->register(TestPubSubEventServiceProvider::class); diff --git a/tests/Pub/BasicEvents/EventBridgeTest.php b/tests/Pub/BasicEvents/EventBridgeTest.php index b14be89..89a4e9c 100644 --- a/tests/Pub/BasicEvents/EventBridgeTest.php +++ b/tests/Pub/BasicEvents/EventBridgeTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Log; use Mockery as m; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Tests\Pub\Concerns\InteractsWithEventBridge; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrieved; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrievedWithCustomName; @@ -18,7 +19,7 @@ class EventBridgeTest extends TestCase { use InteractsWithEventBridge; - /** @test */ + #[Test] public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type_and_serialised_event_as_the_detail() { $event = new UserRetrieved($this->createJane()); @@ -38,7 +39,7 @@ public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type event($event); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_with_action() { $event = new UserRetrievedWithCustomName($this->createJane()); @@ -56,7 +57,7 @@ public function it_broadcasts_basic_event_with_action() event($event); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_with_action_and_custom_payload() { $event = new UserRetrievedWithCustomPayload($this->createJane()); @@ -77,7 +78,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload() event($event); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_to_multiple_channels_as_buses() { $event = new UserRetrievedWithMultipleChannels($this->createJane()); @@ -101,7 +102,7 @@ public function it_broadcasts_basic_event_to_multiple_channels_as_buses() event($event); } - /** @test */ + #[Test] public function it_can_use_a_source() { config(['broadcasting.connections.eventbridge.source' => 'some-other-source']); @@ -125,7 +126,7 @@ public function it_can_use_a_source() event($event); } - /** @test */ + #[Test] public function it_logs_errors_when_events_fail_to_send() { $event = new UserRetrieved($this->createJane()); diff --git a/tests/Pub/BasicEvents/SnsTest.php b/tests/Pub/BasicEvents/SnsTest.php index c53e36c..0d24f7e 100644 --- a/tests/Pub/BasicEvents/SnsTest.php +++ b/tests/Pub/BasicEvents/SnsTest.php @@ -4,6 +4,7 @@ use Mockery as m; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Tests\Pub\Concerns\InteractsWithSns; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrieved; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrievedWithCustomName; @@ -17,7 +18,7 @@ class SnsTest extends TestCase { use InteractsWithSns; - /** @test */ + #[Test] public function it_broadcasts_basic_event() { $this->mockSns(function (MockInterface $sns) { @@ -40,7 +41,7 @@ public function it_broadcasts_basic_event() ]))); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_with_action() { $this->mockSns(function (MockInterface $sns) { @@ -62,7 +63,7 @@ public function it_broadcasts_basic_event_with_action() ]))); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_with_action_and_custom_payload() { $this->mockSns(function (MockInterface $sns) { @@ -84,7 +85,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload() ]))); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_to_multiple_channels() { $this->mockSns(function (MockInterface $sns) { @@ -105,7 +106,7 @@ public function it_broadcasts_basic_event_to_multiple_channels() ]))); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_name_as_subject() { $this->mockSns(function (MockInterface $sns) { @@ -126,7 +127,7 @@ public function it_broadcasts_basic_event_name_as_subject() ]))); } - /** @test */ + #[Test] public function it_broadcasts_basic_event_name_as_subject_if_specified() { $this->mockSns(function (MockInterface $sns) { @@ -147,7 +148,7 @@ public function it_broadcasts_basic_event_name_as_subject_if_specified() ]))); } - /** @test */ + #[Test] public function it_can_use_an_arn_prefix_and_suffix() { config(['broadcasting.connections.sns.arn-prefix' => 'some-prefix:']); diff --git a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php index 6903320..392a647 100644 --- a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php +++ b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php @@ -2,13 +2,14 @@ namespace PodPoint\AwsPubSub\Tests\Pub\Broadcasting\Broadcasters; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\EventServiceProvider; use PodPoint\AwsPubSub\Pub\Broadcasting\Broadcasters\EventBridgeBroadcaster; use PodPoint\AwsPubSub\Tests\TestCase; class EventBridgeBroadcasterTest extends TestCase { - /** @test */ + #[Test] public function it_can_instantiate_the_broadcaster() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ @@ -23,7 +24,7 @@ public function it_can_instantiate_the_broadcaster() $this->assertInstanceOf(EventBridgeBroadcaster::class, $broadcaster); } - /** @test */ + #[Test] public function it_supports_optional_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ @@ -36,7 +37,7 @@ public function it_supports_optional_aws_credentials() $this->assertInstanceOf(EventBridgeBroadcaster::class, $broadcaster); } - /** @test */ + #[Test] public function it_supports_null_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ diff --git a/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php index 5e67573..707e686 100644 --- a/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php +++ b/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php @@ -2,6 +2,7 @@ namespace PodPoint\AwsPubSub\Tests\Pub\Broadcasting\Broadcasters; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\EventServiceProvider; use PodPoint\AwsPubSub\Pub\Broadcasting\Broadcasters\SnsBroadcaster; use PodPoint\AwsPubSub\Tests\Pub\Concerns\InteractsWithSns; @@ -11,7 +12,7 @@ class SnsBroadcasterTest extends TestCase { use InteractsWithSns; - /** @test */ + #[Test] public function it_can_instantiate_the_broadcaster() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ @@ -25,7 +26,7 @@ public function it_can_instantiate_the_broadcaster() $this->assertInstanceOf(SnsBroadcaster::class, $broadcaster); } - /** @test */ + #[Test] public function it_supports_optional_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ @@ -37,7 +38,7 @@ public function it_supports_optional_aws_credentials() $this->assertInstanceOf(SnsBroadcaster::class, $broadcaster); } - /** @test */ + #[Test] public function it_supports_null_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ diff --git a/tests/Pub/ModelEventsTest.php b/tests/Pub/ModelEventsTest.php index d8757c8..75a4e2b 100644 --- a/tests/Pub/ModelEventsTest.php +++ b/tests/Pub/ModelEventsTest.php @@ -4,6 +4,7 @@ use Mockery as m; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Tests\Pub\Concerns\InteractsWithSns; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Models\User; use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Models\UserWithBroadcastingEvents; @@ -18,7 +19,7 @@ class ModelEventsTest extends TestCase { use InteractsWithSns; - /** @test */ + #[Test] public function it_broadcasts_model_event() { $this->mockSns(function (MockInterface $sns) { @@ -38,7 +39,7 @@ public function it_broadcasts_model_event() ]); } - /** @test */ + #[Test] public function it_does_not_broadcast_model_events_without_trait() { $this->mockSns(function (MockInterface $sns) { @@ -52,7 +53,7 @@ public function it_does_not_broadcast_model_events_without_trait() ]); } - /** @test */ + #[Test] public function it_broadcasts_model_event_with_custom_payload() { $this->mockSns(function (MockInterface $sns) { @@ -74,7 +75,7 @@ public function it_broadcasts_model_event_with_custom_payload() ]); } - /** @test */ + #[Test] public function it_broadcasts_model_event_with_specified_event() { $user = UserWithBroadcastingEventsWhenUpdatedOnly::create([ @@ -98,7 +99,7 @@ public function it_broadcasts_model_event_with_specified_event() ]); } - /** @test */ + #[Test] public function it_does_not_broadcast_model_event_without_specified_event() { $this->mockSns(function (MockInterface $sns) { @@ -112,7 +113,7 @@ public function it_does_not_broadcast_model_event_without_specified_event() ])->delete(); } - /** @test */ + #[Test] public function it_broadcasts_model_event_with_specified_event_and_custom_payload() { $user = UserWithBroadcastingEventsWithCustomPayloadWhenUpdatedOnly::create([ @@ -138,7 +139,7 @@ public function it_broadcasts_model_event_with_specified_event_and_custom_payloa ]); } - /** @test */ + #[Test] public function it_broadcasts_model_events_to_multiple_channels() { $this->mockSns(function (MockInterface $sns) { @@ -158,7 +159,7 @@ public function it_broadcasts_model_events_to_multiple_channels() ]); } - /** @test */ + #[Test] public function it_broadcasts_model_event_name_as_subject() { $this->mockSns(function (MockInterface $sns) { @@ -176,7 +177,7 @@ public function it_broadcasts_model_event_name_as_subject() ]); } - /** @test */ + #[Test] public function it_broadcasts_model_event_name_as_subject_if_specified() { $this->mockSns(function (MockInterface $sns) { diff --git a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php index bbdab34..0b112d5 100644 --- a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php +++ b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php @@ -2,13 +2,14 @@ namespace PodPoint\AwsPubSub\Tests\Sub\Queue\Connectors; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Sub\Queue\Connectors\SqsSnsConnector; use PodPoint\AwsPubSub\Sub\Queue\SqsSnsQueue; use PodPoint\AwsPubSub\Tests\TestCase; class SqsSnsConnectorTest extends TestCase { - /** @test */ + #[Test] public function it_can_instantiate_the_connector_and_connect_to_the_queue() { $queue = (new SqsSnsConnector)->connect([ @@ -23,7 +24,7 @@ public function it_can_instantiate_the_connector_and_connect_to_the_queue() $this->assertInstanceOf(SqsSnsQueue::class, $queue); } - /** @test */ + #[Test] public function it_can_use_a_queue_prefix() { $queue = (new SqsSnsConnector)->connect([ @@ -38,7 +39,7 @@ public function it_can_use_a_queue_prefix() $this->assertEquals('https://sqs.eu-west-1.amazonaws.com/13245/default', $queue->getQueue(null)); } - /** @test */ + #[Test] public function it_can_use_a_queue_suffix() { $queue = (new SqsSnsConnector)->connect([ @@ -54,7 +55,7 @@ public function it_can_use_a_queue_suffix() $this->assertEquals('https://sqs.eu-west-1.amazonaws.com/13245/default-testing', $queue->getQueue(null)); } - /** @test */ + #[Test] public function it_supports_optional_aws_credentials() { $queue = (new SqsSnsConnector)->connect([ @@ -67,7 +68,7 @@ public function it_supports_optional_aws_credentials() $this->assertEquals('https://sqs.eu-west-1.amazonaws.com/13245/default', $queue->getQueue(null)); } - /** @test */ + #[Test] public function it_supports_null_aws_credentials() { $queue = (new SqsSnsConnector)->connect([ diff --git a/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php b/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php index fcc3b2c..55a18fb 100644 --- a/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php +++ b/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; use Mockery as m; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Sub\Queue\Jobs\SnsEventDispatcherJob; use PodPoint\AwsPubSub\Tests\Sub\Concerns\MocksNotificationMessages; use PodPoint\AwsPubSub\Tests\TestCase; @@ -26,7 +27,7 @@ public function setUp(): void Event::fake(); } - /** @test */ + #[Test] public function it_can_dispatch_an_event_using_the_topic_and_forward_the_message_payload() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -44,7 +45,7 @@ public function it_can_dispatch_an_event_using_the_topic_and_forward_the_message }); } - /** @test */ + #[Test] public function it_can_dispatch_an_event_using_the_subject_if_found_in_the_notification_payload() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -64,7 +65,7 @@ public function it_can_dispatch_an_event_using_the_subject_if_found_in_the_notif Event::assertNotDispatched('TopicArn:123456'); } - /** @test */ + #[Test] public function it_dispatches_an_event_using_the_topic_if_no_subject_can_be_found() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -76,7 +77,7 @@ public function it_dispatches_an_event_using_the_topic_if_no_subject_can_be_foun Event::assertDispatched('TopicArn:123456'); } - /** @test */ + #[Test] public function it_will_handle_empty_messages() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -94,7 +95,7 @@ public function it_will_handle_empty_messages() }); } - /** @test */ + #[Test] public function it_will_handle_empty_messages_with_a_subject() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -112,7 +113,7 @@ public function it_will_handle_empty_messages_with_a_subject() }); } - /** @test */ + #[Test] public function it_will_not_handle_raw_notification_messages_and_release_the_message_onto_the_queue() { Log::shouldReceive('error')->once()->with( @@ -131,7 +132,7 @@ public function it_will_not_handle_raw_notification_messages_and_release_the_mes Event::assertNothingDispatched(); } - /** @test */ + #[Test] public function it_will_not_handle_messages_where_the_event_name_to_trigger_cannot_be_resolved_and_delete_the_message_from_the_queue() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -148,7 +149,7 @@ public function it_will_not_handle_messages_where_the_event_name_to_trigger_cann Event::assertNothingDispatched(); } - /** @test */ + #[Test] public function it_will_delete_the_message_from_the_queue_when_it_managed_to_dispatch_an_event() { $this->mockedJobData = $this->mockedRichNotificationMessage([ diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index 9ba05ba..13b1336 100644 --- a/tests/Sub/Queue/SqsSnsQueueTest.php +++ b/tests/Sub/Queue/SqsSnsQueueTest.php @@ -6,6 +6,8 @@ use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; use Mockery as m; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PodPoint\AwsPubSub\Sub\Queue\Jobs\SnsEventDispatcherJob; use PodPoint\AwsPubSub\Sub\Queue\SqsSnsQueue; use PodPoint\AwsPubSub\Tests\Sub\Concerns\MocksNotificationMessages; @@ -29,7 +31,7 @@ public function setUp(): void $this->sqs = m::mock(SqsClient::class); } - /** @test */ + #[Test] public function it_can_instantiate_the_queue() { $queue = new SqsSnsQueue($this->sqs, 'default'); @@ -37,7 +39,7 @@ public function it_can_instantiate_the_queue() $this->assertInstanceOf(SqsSnsQueue::class, $queue); } - /** @test */ + #[Test] public function it_can_receive_a_rich_notification_message_and_pop_it_off_the_queue() { $this->sqs->shouldReceive('receiveMessage') @@ -53,7 +55,7 @@ public function it_can_receive_a_rich_notification_message_and_pop_it_off_the_qu $this->assertEquals('/default', $result->getQueue()); } - /** @test */ + #[Test] public function it_should_use_the_queue_name_including_prefix_and_suffix() { $this->sqs->shouldReceive('receiveMessage') @@ -69,7 +71,7 @@ public function it_should_use_the_queue_name_including_prefix_and_suffix() $this->assertEquals('prefix/default-suffix', $result->getQueue()); } - /** @test */ + #[Test] public function it_properly_handles_empty_message_when_popping_it_off_the_queue() { $this->sqs->shouldReceive('receiveMessage') @@ -91,10 +93,8 @@ public static function readOnlyDataProvider(): array ]; } - /** - * @test - * @dataProvider readOnlyDataProvider - */ + #[Test] + #[DataProvider('readOnlyDataProvider')] public function it_is_a_read_only_queue_driver_and_will_not_push_messages_onto_a_queue(string $method, ...$args) { Log::shouldReceive('error')->once()->with('Unsupported: sqs-sns queue driver is read-only'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 96ade20..9d7132d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace PodPoint\AwsPubSub\Tests; -use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Orchestra\Testbench\TestCase as Orchestra; use PodPoint\AwsPubSub\AwsPubSubServiceProvider; @@ -10,8 +9,7 @@ abstract class TestCase extends Orchestra { - use RefreshDatabase, - WithFaker; + use WithFaker; /** * Get package providers. From 48ab1e419bd570a41deebb159cf6cbb506ae47d7 Mon Sep 17 00:00:00 2001 From: clemblanco Date: Fri, 6 Sep 2024 10:17:53 +0200 Subject: [PATCH 08/12] WIP --- phpunit.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a06b9de..5f906fd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,6 +2,7 @@ Date: Fri, 6 Sep 2024 10:19:49 +0200 Subject: [PATCH 09/12] WIP --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5f906fd..5c4d4b2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ Date: Fri, 6 Sep 2024 10:21:33 +0200 Subject: [PATCH 10/12] WIP --- tests/Console/InstallCommandTest.php | 2 ++ tests/Console/ListenerMakeCommandTest.php | 2 ++ tests/EventServiceProviderTest.php | 6 ++++++ tests/Pub/BasicEvents/EventBridgeTest.php | 6 ++++++ tests/Pub/BasicEvents/SnsTest.php | 7 +++++++ .../Broadcasters/EventBridgeBroadcasterTest.php | 3 +++ .../Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php | 3 +++ tests/Pub/ModelEventsTest.php | 9 +++++++++ tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php | 5 +++++ tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php | 8 ++++++++ tests/Sub/Queue/SqsSnsQueueTest.php | 6 ++++++ 11 files changed, 57 insertions(+) diff --git a/tests/Console/InstallCommandTest.php b/tests/Console/InstallCommandTest.php index f42414c..a2d8530 100644 --- a/tests/Console/InstallCommandTest.php +++ b/tests/Console/InstallCommandTest.php @@ -23,6 +23,7 @@ public function tearDown(): void } #[Test] + /** @test */ public function it_can_install_the_service_provider() { $this->assertFileDoesNotExist(app_path('Providers').'/PubSubEventServiceProvider.php'); @@ -36,6 +37,7 @@ public function it_can_install_the_service_provider() #[Test] + /** @test */ public function it_does_not_install_the_service_provider_if_already_existing() { $this->artisan('pubsub:install')->assertExitCode(0); diff --git a/tests/Console/ListenerMakeCommandTest.php b/tests/Console/ListenerMakeCommandTest.php index 10bf2b3..ff9be7b 100644 --- a/tests/Console/ListenerMakeCommandTest.php +++ b/tests/Console/ListenerMakeCommandTest.php @@ -24,6 +24,7 @@ public function tearDown(): void } #[Test] + /** @test */ public function it_can_generate_pubsub_event_listeners() { $this->assertFileDoesNotExist(app_path('Listeners/PubSub/SomeListener.php')); @@ -37,6 +38,7 @@ public function it_can_generate_pubsub_event_listeners() } #[Test] + /** @test */ public function it_cannot_generate_pubsub_event_listeners_which_already_exist() { $this->assertFileDoesNotExist(app_path('Listeners/PubSub/SomeListener.php')); diff --git a/tests/EventServiceProviderTest.php b/tests/EventServiceProviderTest.php index 8d26601..dbc6ac4 100644 --- a/tests/EventServiceProviderTest.php +++ b/tests/EventServiceProviderTest.php @@ -10,6 +10,7 @@ class EventServiceProviderTest extends TestCase { #[Test] + /** @test */ public function it_can_prepare_configuration_credentials() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -30,6 +31,7 @@ public function it_can_prepare_configuration_credentials() } #[Test] + /** @test */ public function it_can_prepare_configuration_credentials_with_a_token() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -53,6 +55,7 @@ public function it_can_prepare_configuration_credentials_with_a_token() } #[Test] + /** @test */ public function it_can_make_sure_some_aws_credentials_are_provided_before_preparing_the_credentials() { $config = EventServiceProvider::prepareConfigurationCredentials([ @@ -118,7 +121,9 @@ public static function invalidCredentialsDataProvider() } #[Test] + /** @test */ #[DataProvider('invalidCredentialsDataProvider')] + /** @dataProvider invalidCredentialsDataProvider */ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(array $invalidCredentials) { $config = EventServiceProvider::prepareConfigurationCredentials(array_merge([ @@ -130,6 +135,7 @@ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(arr } #[Test] + /** @test */ public function it_can_register_listeners_when_listen_array_is_populated() { $this->app->register(TestPubSubEventServiceProvider::class); diff --git a/tests/Pub/BasicEvents/EventBridgeTest.php b/tests/Pub/BasicEvents/EventBridgeTest.php index 89a4e9c..c62f6f0 100644 --- a/tests/Pub/BasicEvents/EventBridgeTest.php +++ b/tests/Pub/BasicEvents/EventBridgeTest.php @@ -20,6 +20,7 @@ class EventBridgeTest extends TestCase use InteractsWithEventBridge; #[Test] + /** @test */ public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type_and_serialised_event_as_the_detail() { $event = new UserRetrieved($this->createJane()); @@ -40,6 +41,7 @@ public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type } #[Test] + /** @test */ public function it_broadcasts_basic_event_with_action() { $event = new UserRetrievedWithCustomName($this->createJane()); @@ -58,6 +60,7 @@ public function it_broadcasts_basic_event_with_action() } #[Test] + /** @test */ public function it_broadcasts_basic_event_with_action_and_custom_payload() { $event = new UserRetrievedWithCustomPayload($this->createJane()); @@ -79,6 +82,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload() } #[Test] + /** @test */ public function it_broadcasts_basic_event_to_multiple_channels_as_buses() { $event = new UserRetrievedWithMultipleChannels($this->createJane()); @@ -103,6 +107,7 @@ public function it_broadcasts_basic_event_to_multiple_channels_as_buses() } #[Test] + /** @test */ public function it_can_use_a_source() { config(['broadcasting.connections.eventbridge.source' => 'some-other-source']); @@ -127,6 +132,7 @@ public function it_can_use_a_source() } #[Test] + /** @test */ public function it_logs_errors_when_events_fail_to_send() { $event = new UserRetrieved($this->createJane()); diff --git a/tests/Pub/BasicEvents/SnsTest.php b/tests/Pub/BasicEvents/SnsTest.php index 0d24f7e..126e76e 100644 --- a/tests/Pub/BasicEvents/SnsTest.php +++ b/tests/Pub/BasicEvents/SnsTest.php @@ -19,6 +19,7 @@ class SnsTest extends TestCase use InteractsWithSns; #[Test] + /** @test */ public function it_broadcasts_basic_event() { $this->mockSns(function (MockInterface $sns) { @@ -42,6 +43,7 @@ public function it_broadcasts_basic_event() } #[Test] + /** @test */ public function it_broadcasts_basic_event_with_action() { $this->mockSns(function (MockInterface $sns) { @@ -64,6 +66,7 @@ public function it_broadcasts_basic_event_with_action() } #[Test] + /** @test */ public function it_broadcasts_basic_event_with_action_and_custom_payload() { $this->mockSns(function (MockInterface $sns) { @@ -86,6 +89,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload() } #[Test] + /** @test */ public function it_broadcasts_basic_event_to_multiple_channels() { $this->mockSns(function (MockInterface $sns) { @@ -107,6 +111,7 @@ public function it_broadcasts_basic_event_to_multiple_channels() } #[Test] + /** @test */ public function it_broadcasts_basic_event_name_as_subject() { $this->mockSns(function (MockInterface $sns) { @@ -128,6 +133,7 @@ public function it_broadcasts_basic_event_name_as_subject() } #[Test] + /** @test */ public function it_broadcasts_basic_event_name_as_subject_if_specified() { $this->mockSns(function (MockInterface $sns) { @@ -149,6 +155,7 @@ public function it_broadcasts_basic_event_name_as_subject_if_specified() } #[Test] + /** @test */ public function it_can_use_an_arn_prefix_and_suffix() { config(['broadcasting.connections.sns.arn-prefix' => 'some-prefix:']); diff --git a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php index 392a647..4b2b69b 100644 --- a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php +++ b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php @@ -10,6 +10,7 @@ class EventBridgeBroadcasterTest extends TestCase { #[Test] + /** @test */ public function it_can_instantiate_the_broadcaster() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ @@ -25,6 +26,7 @@ public function it_can_instantiate_the_broadcaster() } #[Test] + /** @test */ public function it_supports_optional_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ @@ -38,6 +40,7 @@ public function it_supports_optional_aws_credentials() } #[Test] + /** @test */ public function it_supports_null_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createEventBridgeDriver([ diff --git a/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php index 707e686..adb80a3 100644 --- a/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php +++ b/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php @@ -13,6 +13,7 @@ class SnsBroadcasterTest extends TestCase use InteractsWithSns; #[Test] + /** @test */ public function it_can_instantiate_the_broadcaster() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ @@ -27,6 +28,7 @@ public function it_can_instantiate_the_broadcaster() } #[Test] + /** @test */ public function it_supports_optional_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ @@ -39,6 +41,7 @@ public function it_supports_optional_aws_credentials() } #[Test] + /** @test */ public function it_supports_null_aws_credentials() { $broadcaster = (new EventServiceProvider($this->app))->createSnsDriver([ diff --git a/tests/Pub/ModelEventsTest.php b/tests/Pub/ModelEventsTest.php index 75a4e2b..f4444d1 100644 --- a/tests/Pub/ModelEventsTest.php +++ b/tests/Pub/ModelEventsTest.php @@ -20,6 +20,7 @@ class ModelEventsTest extends TestCase use InteractsWithSns; #[Test] + /** @test */ public function it_broadcasts_model_event() { $this->mockSns(function (MockInterface $sns) { @@ -40,6 +41,7 @@ public function it_broadcasts_model_event() } #[Test] + /** @test */ public function it_does_not_broadcast_model_events_without_trait() { $this->mockSns(function (MockInterface $sns) { @@ -54,6 +56,7 @@ public function it_does_not_broadcast_model_events_without_trait() } #[Test] + /** @test */ public function it_broadcasts_model_event_with_custom_payload() { $this->mockSns(function (MockInterface $sns) { @@ -76,6 +79,7 @@ public function it_broadcasts_model_event_with_custom_payload() } #[Test] + /** @test */ public function it_broadcasts_model_event_with_specified_event() { $user = UserWithBroadcastingEventsWhenUpdatedOnly::create([ @@ -100,6 +104,7 @@ public function it_broadcasts_model_event_with_specified_event() } #[Test] + /** @test */ public function it_does_not_broadcast_model_event_without_specified_event() { $this->mockSns(function (MockInterface $sns) { @@ -114,6 +119,7 @@ public function it_does_not_broadcast_model_event_without_specified_event() } #[Test] + /** @test */ public function it_broadcasts_model_event_with_specified_event_and_custom_payload() { $user = UserWithBroadcastingEventsWithCustomPayloadWhenUpdatedOnly::create([ @@ -140,6 +146,7 @@ public function it_broadcasts_model_event_with_specified_event_and_custom_payloa } #[Test] + /** @test */ public function it_broadcasts_model_events_to_multiple_channels() { $this->mockSns(function (MockInterface $sns) { @@ -160,6 +167,7 @@ public function it_broadcasts_model_events_to_multiple_channels() } #[Test] + /** @test */ public function it_broadcasts_model_event_name_as_subject() { $this->mockSns(function (MockInterface $sns) { @@ -178,6 +186,7 @@ public function it_broadcasts_model_event_name_as_subject() } #[Test] + /** @test */ public function it_broadcasts_model_event_name_as_subject_if_specified() { $this->mockSns(function (MockInterface $sns) { diff --git a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php index 0b112d5..2bef6fd 100644 --- a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php +++ b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php @@ -10,6 +10,7 @@ class SqsSnsConnectorTest extends TestCase { #[Test] + /** @test */ public function it_can_instantiate_the_connector_and_connect_to_the_queue() { $queue = (new SqsSnsConnector)->connect([ @@ -25,6 +26,7 @@ public function it_can_instantiate_the_connector_and_connect_to_the_queue() } #[Test] + /** @test */ public function it_can_use_a_queue_prefix() { $queue = (new SqsSnsConnector)->connect([ @@ -40,6 +42,7 @@ public function it_can_use_a_queue_prefix() } #[Test] + /** @test */ public function it_can_use_a_queue_suffix() { $queue = (new SqsSnsConnector)->connect([ @@ -56,6 +59,7 @@ public function it_can_use_a_queue_suffix() } #[Test] + /** @test */ public function it_supports_optional_aws_credentials() { $queue = (new SqsSnsConnector)->connect([ @@ -69,6 +73,7 @@ public function it_supports_optional_aws_credentials() } #[Test] + /** @test */ public function it_supports_null_aws_credentials() { $queue = (new SqsSnsConnector)->connect([ diff --git a/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php b/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php index 55a18fb..7f1675a 100644 --- a/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php +++ b/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php @@ -28,6 +28,7 @@ public function setUp(): void } #[Test] + /** @test */ public function it_can_dispatch_an_event_using_the_topic_and_forward_the_message_payload() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -46,6 +47,7 @@ public function it_can_dispatch_an_event_using_the_topic_and_forward_the_message } #[Test] + /** @test */ public function it_can_dispatch_an_event_using_the_subject_if_found_in_the_notification_payload() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -66,6 +68,7 @@ public function it_can_dispatch_an_event_using_the_subject_if_found_in_the_notif } #[Test] + /** @test */ public function it_dispatches_an_event_using_the_topic_if_no_subject_can_be_found() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -78,6 +81,7 @@ public function it_dispatches_an_event_using_the_topic_if_no_subject_can_be_foun } #[Test] + /** @test */ public function it_will_handle_empty_messages() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -96,6 +100,7 @@ public function it_will_handle_empty_messages() } #[Test] + /** @test */ public function it_will_handle_empty_messages_with_a_subject() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -114,6 +119,7 @@ public function it_will_handle_empty_messages_with_a_subject() } #[Test] + /** @test */ public function it_will_not_handle_raw_notification_messages_and_release_the_message_onto_the_queue() { Log::shouldReceive('error')->once()->with( @@ -133,6 +139,7 @@ public function it_will_not_handle_raw_notification_messages_and_release_the_mes } #[Test] + /** @test */ public function it_will_not_handle_messages_where_the_event_name_to_trigger_cannot_be_resolved_and_delete_the_message_from_the_queue() { $this->mockedJobData = $this->mockedRichNotificationMessage([ @@ -150,6 +157,7 @@ public function it_will_not_handle_messages_where_the_event_name_to_trigger_cann } #[Test] + /** @test */ public function it_will_delete_the_message_from_the_queue_when_it_managed_to_dispatch_an_event() { $this->mockedJobData = $this->mockedRichNotificationMessage([ diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index 13b1336..bbdf05a 100644 --- a/tests/Sub/Queue/SqsSnsQueueTest.php +++ b/tests/Sub/Queue/SqsSnsQueueTest.php @@ -32,6 +32,7 @@ public function setUp(): void } #[Test] + /** @test */ public function it_can_instantiate_the_queue() { $queue = new SqsSnsQueue($this->sqs, 'default'); @@ -40,6 +41,7 @@ public function it_can_instantiate_the_queue() } #[Test] + /** @test */ public function it_can_receive_a_rich_notification_message_and_pop_it_off_the_queue() { $this->sqs->shouldReceive('receiveMessage') @@ -56,6 +58,7 @@ public function it_can_receive_a_rich_notification_message_and_pop_it_off_the_qu } #[Test] + /** @test */ public function it_should_use_the_queue_name_including_prefix_and_suffix() { $this->sqs->shouldReceive('receiveMessage') @@ -72,6 +75,7 @@ public function it_should_use_the_queue_name_including_prefix_and_suffix() } #[Test] + /** @test */ public function it_properly_handles_empty_message_when_popping_it_off_the_queue() { $this->sqs->shouldReceive('receiveMessage') @@ -94,7 +98,9 @@ public static function readOnlyDataProvider(): array } #[Test] + /** @test */ #[DataProvider('readOnlyDataProvider')] + /** @dataProvider readOnlyDataProvider */ public function it_is_a_read_only_queue_driver_and_will_not_push_messages_onto_a_queue(string $method, ...$args) { Log::shouldReceive('error')->once()->with('Unsupported: sqs-sns queue driver is read-only'); From 920687f7bb1997d245f71cfcf1aea69ef007984c Mon Sep 17 00:00:00 2001 From: clemblanco Date: Fri, 6 Sep 2024 10:23:12 +0200 Subject: [PATCH 11/12] WIP --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 99498e7..b4d02f2 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,7 @@ "php": "^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52|^9.0|^10.0|^11.0", - "laravel/framework": "11.*" + "illuminate/support": "^8.52|^9.0|^10.0" }, "require-dev": { "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0" From af3f9bb04422eb129a79303fbb4689b3a64acbc2 Mon Sep 17 00:00:00 2001 From: clemblanco Date: Fri, 6 Sep 2024 10:25:26 +0200 Subject: [PATCH 12/12] WIP --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b4d02f2..67d18fe 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "php": "^8.0", "ext-json": "*", "aws/aws-sdk-php": "^3.155", - "illuminate/support": "^8.52|^9.0|^10.0" + "illuminate/support": "^8.52|^9.0|^10.0|^11.0" }, "require-dev": { "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0"