@@ -28,49 +28,49 @@ protected function getSut(
2828
2929 public function testMarkAsSentDelegatesToRepository (): void
3030 {
31- $ otpData = $ this ->createMock (UserInterface::class);
32- $ otpData ->method ('getId ' )->willReturn ($ userId = uniqid ());
31+ $ otpDataStub = $ this ->createStub (UserInterface::class);
32+ $ otpDataStub ->method ('getId ' )->willReturn ($ userId = uniqid ());
3333
34- $ userRepository = $ this ->createMock (UserRepositoryInterface::class);
35- $ userRepository ->method ('getUserOTPData ' )->willReturn ($ otpData );
36- $ userRepository ->expects ($ this ->once ())
34+ $ userRepositorySpy = $ this ->createMock (UserRepositoryInterface::class);
35+ $ userRepositorySpy ->method ('getUserOTPData ' )->willReturn ($ otpDataStub );
36+ $ userRepositorySpy ->expects ($ this ->once ())
3737 ->method ('markOtpAsSent ' )
3838 ->with ($ userId );
3939
40- $ service = $ this ->getSut (
41- userRepository: $ userRepository ,
40+ $ sut = $ this ->getSut (
41+ userRepository: $ userRepositorySpy ,
4242 );
4343
44- $ service ->markAsSent (uniqid ());
44+ $ sut ->markAsSent (uniqid ());
4545 }
4646
4747 public function testCanSendReturnsTrueWhenNeverSent (): void
4848 {
49- $ otpData = $ this ->createMock (UserInterface::class);
50- $ otpData ->method ('getLastSentAt ' )->willReturn (null );
49+ $ otpDataStub = $ this ->createStub (UserInterface::class);
50+ $ otpDataStub ->method ('getLastSentAt ' )->willReturn (null );
5151
52- $ userRepository = $ this ->createMock (UserRepositoryInterface::class);
53- $ userRepository ->method ('getUserOTPData ' )->willReturn ($ otpData );
52+ $ userRepositoryStub = $ this ->createStub (UserRepositoryInterface::class);
53+ $ userRepositoryStub ->method ('getUserOTPData ' )->willReturn ($ otpDataStub );
5454
55- $ service = $ this ->getSut (
56- userRepository: $ userRepository ,
55+ $ sut = $ this ->getSut (
56+ userRepository: $ userRepositoryStub ,
5757 );
5858
59- $ this ->assertTrue ($ service ->canSend (uniqid ()));
59+ $ this ->assertTrue ($ sut ->canSend (uniqid ()));
6060 }
6161
6262 public function testCanSendReturnsFalseWhenCooldownActive (): void
6363 {
6464 $ lastSent = (new DateTimeImmutable ())->modify ('-30 seconds ' );
6565
66- $ otpData = $ this ->createMock (UserInterface::class);
67- $ otpData ->method ('getLastSentAt ' )->willReturn ($ lastSent );
66+ $ otpDataStub = $ this ->createStub (UserInterface::class);
67+ $ otpDataStub ->method ('getLastSentAt ' )->willReturn ($ lastSent );
6868
69- $ userRepository = $ this ->createMock (UserRepositoryInterface::class);
70- $ userRepository ->method ('getUserOTPData ' )->willReturn ($ otpData );
69+ $ userRepositoryStub = $ this ->createStub (UserRepositoryInterface::class);
70+ $ userRepositoryStub ->method ('getUserOTPData ' )->willReturn ($ otpDataStub );
7171
7272 $ service = $ this ->getSut (
73- userRepository: $ userRepository ,
73+ userRepository: $ userRepositoryStub ,
7474 );
7575
7676 $ this ->assertFalse ($ service ->canSend (uniqid ()));
@@ -80,14 +80,14 @@ public function testCanSendReturnsTrueWhenCooldownPassed(): void
8080 {
8181 $ lastSent = (new DateTimeImmutable ())->modify ('-120 seconds ' );
8282
83- $ otpData = $ this ->createMock (UserInterface::class);
84- $ otpData ->method ('getLastSentAt ' )->willReturn ($ lastSent );
83+ $ otpDataStub = $ this ->createStub (UserInterface::class);
84+ $ otpDataStub ->method ('getLastSentAt ' )->willReturn ($ lastSent );
8585
86- $ userRepository = $ this ->createMock (UserRepositoryInterface::class);
87- $ userRepository ->method ('getUserOTPData ' )->willReturn ($ otpData );
86+ $ userRepositoryStub = $ this ->createStub (UserRepositoryInterface::class);
87+ $ userRepositoryStub ->method ('getUserOTPData ' )->willReturn ($ otpDataStub );
8888
8989 $ service = $ this ->getSut (
90- userRepository: $ userRepository ,
90+ userRepository: $ userRepositoryStub ,
9191 );
9292
9393 $ this ->assertTrue ($ service ->canSend (uniqid ()));
0 commit comments