Skip to content

Commit 78c1e51

Browse files
[0.6] Laravel 10 and 11 support (#79)
- Laravel 10 support - Laravel 11 support - PHPUnit 11 support - Orchestra Testbench 9 support - Remove PHP 7.x support
1 parent fa5a8d7 commit 78c1e51

16 files changed

+145
-70
lines changed

.github/workflows/run-tests.yml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,41 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88
strategy:
9-
fail-fast: true
9+
fail-fast: false
1010
matrix:
11-
php: [ 7.3, 7.4, 8.0, 8.1 ]
12-
laravel: [ 8.*, 9.* ]
11+
php: [8.0, 8.1, 8.2, 8.3, 8.4]
12+
laravel: [8.*, 9.*, 10.*, 11.*]
1313
exclude:
14-
- php: 7.3
15-
laravel: 9.*
16-
- php: 7.4
17-
laravel: 9.*
14+
- php: 8.0
15+
laravel: 10.*
16+
- php: 8.0
17+
laravel: 11.*
18+
- php: 8.1
19+
laravel: 11.*
1820

1921
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
2022

2123
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v2
24-
25-
- name: Cache dependencies
26-
uses: actions/cache@v2
27-
with:
28-
path: ~/.composer/cache/files
29-
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
30-
31-
- name: Setup PHP
32-
uses: shivammathur/setup-php@v2
33-
with:
34-
php-version: ${{ matrix.php }}
35-
extensions: dom, curl, libxml, mbstring, zip
36-
coverage: none
37-
38-
- name: Install dependencies
39-
run: |
40-
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
41-
composer update --prefer-dist --no-interaction --no-progress
42-
43-
- name: Execute tests
44-
run: vendor/bin/phpunit
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
27+
- name: Cache dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.composer/cache/files
31+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: dom, curl, libxml, mbstring, zip
38+
coverage: none
39+
40+
- name: Install dependencies
41+
run: |
42+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
43+
composer update --prefer-dist --no-interaction --no-progress
44+
45+
- name: Execute tests
46+
run: vendor/bin/phpunit

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
/vendor
1+
vendor
22
composer.lock
3-
/phpunit.xml
3+
phpunit.xml
4+
.phpunit.cache/
45
.phpunit.result.cache
5-
.idea
6+
.phpunit.cache/test-results
7+
.idea/

composer.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
22
"name": "pod-point/laravel-aws-pubsub",
33
"description": "A Laravel broadcasting driver and queue driver that broadcasts and listens to published events utilising AWS SNS, EventBridge and SQS.",
4-
"keywords": ["laravel", "broadcasting", "broadcast", "queue", "listeners", "pubsub", "aws", "sns", "sqs"],
4+
"keywords": [
5+
"laravel",
6+
"broadcasting",
7+
"broadcast",
8+
"queue",
9+
"listeners",
10+
"pubsub",
11+
"aws",
12+
"sns",
13+
"sqs"
14+
],
515
"homepage": "https://github.com/pod-point/laravel-aws-pubsub",
616
"license": "MIT",
717
"authors": [
@@ -11,13 +21,13 @@
1121
}
1222
],
1323
"require": {
14-
"php": "^7.3|^8.0",
24+
"php": "^8.0",
1525
"ext-json": "*",
1626
"aws/aws-sdk-php": "^3.155",
17-
"illuminate/support": "^8.52|^9.0|^10.0"
27+
"illuminate/support": "^8.52|^9.0|^10.0|^11.0"
1828
},
1929
"require-dev": {
20-
"orchestra/testbench": "^6.0|^7.0"
30+
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0"
2131
},
2232
"autoload": {
2333
"psr-4": {

phpunit.xml.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
beStrictAboutTestsThatDoNotTestAnything="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
failOnWarning="true"
66
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
107
processIsolation="false"
118
stopOnFailure="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
1212
>
1313
<testsuites>
1414
<testsuite name="Package Test Suite">
15-
<directory suffix=".php">./tests/</directory>
15+
<directory suffix="Test.php">./tests/</directory>
1616
</testsuite>
1717
</testsuites>
1818
</phpunit>

tests/Console/InstallCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PodPoint\AwsPubSub\Tests\Console;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use PodPoint\AwsPubSub\Tests\TestCase;
67

78
class InstallCommandTest extends TestCase
@@ -21,33 +22,32 @@ public function tearDown(): void
2122
copy(config_path('app.original'), config_path('app.php'));
2223
}
2324

25+
#[Test]
2426
/** @test */
2527
public function it_can_install_the_service_provider()
2628
{
2729
$this->assertFileDoesNotExist(app_path('Providers').'/PubSubEventServiceProvider.php');
28-
$this->assertStringNotContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php')));
2930

3031
$this->artisan('pubsub:install')
3132
->expectsOutput('PubSubEventServiceProvider created successfully.')
3233
->assertExitCode(0);
3334

3435
$this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php');
35-
$this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php')));
3636
}
3737

38+
39+
#[Test]
3840
/** @test */
3941
public function it_does_not_install_the_service_provider_if_already_existing()
4042
{
4143
$this->artisan('pubsub:install')->assertExitCode(0);
4244

4345
$this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php');
44-
$this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php')));
4546

4647
$this->artisan('pubsub:install')
4748
->expectsOutput('PubSubEventServiceProvider already exists!')
4849
->assertExitCode(1);
4950

5051
$this->assertFileExists(app_path('Providers').'/PubSubEventServiceProvider.php');
51-
$this->assertStringContainsString('PubSubEventServiceProvider', file_get_contents(config_path('app.php')));
5252
}
5353
}

