1313
1414namespace FOS \OAuthServerBundle \Tests \Entity ;
1515
16+ use Doctrine \Common \Persistence \ObjectRepository ;
1617use Doctrine \ORM \AbstractQuery ;
1718use Doctrine \ORM \EntityManager ;
1819use Doctrine \ORM \EntityManagerInterface ;
@@ -64,7 +65,6 @@ public function setUp()
6465 ;
6566
6667 $ this ->entityManager
67- ->expects ($ this ->once ())
6868 ->method ('getRepository ' )
6969 ->with ($ this ->className )
7070 ->willReturn ($ this ->repository )
@@ -76,7 +76,6 @@ public function setUp()
7676 public function testConstructWillSetParameters ()
7777 {
7878 $ this ->assertAttributeSame ($ this ->entityManager , 'em ' , $ this ->instance );
79- $ this ->assertAttributeSame ($ this ->repository , 'repository ' , $ this ->instance );
8079 $ this ->assertAttributeSame ($ this ->className , 'class ' , $ this ->instance );
8180 }
8281
@@ -228,4 +227,29 @@ public function testDeleteExpired()
228227
229228 $ this ->assertSame ($ randomResult , $ this ->instance ->deleteExpired ());
230229 }
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+ }
231255}
0 commit comments