Skip to content

Commit 46579d7

Browse files
committed
Support Laravel 11
1 parent 51f3b47 commit 46579d7

File tree

8 files changed

+69
-57
lines changed

8 files changed

+69
-57
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: [ 8.0, 8.1, 8.2, 8.3 ]
17-
laravel: [ 8, 9, 10 ]
16+
php: [ 8.1, 8.2, 8.3 ]
17+
laravel: [ 10, 11 ]
1818
stability: [ prefer-lowest, prefer-stable ]
1919
exclude:
20-
- php: 8.0
21-
laravel: 10
20+
- php: 8.1
21+
laravel: 11
2222

2323
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (${{ matrix.stability }})
2424

@@ -34,11 +34,6 @@ jobs:
3434
tools: composer:v2
3535
coverage: none
3636

37-
- name: Patch testbench version
38-
if: matrix.laravel == 8
39-
run: |
40-
composer require "orchestra/testbench=^6.23" --dev --no-interaction --no-update
41-
4237
# https://github.com/briannesbitt/Carbon/releases/tag/2.62.1
4338
- name: Patch Carbon version
4439
if: matrix.php == 8.2 || matrix.php == 8.3
@@ -51,4 +46,7 @@ jobs:
5146
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
5247
5348
- name: Execute tests
54-
run: vendor/bin/phpunit --verbose
49+
run: vendor/bin/phpunit
50+
51+
- name: Run phpstan
52+
run: vendor/bin/phpstan analyse --error-format=github

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.0",
21+
"php": "^8.1",
2222
"ext-json": "*",
23-
"illuminate/cache": "^8.0|^9.0|^10.0",
24-
"illuminate/config": "^8.0|^9.0|^10.0",
25-
"illuminate/contracts": "^8.0|^9.0|^10.0",
26-
"illuminate/support": "^8.0|^9.0|^10.0",
27-
"illuminate/console": "^8.0|^9.0|^10.0",
28-
"illuminate/validation": "^8.0|^9.0|^10.0"
23+
"illuminate/cache": "^10.0|^11.0",
24+
"illuminate/config": "^10.0|^11.0",
25+
"illuminate/contracts": "^10.0|^11.0",
26+
"illuminate/support": "^10.0|^11.0",
27+
"illuminate/console": "^10.0|^11.0",
28+
"illuminate/validation": "^10.0|^11.0"
2929
},
3030
"require-dev": {
3131
"mockery/mockery": "^1.4.2",
3232
"orchestra/testbench": "*",
33-
"phpunit/phpunit": "^9.5.10"
33+
"phpunit/phpunit": "^10.5",
34+
"larastan/larastan": "^2.9",
35+
"laravel/pint": "^1.14"
3436
},
3537
"autoload": {
3638
"psr-4": {

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- ./vendor/larastan/larastan/extension.neon
3+
4+
parameters:
5+
6+
paths:
7+
- src
8+
9+
# 8 is the highest level
10+
level: 5
11+
12+
checkMissingIterableValueType: false

phpunit.xml.dist

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false">
6+
>
117
<testsuites>
128
<testsuite name="Package Test Suite">
13-
<directory suffix=".php">./tests/</directory>
9+
<directory suffix=".php">tests</directory>
10+
<exclude>tests/TestCase.php</exclude>
1411
</testsuite>
1512
</testsuites>
16-
<filter>
17-
<whitelist addUncoveredFilesFromWhitelist="true">
18-
<directory suffix=".php">./src</directory>
19-
</whitelist>
20-
</filter>
13+
<source>
14+
<include>
15+
<directory>src</directory>
16+
</include>
17+
</source>
2118
</phpunit>

tests/.gitkeep

Whitespace-only changes.

tests/Console/UpdateDisposableDomainsCommandTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace Propaganistas\LaravelDisposableEmail\Tests\Console;
44

55
use InvalidArgumentException;
6+
use PHPUnit\Framework\Attributes\Test;
67
use Propaganistas\LaravelDisposableEmail\Contracts\Fetcher;
78
use Propaganistas\LaravelDisposableEmail\Tests\TestCase;
89

910
class UpdateDisposableDomainsCommandTest extends TestCase
1011
{
11-
/** @test */
12+
#[Test]
1213
public function it_creates_the_file()
1314
{
1415
$this->assertFileDoesNotExist($this->storagePath);
@@ -24,7 +25,7 @@ public function it_creates_the_file()
2425
$this->assertContains('yopmail.com', $domains);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_overwrites_the_file()
2930
{
3031
file_put_contents($this->storagePath, json_encode(['foo']));
@@ -41,7 +42,7 @@ public function it_overwrites_the_file()
4142
$this->assertNotContains('foo', $domains);
4243
}
4344

44-
/** @test */
45+
#[Test]
4546
public function it_doesnt_overwrite_on_fetch_failure()
4647
{
4748
$this->expectException(InvalidArgumentException::class);
@@ -60,7 +61,7 @@ public function it_doesnt_overwrite_on_fetch_failure()
6061
$this->assertEquals(['foo'], $domains);
6162
}
6263

63-
/** @test */
64+
#[Test]
6465
public function it_can_use_a_custom_fetcher()
6566
{
6667
file_put_contents($this->storagePath, json_encode(['foo']));
@@ -77,7 +78,7 @@ public function it_can_use_a_custom_fetcher()
7778
$this->assertEquals(['bar'], $domains);
7879
}
7980

80-
/** @test */
81+
#[Test]
8182
public function custom_fetchers_need_fetcher_contract()
8283
{
8384
file_put_contents($this->storagePath, json_encode(['foo']));
@@ -94,7 +95,7 @@ public function custom_fetchers_need_fetcher_contract()
9495
$this->assertNotEquals(['foo'], $domains);
9596
}
9697

97-
/** @test */
98+
#[Test]
9899
public function it_processes_legacy_source_config()
99100
{
100101
file_put_contents($this->storagePath, json_encode(['foo']));

tests/DisposableDomainsTest.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
namespace Propaganistas\LaravelDisposableEmail\Tests;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Propaganistas\LaravelDisposableEmail\DisposableDomains;
67

78
class DisposableDomainsTest extends TestCase
89
{
9-
/** @test */
10+
#[Test]
1011
public function it_can_be_resolved_using_alias()
1112
{
1213
$this->assertEquals(DisposableDomains::class, get_class($this->app->make('disposable_email.domains')));
1314
}
1415

15-
/** @test */
16+
#[Test]
1617
public function it_can_be_resolved_using_class()
1718
{
1819
$this->assertEquals(DisposableDomains::class, get_class($this->app->make(DisposableDomains::class)));
1920
}
2021

21-
/** @test */
22+
#[Test]
2223
public function it_can_get_storage_path()
2324
{
2425
$this->assertEquals(
@@ -27,15 +28,15 @@ public function it_can_get_storage_path()
2728
);
2829
}
2930

30-
/** @test */
31+
#[Test]
3132
public function it_can_set_storage_path()
3233
{
3334
$this->disposable()->setStoragePath('foo');
3435

3536
$this->assertEquals('foo', $this->disposable()->getStoragePath());
3637
}
3738

38-
/** @test */
39+
#[Test]
3940
public function it_can_get_cache_key()
4041
{
4142
$this->assertEquals(
@@ -44,15 +45,15 @@ public function it_can_get_cache_key()
4445
);
4546
}
4647

47-
/** @test */
48+
#[Test]
4849
public function it_can_set_cache_key()
4950
{
5051
$this->disposable()->setCacheKey('foo');
5152

5253
$this->assertEquals('foo', $this->disposable()->getCacheKey());
5354
}
5455

55-
/** @test */
56+
#[Test]
5657
public function it_takes_cached_domains_if_available()
5758
{
5859
$this->app['cache.store'][$this->disposable()->getCacheKey()] = ['foo'];
@@ -64,7 +65,7 @@ public function it_takes_cached_domains_if_available()
6465
$this->assertEquals(['foo'], $domains);
6566
}
6667

67-
/** @test */
68+
#[Test]
6869
public function it_flushes_invalid_cache_values()
6970
{
7071
$this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo';
@@ -74,7 +75,7 @@ public function it_flushes_invalid_cache_values()
7475
$this->assertNotEquals('foo', $this->app['cache.store'][$this->disposable()->getCacheKey()]);
7576
}
7677

77-
/** @test */
78+
#[Test]
7879
public function it_skips_cache_when_configured()
7980
{
8081
$this->app['config']['disposable-email.cache.enabled'] = false;
@@ -86,7 +87,7 @@ public function it_skips_cache_when_configured()
8687
$this->assertContains('yopmail.com', $domains);
8788
}
8889

89-
/** @test */
90+
#[Test]
9091
public function it_takes_storage_domains_when_cache_is_not_available()
9192
{
9293
$this->app['config']['disposable-email.cache.enabled'] = false;
@@ -100,7 +101,7 @@ public function it_takes_storage_domains_when_cache_is_not_available()
100101
$this->assertEquals(['foo'], $domains);
101102
}
102103

103-
/** @test */
104+
#[Test]
104105
public function it_takes_package_domains_when_storage_is_not_available()
105106
{
106107
$this->app['config']['disposable-email.cache.enabled'] = false;
@@ -111,7 +112,7 @@ public function it_takes_package_domains_when_storage_is_not_available()
111112
$this->assertContains('yopmail.com', $domains);
112113
}
113114

114-
/** @test */
115+
#[Test]
115116
public function it_can_flush_storage()
116117
{
117118
file_put_contents($this->storagePath, 'foo');
@@ -121,15 +122,15 @@ public function it_can_flush_storage()
121122
$this->assertFileDoesNotExist($this->storagePath);
122123
}
123124

124-
/** @test */
125+
#[Test]
125126
public function it_doesnt_throw_exceptions_for_flush_storage_when_file_doesnt_exist()
126127
{
127128
$this->disposable()->flushStorage();
128129

129130
$this->assertTrue(true);
130131
}
131132

132-
/** @test */
133+
#[Test]
133134
public function it_can_flush_cache()
134135
{
135136
$this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo';
@@ -141,7 +142,7 @@ public function it_can_flush_cache()
141142
$this->assertNull($this->app['cache']->get($this->disposable()->getCacheKey()));
142143
}
143144

144-
/** @test */
145+
#[Test]
145146
public function it_can_verify_disposability()
146147
{
147148
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
@@ -153,15 +154,15 @@ public function it_can_verify_disposability()
153154
$this->assertTrue($this->disposable()->isIndisposable('[email protected]'));
154155
}
155156

156-
/** @test */
157+
#[Test]
157158
public function it_checks_the_full_email_domain()
158159
{
159160
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
160161
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
161162
$this->assertTrue($this->disposable()->isNotDisposable('[email protected]'));
162163
}
163164

164-
/** @test */
165+
#[Test]
165166
public function it_can_exclude_whitelisted_domains()
166167
{
167168
$this->disposable()->setWhitelist(['yopmail.com']);

tests/Validation/IndisposableTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace Propaganistas\LaravelDisposableEmail\Tests\Validation;
44

5+
use PHPUnit\Framework\Attributes\Test;
56
use Propaganistas\LaravelDisposableEmail\Tests\TestCase;
67
use Propaganistas\LaravelDisposableEmail\Validation\Indisposable;
78

89
class IndisposableTest extends TestCase
910
{
10-
/** @test */
11+
#[Test]
1112
public function it_should_pass_for_indisposable_emails()
1213
{
1314
$validator = new Indisposable;
@@ -16,7 +17,7 @@ public function it_should_pass_for_indisposable_emails()
1617
$this->assertTrue($validator->validate(null, $email, null, null));
1718
}
1819

19-
/** @test */
20+
#[Test]
2021
public function it_should_fail_for_disposable_emails()
2122
{
2223
$validator = new Indisposable;
@@ -25,7 +26,7 @@ public function it_should_fail_for_disposable_emails()
2526
$this->assertFalse($validator->validate(null, $email, null, null));
2627
}
2728

28-
/** @test */
29+
#[Test]
2930
public function it_is_usable_through_the_validator()
3031
{
3132
$passingValidation = $this->app['validator']->make(['email' => '[email protected]'], ['email' => 'indisposable']);

0 commit comments

Comments
 (0)