13
13
14
14
namespace FOS \OAuthServerBundle \Tests \Entity ;
15
15
16
+ use Doctrine \Common \Persistence \ObjectRepository ;
16
17
use Doctrine \ORM \AbstractQuery ;
17
18
use Doctrine \ORM \EntityManager ;
18
19
use Doctrine \ORM \EntityManagerInterface ;
@@ -64,7 +65,6 @@ public function setUp()
64
65
;
65
66
66
67
$ this ->entityManager
67
- ->expects ($ this ->once ())
68
68
->method ('getRepository ' )
69
69
->with ($ this ->className )
70
70
->willReturn ($ this ->repository )
@@ -76,7 +76,6 @@ public function setUp()
76
76
public function testConstructWillSetParameters ()
77
77
{
78
78
$ this ->assertAttributeSame ($ this ->entityManager , 'em ' , $ this ->instance );
79
- $ this ->assertAttributeSame ($ this ->repository , 'repository ' , $ this ->instance );
80
79
$ this ->assertAttributeSame ($ this ->className , 'class ' , $ this ->instance );
81
80
}
82
81
@@ -228,4 +227,29 @@ public function testDeleteExpired()
228
227
229
228
$ this ->assertSame ($ randomResult , $ this ->instance ->deleteExpired ());
230
229
}
230
+
231
+ public function testExceptionWithObjectRepository ()
232
+ {
233
+ $ this ->repository = $ this ->getMockBuilder (ObjectRepository::class)
234
+ ->disableOriginalConstructor ()
235
+ ->getMock ()
236
+ ;
237
+
238
+ $ this ->entityManager = $ this ->getMockBuilder (EntityManager::class)
239
+ ->disableOriginalConstructor ()
240
+ ->getMock ()
241
+ ;
242
+
243
+ $ this ->entityManager
244
+ ->expects ($ this ->once ())
245
+ ->method ('getRepository ' )
246
+ ->with ($ this ->className )
247
+ ->willReturn ($ this ->repository )
248
+ ;
249
+
250
+ $ this ->instance = new TokenManager ($ this ->entityManager , $ this ->className );
251
+
252
+ $ this ->expectException (\RuntimeException::class);
253
+ $ this ->instance ->findTokenBy ([]);
254
+ }
231
255
}
0 commit comments