@@ -98,6 +98,44 @@ public function testExistReturnsFalseIfInvalidToken()
98
98
$ this ->assertFalse ($ repo ->exists ($ user , 'wrong-token ' ));
99
99
}
100
100
101
+ public function testRecentlyCreatedReturnsFalseIfNoRowFoundForUser ()
102
+ {
103
+ $ repo = $ this ->getRepo ();
104
+ $ repo ->getConnection ()->shouldReceive ('table ' )->once ()->with ('table ' )->andReturn ($ query = m::mock (stdClass::class));
105
+ $ query ->shouldReceive ('where ' )->once ()->with ('email ' , 'email ' )->andReturn ($ query );
106
+ $ query ->shouldReceive ('first ' )->once ()->andReturn (null );
107
+ $ user = m::mock (CanResetPassword::class);
108
+ $ user ->shouldReceive ('getEmailForPasswordReset ' )->once ()->andReturn ('email ' );
109
+
110
+ $ this ->assertFalse ($ repo ->recentlyCreated ($ user ));
111
+ }
112
+
113
+ public function testRecentlyCreatedReturnsTrueIfRecordIsRecentlyCreated ()
114
+ {
115
+ $ repo = $ this ->getRepo ();
116
+ $ repo ->getConnection ()->shouldReceive ('table ' )->once ()->with ('table ' )->andReturn ($ query = m::mock (stdClass::class));
117
+ $ query ->shouldReceive ('where ' )->once ()->with ('email ' , 'email ' )->andReturn ($ query );
118
+ $ date = Carbon::now ()->subSeconds (59 )->toDateTimeString ();
119
+ $ query ->shouldReceive ('first ' )->once ()->andReturn ((object ) ['created_at ' => $ date , 'token ' => 'hashed-token ' ]);
120
+ $ user = m::mock (CanResetPassword::class);
121
+ $ user ->shouldReceive ('getEmailForPasswordReset ' )->once ()->andReturn ('email ' );
122
+
123
+ $ this ->assertTrue ($ repo ->recentlyCreated ($ user ));
124
+ }
125
+
126
+ public function testRecentlyCreatedReturnsFalseIfValidRecordExists ()
127
+ {
128
+ $ repo = $ this ->getRepo ();
129
+ $ repo ->getConnection ()->shouldReceive ('table ' )->once ()->with ('table ' )->andReturn ($ query = m::mock (stdClass::class));
130
+ $ query ->shouldReceive ('where ' )->once ()->with ('email ' , 'email ' )->andReturn ($ query );
131
+ $ date = Carbon::now ()->subSeconds (61 )->toDateTimeString ();
132
+ $ query ->shouldReceive ('first ' )->once ()->andReturn ((object ) ['created_at ' => $ date , 'token ' => 'hashed-token ' ]);
133
+ $ user = m::mock (CanResetPassword::class);
134
+ $ user ->shouldReceive ('getEmailForPasswordReset ' )->once ()->andReturn ('email ' );
135
+
136
+ $ this ->assertFalse ($ repo ->recentlyCreated ($ user ));
137
+ }
138
+
101
139
public function testDeleteMethodDeletesByToken ()
102
140
{
103
141
$ repo = $ this ->getRepo ();
0 commit comments