diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3596323..8594c3f8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,23 +16,11 @@ jobs: strategy: fail-fast: true matrix: - php: [7.3, 7.4, '8.0', 8.1, 8.2, 8.3] - laravel: [8, 9, 10] + php: [8.1, 8.2, 8.3] + laravel: [10, 11] exclude: - - php: 7.3 - laravel: 9 - - php: 7.3 - laravel: 10 - - php: 7.4 - laravel: 9 - - php: 7.4 - laravel: 10 - - php: '8.0' - laravel: 10 - - php: 8.3 - laravel: 8 - - php: 8.3 - laravel: 9 + - php: 8.1 + laravel: 11 name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} @@ -53,4 +41,4 @@ jobs: run: composer require "illuminate/contracts=^${{ matrix.laravel }}" --prefer-dist --no-interaction - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 9e008ee7..53d793e1 100644 --- a/composer.json +++ b/composer.json @@ -14,17 +14,17 @@ } ], "require": { - "php": "^7.3|^8.0", + "php": "^8.1", "ext-json": "*", "bacon/bacon-qr-code": "^2.0", - "illuminate/support": "^8.82|^9.0|^10.0", - "pragmarx/google2fa": "^7.0|^8.0" + "illuminate/support": "^10.0|^11.0", + "pragmarx/google2fa": "^8.0" }, "require-dev": { "mockery/mockery": "^1.0", - "orchestra/testbench": "^6.34|^7.31|^8.11", + "orchestra/testbench": "^8.16|^9.0", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.4" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1bf9e93e..92386ad2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,11 @@ - + - ./tests/ + ./tests/ - + diff --git a/src/FortifyServiceProvider.php b/src/FortifyServiceProvider.php index 75042080..446ff516 100644 --- a/src/FortifyServiceProvider.php +++ b/src/FortifyServiceProvider.php @@ -136,7 +136,9 @@ protected function configurePublishing() __DIR__.'/../stubs/UpdateUserPassword.php' => app_path('Actions/Fortify/UpdateUserPassword.php'), ], 'fortify-support'); - $this->publishes([ + $method = method_exists($this, 'publishesMigrations') ? 'publishesMigrations' : 'publishes'; + + $this->{$method}([ __DIR__.'/../database/migrations' => database_path('migrations'), ], 'fortify-migrations'); } diff --git a/stubs/fortify.php b/stubs/fortify.php index 0fe22c89..cfe82722 100644 --- a/stubs/fortify.php +++ b/stubs/fortify.php @@ -1,6 +1,5 @@ RouteServiceProvider::HOME, + 'home' => '/home', /* |-------------------------------------------------------------------------- diff --git a/tests/AuthenticatedSessionControllerTest.php b/tests/AuthenticatedSessionControllerTest.php index fe99c6b3..9df58110 100644 --- a/tests/AuthenticatedSessionControllerTest.php +++ b/tests/AuthenticatedSessionControllerTest.php @@ -16,8 +16,10 @@ use Laravel\Fortify\LoginRateLimiter; use Laravel\Fortify\TwoFactorAuthenticatable; use Mockery; +use Orchestra\Testbench\Attributes\WithMigration; use PragmaRX\Google2FA\Google2FA; +#[WithMigration] class AuthenticatedSessionControllerTest extends OrchestraTestCase { use RefreshDatabase; @@ -210,12 +212,12 @@ static function ($mock) use ($username) { self::assertSame($expectedResult.'|192.168.0.1', $method->invoke($loginRateLimiter, $request)); } - public function usernameProvider(): array + public static function usernameProvider(): array { return [ 'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', 'test@laravel.com'], 'uppercase special characters' => ['ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ', 'test@laravel.com'], - 'special character numbers' =>['test⑩⓸③@laravel.com', 'test1043@laravel.com'], + 'special character numbers' => ['test⑩⓸③@laravel.com', 'test1043@laravel.com'], 'default email' => ['test@laravel.com', 'test@laravel.com'], ]; } diff --git a/tests/ConfirmablePasswordControllerTest.php b/tests/ConfirmablePasswordControllerTest.php index ec9ae430..b5cb0245 100644 --- a/tests/ConfirmablePasswordControllerTest.php +++ b/tests/ConfirmablePasswordControllerTest.php @@ -6,24 +6,22 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use Laravel\Fortify\Contracts\ConfirmPasswordViewResponse; use Laravel\Fortify\Fortify; +use Orchestra\Testbench\Attributes\WithMigration; +#[WithMigration] class ConfirmablePasswordControllerTest extends OrchestraTestCase { use RefreshDatabase; protected $user; - protected function setUp(): void + protected function afterRefreshingDatabase() { - $this->afterApplicationCreated(function () { - $this->user = TestConfirmPasswordUser::forceCreate([ - 'name' => 'Taylor Otwell', - 'email' => 'taylor@laravel.com', - 'password' => bcrypt('secret'), - ]); - }); - - parent::setUp(); + $this->user = TestConfirmPasswordUser::forceCreate([ + 'name' => 'Taylor Otwell', + 'email' => 'taylor@laravel.com', + 'password' => bcrypt('secret'), + ]); } public function test_the_confirm_password_view_is_returned() diff --git a/tests/OrchestraTestCase.php b/tests/OrchestraTestCase.php index 29628306..b2a3696b 100644 --- a/tests/OrchestraTestCase.php +++ b/tests/OrchestraTestCase.php @@ -2,14 +2,23 @@ namespace Laravel\Fortify\Tests; +use Illuminate\Foundation\Testing\RefreshDatabaseState; use Laravel\Fortify\Features; -use Orchestra\Testbench\Concerns\WithLaravelMigrations; use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase; abstract class OrchestraTestCase extends TestCase { - use WithLaravelMigrations, WithWorkbench; + use WithWorkbench; + + public function setUp(): void + { + if (class_exists(RefreshDatabaseState::class)) { + RefreshDatabaseState::$migrated = false; + } + + parent::setUp(); + } protected function defineEnvironment($app) { diff --git a/tests/TwoFactorAuthenticationControllerTest.php b/tests/TwoFactorAuthenticationControllerTest.php index 60310373..32aa9d62 100644 --- a/tests/TwoFactorAuthenticationControllerTest.php +++ b/tests/TwoFactorAuthenticationControllerTest.php @@ -9,8 +9,12 @@ use Laravel\Fortify\Events\TwoFactorAuthenticationDisabled; use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled; use Laravel\Fortify\TwoFactorAuthenticatable; +use Orchestra\Testbench\Attributes\DefineEnvironment; +use Orchestra\Testbench\Attributes\ResetRefreshDatabaseState; +use Orchestra\Testbench\Attributes\WithMigration; use PragmaRX\Google2FA\Google2FA; +#[WithMigration] class TwoFactorAuthenticationControllerTest extends OrchestraTestCase { use RefreshDatabase; @@ -62,9 +66,8 @@ public function test_two_factor_authentication_secret_key_can_be_retrieved() $this->assertEquals('foo', $response->original['secretKey']); } - /** - * @define-env withConfirmedTwoFactorAuthentication - */ + #[DefineEnvironment('withConfirmedTwoFactorAuthentication')] + #[ResetRefreshDatabaseState] public function test_two_factor_authentication_can_be_confirmed() { Event::fake(); @@ -100,9 +103,8 @@ public function test_two_factor_authentication_can_be_confirmed() $this->assertFalse($user->hasEnabledTwoFactorAuthentication()); } - /** - * @define-env withConfirmedTwoFactorAuthentication - */ + #[DefineEnvironment('withConfirmedTwoFactorAuthentication')] + #[ResetRefreshDatabaseState] public function test_two_factor_authentication_can_not_be_confirmed_with_invalid_code() { Event::fake();