tests/Console/ListenerMakeCommandTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Support\Facades\Artisan;
66
use Illuminate\Support\Str;
7+
use PHPUnit\Framework\Attributes\Test;
78
use PodPoint\AwsPubSub\Tests\TestCase;
89

910
class ListenerMakeCommandTest extends TestCase
@@ -22,6 +23,7 @@ public function tearDown(): void
2223
$this->cleanup();
2324
}
2425

26+
#[Test]
2527
/** @test */
2628
public function it_can_generate_pubsub_event_listeners()
2729
{
@@ -35,6 +37,7 @@ public function it_can_generate_pubsub_event_listeners()
3537
$this->assertFileExists(app_path('Listeners/PubSub/SomeListener.php'));
3638
}
3739

40+
#[Test]
3841
/** @test */
3942
public function it_cannot_generate_pubsub_event_listeners_which_already_exist()
4043
{

tests/EventServiceProviderTest.php

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
namespace PodPoint\AwsPubSub\Tests;
44

55
use Illuminate\Support\Facades\Event;
6+
use PHPUnit\Framework\Attributes\DataProvider;
7+
use PHPUnit\Framework\Attributes\Test;
68
use PodPoint\AwsPubSub\EventServiceProvider;
79

810
class EventServiceProviderTest extends TestCase
911
{
12+
#[Test]
1013
/** @test */
1114
public function it_can_prepare_configuration_credentials()
1215
{
@@ -27,6 +30,7 @@ public function it_can_prepare_configuration_credentials()
2730
], $config);
2831
}
2932

33+
#[Test]
3034
/** @test */
3135
public function it_can_prepare_configuration_credentials_with_a_token()
3236
{
@@ -50,6 +54,7 @@ public function it_can_prepare_configuration_credentials_with_a_token()
5054
], $config);
5155
}
5256

57+
#[Test]
5358
/** @test */
5459
public function it_can_make_sure_some_aws_credentials_are_provided_before_preparing_the_credentials()
5560
{
@@ -61,65 +66,64 @@ public function it_can_make_sure_some_aws_credentials_are_provided_before_prepar
6166
$this->assertArrayNotHasKey('credentials', $config);
6267
}
6368

