diff --git a/composer.json b/composer.json index 928acc8..d54081d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "orchestra/testbench": "^7.0|^8.0|^9.0", - "phpunit/phpunit": "^9.3|^10.4" + "phpunit/phpunit": "^9.3|^10.4|^11.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 54fd7b7..51a3ce7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,23 +1,10 @@ - + ./tests - diff --git a/tests/AuthBackend/AuthenticatesUsersTest.php b/tests/AuthBackend/AuthenticatesUsersTest.php index d25891c..06860e6 100644 --- a/tests/AuthBackend/AuthenticatesUsersTest.php +++ b/tests/AuthBackend/AuthenticatesUsersTest.php @@ -12,6 +12,7 @@ use Illuminate\Validation\ValidationException; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class AuthenticatesUsersTest extends TestCase { @@ -34,7 +35,7 @@ protected function defineDatabaseMigrations() $this->loadLaravelMigrations(); } - /** @test */ + #[Test] public function it_can_authenticate_a_user() { Event::fake(); @@ -57,7 +58,7 @@ public function it_can_authenticate_a_user() }); } - /** @test */ + #[Test] public function it_can_authenticate_a_user_with_remember_as_false() { Event::fake(); @@ -81,9 +82,7 @@ public function it_can_authenticate_a_user_with_remember_as_false() }); } - - - /** @test */ + #[Test] public function it_can_authenticate_a_user_with_remember_as_true() { Event::fake(); @@ -107,7 +106,7 @@ public function it_can_authenticate_a_user_with_remember_as_true() }); } - /** @test */ + #[Test] public function it_cant_authenticate_a_user_with_invalid_password() { $user = UserFactory::new()->create(); @@ -131,7 +130,7 @@ public function it_cant_authenticate_a_user_with_invalid_password() ], $response->exception->errors()); } - /** @test */ + #[Test] public function it_cant_authenticate_unknown_credential() { $request = Request::create('/login', 'POST', [ diff --git a/tests/AuthBackend/RegistersUsersTest.php b/tests/AuthBackend/RegistersUsersTest.php index fed3cb3..3f6ef0b 100644 --- a/tests/AuthBackend/RegistersUsersTest.php +++ b/tests/AuthBackend/RegistersUsersTest.php @@ -13,6 +13,7 @@ use Illuminate\Validation\ValidationException; use Orchestra\Testbench\Factories\UserFactory; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; class RegistersUsersTest extends TestCase { @@ -28,7 +29,7 @@ protected function defineDatabaseMigrations() $this->loadLaravelMigrations(); } - /** @test */ + #[Test] public function it_can_register_a_user() { $request = Request::create('/register', 'POST', [ diff --git a/tests/AuthBackend/ThrottleLoginsTest.php b/tests/AuthBackend/ThrottleLoginsTest.php index b2c2c3d..d59f658 100644 --- a/tests/AuthBackend/ThrottleLoginsTest.php +++ b/tests/AuthBackend/ThrottleLoginsTest.php @@ -2,20 +2,19 @@ namespace Laravel\Ui\Tests\AuthBackend; -use Illuminate\Foundation\Auth\ThrottlesLogins; +use Illuminate\Foundation\Auth\ThrottlesLogins as ThrottlesLoginsTrait; use Orchestra\Testbench\TestCase; use Illuminate\Http\Request; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; class ThrottleLoginsTest extends TestCase { - /** - * @test - * @dataProvider emailProvider - */ + #[Test] + #[DataProvider('emailProvider')] public function it_can_generate_throttle_key(string $email, string $expectedEmail): void { - $throttle = $this->getMockForTrait(ThrottlesLogins::class, [], '', true, true, true, ['username']); + $throttle = $this->createMock(ThrottlesLogins::class); $throttle->method('username')->willReturn('email'); $reflection = new \ReflectionClass($throttle); $method = $reflection->getMethod('throttleKey'); @@ -33,8 +32,18 @@ public static function emailProvider(): 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'], ]; } } + +class ThrottlesLogins +{ + use ThrottlesLoginsTrait; + + public function username() + { + return 'email'; + } +}