2
2
3
3
namespace Laravel \Ui \Tests \AuthBackend ;
4
4
5
- use Illuminate \Foundation \Auth \ThrottlesLogins ;
5
+ use Illuminate \Foundation \Auth \ThrottlesLogins as ThrottlesLoginsTrait ;
6
6
use Orchestra \Testbench \TestCase ;
7
7
use Illuminate \Http \Request ;
8
- use PHPUnit \Framework \MockObject \MockObject ;
8
+ use PHPUnit \Framework \Attributes \DataProvider ;
9
+ use PHPUnit \Framework \Attributes \Test ;
9
10
10
11
class ThrottleLoginsTest extends TestCase
11
12
{
12
- /**
13
- * @test
14
- * @dataProvider emailProvider
15
- */
13
+ #[Test]
14
+ #[DataProvider('emailProvider ' )]
16
15
public function it_can_generate_throttle_key (string $ email , string $ expectedEmail ): void
17
16
{
18
- $ throttle = $ this ->getMockForTrait (ThrottlesLogins::class, [], '' , true , true , true , [ ' username ' ] );
17
+ $ throttle = $ this ->createMock (ThrottlesLogins::class);
19
18
$ throttle ->method ('username ' )->willReturn ('email ' );
20
19
$ reflection = new \ReflectionClass ($ throttle );
21
20
$ method = $ reflection ->getMethod ('throttleKey ' );
@@ -33,8 +32,18 @@ public static function emailProvider(): array
33
32
return [
34
33
'lowercase special characters ' => [
'ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ ' ,
'[email protected] ' ],
35
34
'uppercase special characters ' => [
'ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ ' ,
'[email protected] ' ],
36
- 'special character numbers ' =>[
'test⑩⓸③@laravel.com ' ,
'[email protected] ' ],
35
+ 'special character numbers ' =>
[
'test⑩⓸③@laravel.com ' ,
'[email protected] ' ],
37
36
38
37
];
39
38
}
40
39
}
40
+
41
+ class ThrottlesLogins
42
+ {
43
+ use ThrottlesLoginsTrait;
44
+
45
+ public function username ()
46
+ {
47
+ return 'email ' ;
48
+ }
49
+ }
0 commit comments