64-
public function invalidCredentialsDataProvider()
69+
public static function invalidCredentialsDataProvider()
6570
{
6671
return [
6772
'key_is_empty' => [
68-
'creds' => [
73+
[
6974
'key' => '',
7075
'secret' => 'some_secret',
7176
],
7277
],
7378
'secret_is_empty' => [
74-
'creds' => [
79+
[
7580
'key' => 'some_key',
7681
'secret' => '',
7782
],
7883
],
7984
'key_and_secret_are_empty' => [
80-
'creds' => [
85+
[
8186
'key' => '',
8287
'secret' => '',
8388
],
8489
],
8590
'key_is_null' => [
86-
'creds' => [
91+
[
8792
'key' => null,
8893
'secret' => 'some_secret',
8994
],
9095
],
9196
'secret_is_null' => [
92-
'creds' => [
97+
[
9398
'key' => 'some_key',
9499
'secret' => null,
95100
],
96101
],
97102
'key_and_secret_are_null' => [
98-
'creds' => [
103+
[
99104
'key' => null,
100105
'secret' => null,
101106
],
102107
],
103108
'key_is_empty_and_secret_is_null' => [
104-
'creds' => [
109+
[
105110
'key' => '',
106111
'secret' => null,
107112
],
108113
],
109114
'key_is_null_and_secret_is_empty' => [
110-
'creds' => [
115+
[
111116
'key' => null,
112117
'secret' => '',
113118
],
114119
],
115120
];
116121
}
117122

118-
/**
119-
* @test
120-
*
121-
* @dataProvider invalidCredentialsDataProvider
122-
*/
123+
#[Test]
124+
/** @test */
125+
#[DataProvider('invalidCredentialsDataProvider')]
126+
/** @dataProvider invalidCredentialsDataProvider */
123127
public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(array $invalidCredentials)
124128
{
125129
$config = EventServiceProvider::prepareConfigurationCredentials(array_merge([
@@ -130,9 +134,8 @@ public function it_can_make_sure_some_aws_credentials_are_provided_and_valid(arr
130134
$this->assertArrayNotHasKey('credentials', $config);
131135
}
132136

133-
/**
134-
* @test
135-
*/
137+
#[Test]
138+
/** @test */
136139
public function it_can_register_listeners_when_listen_array_is_populated()
137140
{
138141
$this->app->register(TestPubSubEventServiceProvider::class);

tests/Pub/BasicEvents/EventBridgeTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Support\Facades\Log;
77
use Mockery as m;
88
use Mockery\MockInterface;
9+
use PHPUnit\Framework\Attributes\Test;
910
use PodPoint\AwsPubSub\Tests\Pub\Concerns\InteractsWithEventBridge;
1011
use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrieved;
1112
use PodPoint\AwsPubSub\Tests\Pub\TestClasses\Events\UserRetrievedWithCustomName;
@@ -18,6 +19,7 @@ class EventBridgeTest extends TestCase
1819
{
1920
use InteractsWithEventBridge;
2021

22+
#[Test]
2123
/** @test */
2224
public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type_and_serialised_event_as_the_detail()
2325
{
@@ -38,6 +40,7 @@ public function it_broadcasts_basic_event_with_the_event_name_as_the_detail_type
3840
event($event);
3941
}
4042

43+
#[Test]
4144
/** @test */
4245
public function it_broadcasts_basic_event_with_action()
4346
{
@@ -56,6 +59,7 @@ public function it_broadcasts_basic_event_with_action()
5659
event($event);
5760
}
5861

62+
#[Test]
5963
/** @test */
6064
public function it_broadcasts_basic_event_with_action_and_custom_payload()
6165
{
@@ -77,6 +81,7 @@ public function it_broadcasts_basic_event_with_action_and_custom_payload()
7781
event($event);
7882
}
7983

84+
#[Test]
8085
/** @test */
8186
public function it_broadcasts_basic_event_to_multiple_channels_as_buses()
8287
{
@@ -101,6 +106,7 @@ public function it_broadcasts_basic_event_to_multiple_channels_as_buses()
101106
event($event);
102107
}
103108

109+
#[Test]
104110
/** @test */
105111
public function it_can_use_a_source()
106112
{
@@ -125,6 +131,7 @@ public function it_can_use_a_source()
125131
event($event);
126132
}
127133

134+
#[Test]
128135
/** @test */
129136
public function it_logs_errors_when_events_fail_to_send()
130137
{

0 commit comments

Comments
 (0)