diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e3cc518..49224c9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -6,39 +6,41 @@ jobs: test: runs-on: ubuntu-latest strategy: - fail-fast: true + fail-fast: false matrix: - php: [ 7.3, 7.4, 8.0, 8.1 ] - laravel: [ 8.*, 9.* ] + php: [8.0, 8.1, 8.2, 8.3, 8.4] + laravel: [8.*, 9.*, 10.*, 11.*] exclude: - - php: 7.3 - laravel: 9.* - - php: 7.4 - laravel: 9.* + - php: 8.0 + laravel: 10.* + - php: 8.0 + laravel: 11.* + - php: 8.1 + laravel: 11.* 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 cc6dc3e..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": [ @@ -11,13 +21,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" + "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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 167e3f8..5c4d4b2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,18 @@ - - ./tests/ + ./tests/ diff --git a/tests/Console/InstallCommandTest.php b/tests/Console/InstallCommandTest.php index 3d48edc..a2d8530 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,32 @@ 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..ff9be7b 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,6 +23,7 @@ public function tearDown(): void $this->cleanup(); } + #[Test] /** @test */ public function it_can_generate_pubsub_event_listeners() { @@ -35,6 +37,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() { diff --git a/tests/EventServiceProviderTest.php b/tests/EventServiceProviderTest.php index ca32fb4..dbc6ac4 100644 --- a/tests/EventServiceProviderTest.php +++ b/tests/EventServiceProviderTest.php @@ -3,10 +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() { @@ -27,6 +30,7 @@ public function it_can_prepare_configuration_credentials() ], $config); } + #[Test] /** @test */ public function it_can_prepare_configuration_credentials_with_a_token() { @@ -50,6 +54,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() { @@ -61,53 +66,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' => '', ], @@ -115,11 +120,10 @@ public function invalidCredentialsDataProvider() ]; } - /** - * @test - * - * @dataProvider 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,9 +134,8 @@ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(arr $this->assertArrayNotHasKey('credentials', $config); } - /** - * @test - */ + #[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..c62f6f0 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,6 +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() { @@ -38,6 +40,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() { @@ -56,6 +59,7 @@ public function it_broadcasts_basic_event_with_action() event($event); } + #[Test] /** @test */ public function it_broadcasts_basic_event_with_action_and_custom_payload() { @@ -77,6 +81,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() { @@ -101,6 +106,7 @@ public function it_broadcasts_basic_event_to_multiple_channels_as_buses() event($event); } + #[Test] /** @test */ public function it_can_use_a_source() { @@ -125,6 +131,7 @@ public function it_can_use_a_source() event($event); } + #[Test] /** @test */ public function it_logs_errors_when_events_fail_to_send() { diff --git a/tests/Pub/BasicEvents/SnsTest.php b/tests/Pub/BasicEvents/SnsTest.php index c53e36c..126e76e 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,6 +18,7 @@ class SnsTest extends TestCase { use InteractsWithSns; + #[Test] /** @test */ public function it_broadcasts_basic_event() { @@ -40,6 +42,7 @@ public function it_broadcasts_basic_event() ]))); } + #[Test] /** @test */ public function it_broadcasts_basic_event_with_action() { @@ -62,6 +65,7 @@ public function it_broadcasts_basic_event_with_action() ]))); } + #[Test] /** @test */ public function it_broadcasts_basic_event_with_action_and_custom_payload() { @@ -84,6 +88,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload() ]))); } + #[Test] /** @test */ public function it_broadcasts_basic_event_to_multiple_channels() { @@ -105,6 +110,7 @@ public function it_broadcasts_basic_event_to_multiple_channels() ]))); } + #[Test] /** @test */ public function it_broadcasts_basic_event_name_as_subject() { @@ -126,6 +132,7 @@ public function it_broadcasts_basic_event_name_as_subject() ]))); } + #[Test] /** @test */ public function it_broadcasts_basic_event_name_as_subject_if_specified() { @@ -147,6 +154,7 @@ public function it_broadcasts_basic_event_name_as_subject_if_specified() ]))); } + #[Test] /** @test */ public function it_can_use_an_arn_prefix_and_suffix() { diff --git a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php index 6903320..4b2b69b 100644 --- a/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php +++ b/tests/Pub/Broadcasting/Broadcasters/EventBridgeBroadcasterTest.php @@ -2,12 +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() { @@ -23,6 +25,7 @@ public function it_can_instantiate_the_broadcaster() $this->assertInstanceOf(EventBridgeBroadcaster::class, $broadcaster); } + #[Test] /** @test */ public function it_supports_optional_aws_credentials() { @@ -36,6 +39,7 @@ public function it_supports_optional_aws_credentials() $this->assertInstanceOf(EventBridgeBroadcaster::class, $broadcaster); } + #[Test] /** @test */ public function it_supports_null_aws_credentials() { diff --git a/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php b/tests/Pub/Broadcasting/Broadcasters/SnsBroadcasterTest.php index 5e67573..adb80a3 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,6 +12,7 @@ class SnsBroadcasterTest extends TestCase { use InteractsWithSns; + #[Test] /** @test */ public function it_can_instantiate_the_broadcaster() { @@ -25,6 +27,7 @@ public function it_can_instantiate_the_broadcaster() $this->assertInstanceOf(SnsBroadcaster::class, $broadcaster); } + #[Test] /** @test */ public function it_supports_optional_aws_credentials() { @@ -37,6 +40,7 @@ public function it_supports_optional_aws_credentials() $this->assertInstanceOf(SnsBroadcaster::class, $broadcaster); } + #[Test] /** @test */ public function it_supports_null_aws_credentials() { diff --git a/tests/Pub/ModelEventsTest.php b/tests/Pub/ModelEventsTest.php index d8757c8..f4444d1 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,6 +19,7 @@ class ModelEventsTest extends TestCase { use InteractsWithSns; + #[Test] /** @test */ public function it_broadcasts_model_event() { @@ -38,6 +40,7 @@ public function it_broadcasts_model_event() ]); } + #[Test] /** @test */ public function it_does_not_broadcast_model_events_without_trait() { @@ -52,6 +55,7 @@ public function it_does_not_broadcast_model_events_without_trait() ]); } + #[Test] /** @test */ public function it_broadcasts_model_event_with_custom_payload() { @@ -74,6 +78,7 @@ public function it_broadcasts_model_event_with_custom_payload() ]); } + #[Test] /** @test */ public function it_broadcasts_model_event_with_specified_event() { @@ -98,6 +103,7 @@ public function it_broadcasts_model_event_with_specified_event() ]); } + #[Test] /** @test */ public function it_does_not_broadcast_model_event_without_specified_event() { @@ -112,6 +118,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() { @@ -138,6 +145,7 @@ public function it_broadcasts_model_event_with_specified_event_and_custom_payloa ]); } + #[Test] /** @test */ public function it_broadcasts_model_events_to_multiple_channels() { @@ -158,6 +166,7 @@ public function it_broadcasts_model_events_to_multiple_channels() ]); } + #[Test] /** @test */ public function it_broadcasts_model_event_name_as_subject() { @@ -176,6 +185,7 @@ public function it_broadcasts_model_event_name_as_subject() ]); } + #[Test] /** @test */ public function it_broadcasts_model_event_name_as_subject_if_specified() { diff --git a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php index bbdab34..2bef6fd 100644 --- a/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php +++ b/tests/Sub/Queue/Connectors/SqsSnsConnectorTest.php @@ -2,12 +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() { @@ -23,6 +25,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() { @@ -38,6 +41,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() { @@ -54,6 +58,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() { @@ -67,6 +72,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() { diff --git a/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php b/tests/Sub/Queue/Jobs/SnsEventDispatcherJobTest.php index fcc3b2c..7f1675a 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,6 +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() { @@ -44,6 +46,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() { @@ -64,6 +67,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() { @@ -76,6 +80,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() { @@ -94,6 +99,7 @@ public function it_will_handle_empty_messages() }); } + #[Test] /** @test */ public function it_will_handle_empty_messages_with_a_subject() { @@ -112,6 +118,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() { @@ -131,6 +138,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() { @@ -148,6 +156,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() { diff --git a/tests/Sub/Queue/SqsSnsQueueTest.php b/tests/Sub/Queue/SqsSnsQueueTest.php index ad067ee..bbdf05a 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,6 +31,7 @@ public function setUp(): void $this->sqs = m::mock(SqsClient::class); } + #[Test] /** @test */ public function it_can_instantiate_the_queue() { @@ -37,6 +40,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() { @@ -53,6 +57,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() { @@ -69,6 +74,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() { @@ -82,7 +88,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']], @@ -91,7 +97,10 @@ public function readOnlyDataProvider(): array ]; } - /** @test @dataProvider readOnlyDataProvider */ + #[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'); 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.