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
62 changes: 32 additions & 30 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/vendor
vendor
composer.lock
/phpunit.xml
phpunit.xml
.phpunit.cache/
.phpunit.result.cache
.idea
.phpunit.cache/test-results
.idea/
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
failOnWarning="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
8 changes: 4 additions & 4 deletions tests/Console/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PodPoint\AwsPubSub\Tests\Console;

use PHPUnit\Framework\Attributes\Test;
use PodPoint\AwsPubSub\Tests\TestCase;

class InstallCommandTest extends TestCase
Expand All @@ -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')));
}
}
3 changes: 3 additions & 0 deletions tests/Console/ListenerMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,6 +23,7 @@ public function tearDown(): void
$this->cleanup();
}

#[Test]
/** @test */
public function it_can_generate_pubsub_event_listeners()
{
Expand All @@ -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()
{
Expand Down
37 changes: 20 additions & 17 deletions tests/EventServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -27,6 +30,7 @@ public function it_can_prepare_configuration_credentials()
], $config);
}

#[Test]
/** @test */
public function it_can_prepare_configuration_credentials_with_a_token()
{
Expand All @@ -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()
{
Expand All @@ -61,65 +66,64 @@ 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' => '',
],
],
];
}

/**
* @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([
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions tests/Pub/BasicEvents/EventBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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()
{
Expand Down
Loading