diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 21fc72e..1b5d015 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,12 +13,12 @@ jobs: strategy: fail-fast: false matrix: - php: [ 8.0, 8.1, 8.2, 8.3 ] - laravel: [ 8, 9, 10 ] + php: [ 8.1, 8.2, 8.3 ] + laravel: [ 10, 11 ] stability: [ prefer-lowest, prefer-stable ] exclude: - - php: 8.0 - laravel: 10 + - php: 8.1 + laravel: 11 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (${{ matrix.stability }}) @@ -34,11 +34,6 @@ jobs: tools: composer:v2 coverage: none - - name: Patch testbench version - if: matrix.laravel == 8 - run: | - composer require "orchestra/testbench=^6.23" --dev --no-interaction --no-update - # https://github.com/briannesbitt/Carbon/releases/tag/2.62.1 - name: Patch Carbon version if: matrix.php == 8.2 || matrix.php == 8.3 @@ -51,4 +46,7 @@ jobs: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit + + - name: Run phpstan + run: vendor/bin/phpstan analyse --error-format=github diff --git a/composer.json b/composer.json index 874ff55..7072999 100644 --- a/composer.json +++ b/composer.json @@ -18,19 +18,21 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-json": "*", - "illuminate/cache": "^8.0|^9.0|^10.0", - "illuminate/config": "^8.0|^9.0|^10.0", - "illuminate/contracts": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0", - "illuminate/console": "^8.0|^9.0|^10.0", - "illuminate/validation": "^8.0|^9.0|^10.0" + "illuminate/cache": "^10.0|^11.0", + "illuminate/config": "^10.0|^11.0", + "illuminate/contracts": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0", + "illuminate/validation": "^10.0|^11.0" }, "require-dev": { "mockery/mockery": "^1.4.2", "orchestra/testbench": "*", - "phpunit/phpunit": "^9.5.10" + "phpunit/phpunit": "^10.5", + "larastan/larastan": "^2.9", + "laravel/pint": "^1.14" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..3ba92f3 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,12 @@ +includes: + - ./vendor/larastan/larastan/extension.neon + +parameters: + + paths: + - src + + # 8 is the highest level + level: 5 + + checkMissingIterableValueType: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7d75852..451acf8 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,18 @@ - +> - ./tests/ + tests + tests/TestCase.php - - - ./src - - + + + src + + diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Console/UpdateDisposableDomainsCommandTest.php b/tests/Console/UpdateDisposableDomainsCommandTest.php index 9ee337b..024ff57 100644 --- a/tests/Console/UpdateDisposableDomainsCommandTest.php +++ b/tests/Console/UpdateDisposableDomainsCommandTest.php @@ -3,12 +3,13 @@ namespace Propaganistas\LaravelDisposableEmail\Tests\Console; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Test; use Propaganistas\LaravelDisposableEmail\Contracts\Fetcher; use Propaganistas\LaravelDisposableEmail\Tests\TestCase; class UpdateDisposableDomainsCommandTest extends TestCase { - /** @test */ + #[Test] public function it_creates_the_file() { $this->assertFileDoesNotExist($this->storagePath); @@ -24,7 +25,7 @@ public function it_creates_the_file() $this->assertContains('yopmail.com', $domains); } - /** @test */ + #[Test] public function it_overwrites_the_file() { file_put_contents($this->storagePath, json_encode(['foo'])); @@ -41,7 +42,7 @@ public function it_overwrites_the_file() $this->assertNotContains('foo', $domains); } - /** @test */ + #[Test] public function it_doesnt_overwrite_on_fetch_failure() { $this->expectException(InvalidArgumentException::class); @@ -60,7 +61,7 @@ public function it_doesnt_overwrite_on_fetch_failure() $this->assertEquals(['foo'], $domains); } - /** @test */ + #[Test] public function it_can_use_a_custom_fetcher() { file_put_contents($this->storagePath, json_encode(['foo'])); @@ -77,7 +78,7 @@ public function it_can_use_a_custom_fetcher() $this->assertEquals(['bar'], $domains); } - /** @test */ + #[Test] public function custom_fetchers_need_fetcher_contract() { file_put_contents($this->storagePath, json_encode(['foo'])); @@ -94,7 +95,7 @@ public function custom_fetchers_need_fetcher_contract() $this->assertNotEquals(['foo'], $domains); } - /** @test */ + #[Test] public function it_processes_legacy_source_config() { file_put_contents($this->storagePath, json_encode(['foo'])); diff --git a/tests/DisposableDomainsTest.php b/tests/DisposableDomainsTest.php index 73b673d..defa3ef 100644 --- a/tests/DisposableDomainsTest.php +++ b/tests/DisposableDomainsTest.php @@ -2,23 +2,24 @@ namespace Propaganistas\LaravelDisposableEmail\Tests; +use PHPUnit\Framework\Attributes\Test; use Propaganistas\LaravelDisposableEmail\DisposableDomains; class DisposableDomainsTest extends TestCase { - /** @test */ + #[Test] public function it_can_be_resolved_using_alias() { $this->assertEquals(DisposableDomains::class, get_class($this->app->make('disposable_email.domains'))); } - /** @test */ + #[Test] public function it_can_be_resolved_using_class() { $this->assertEquals(DisposableDomains::class, get_class($this->app->make(DisposableDomains::class))); } - /** @test */ + #[Test] public function it_can_get_storage_path() { $this->assertEquals( @@ -27,7 +28,7 @@ public function it_can_get_storage_path() ); } - /** @test */ + #[Test] public function it_can_set_storage_path() { $this->disposable()->setStoragePath('foo'); @@ -35,7 +36,7 @@ public function it_can_set_storage_path() $this->assertEquals('foo', $this->disposable()->getStoragePath()); } - /** @test */ + #[Test] public function it_can_get_cache_key() { $this->assertEquals( @@ -44,7 +45,7 @@ public function it_can_get_cache_key() ); } - /** @test */ + #[Test] public function it_can_set_cache_key() { $this->disposable()->setCacheKey('foo'); @@ -52,7 +53,7 @@ public function it_can_set_cache_key() $this->assertEquals('foo', $this->disposable()->getCacheKey()); } - /** @test */ + #[Test] public function it_takes_cached_domains_if_available() { $this->app['cache.store'][$this->disposable()->getCacheKey()] = ['foo']; @@ -64,7 +65,7 @@ public function it_takes_cached_domains_if_available() $this->assertEquals(['foo'], $domains); } - /** @test */ + #[Test] public function it_flushes_invalid_cache_values() { $this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo'; @@ -74,7 +75,7 @@ public function it_flushes_invalid_cache_values() $this->assertNotEquals('foo', $this->app['cache.store'][$this->disposable()->getCacheKey()]); } - /** @test */ + #[Test] public function it_skips_cache_when_configured() { $this->app['config']['disposable-email.cache.enabled'] = false; @@ -86,7 +87,7 @@ public function it_skips_cache_when_configured() $this->assertContains('yopmail.com', $domains); } - /** @test */ + #[Test] public function it_takes_storage_domains_when_cache_is_not_available() { $this->app['config']['disposable-email.cache.enabled'] = false; @@ -100,7 +101,7 @@ public function it_takes_storage_domains_when_cache_is_not_available() $this->assertEquals(['foo'], $domains); } - /** @test */ + #[Test] public function it_takes_package_domains_when_storage_is_not_available() { $this->app['config']['disposable-email.cache.enabled'] = false; @@ -111,7 +112,7 @@ public function it_takes_package_domains_when_storage_is_not_available() $this->assertContains('yopmail.com', $domains); } - /** @test */ + #[Test] public function it_can_flush_storage() { file_put_contents($this->storagePath, 'foo'); @@ -121,7 +122,7 @@ public function it_can_flush_storage() $this->assertFileDoesNotExist($this->storagePath); } - /** @test */ + #[Test] public function it_doesnt_throw_exceptions_for_flush_storage_when_file_doesnt_exist() { $this->disposable()->flushStorage(); @@ -129,7 +130,7 @@ public function it_doesnt_throw_exceptions_for_flush_storage_when_file_doesnt_ex $this->assertTrue(true); } - /** @test */ + #[Test] public function it_can_flush_cache() { $this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo'; @@ -141,7 +142,7 @@ public function it_can_flush_cache() $this->assertNull($this->app['cache']->get($this->disposable()->getCacheKey())); } - /** @test */ + #[Test] public function it_can_verify_disposability() { $this->assertTrue($this->disposable()->isDisposable('example@yopmail.com')); @@ -153,7 +154,7 @@ public function it_can_verify_disposability() $this->assertTrue($this->disposable()->isIndisposable('example@gmail.com')); } - /** @test */ + #[Test] public function it_checks_the_full_email_domain() { $this->assertTrue($this->disposable()->isDisposable('example@mailinator.com')); @@ -161,7 +162,7 @@ public function it_checks_the_full_email_domain() $this->assertTrue($this->disposable()->isNotDisposable('example@isnotdisposable.mailinator.com')); } - /** @test */ + #[Test] public function it_can_exclude_whitelisted_domains() { $this->disposable()->setWhitelist(['yopmail.com']); diff --git a/tests/Validation/IndisposableTest.php b/tests/Validation/IndisposableTest.php index 830fa0f..6af0caa 100644 --- a/tests/Validation/IndisposableTest.php +++ b/tests/Validation/IndisposableTest.php @@ -2,12 +2,13 @@ namespace Propaganistas\LaravelDisposableEmail\Tests\Validation; +use PHPUnit\Framework\Attributes\Test; use Propaganistas\LaravelDisposableEmail\Tests\TestCase; use Propaganistas\LaravelDisposableEmail\Validation\Indisposable; class IndisposableTest extends TestCase { - /** @test */ + #[Test] public function it_should_pass_for_indisposable_emails() { $validator = new Indisposable; @@ -16,7 +17,7 @@ public function it_should_pass_for_indisposable_emails() $this->assertTrue($validator->validate(null, $email, null, null)); } - /** @test */ + #[Test] public function it_should_fail_for_disposable_emails() { $validator = new Indisposable; @@ -25,7 +26,7 @@ public function it_should_fail_for_disposable_emails() $this->assertFalse($validator->validate(null, $email, null, null)); } - /** @test */ + #[Test] public function it_is_usable_through_the_validator() { $passingValidation = $this->app['validator']->make(['email' => 'example@gmail.com'], ['email' => 'indisposable']);