File tree 2 files changed +19
-21
lines changed
2 files changed +19
-21
lines changed Original file line number Diff line number Diff line change 14
14
namespace FOS \OAuthServerBundle \Document ;
15
15
16
16
use Doctrine \ODM \MongoDB \DocumentManager ;
17
- use Doctrine \ODM \MongoDB \DocumentRepository ;
18
17
use FOS \OAuthServerBundle \Model \AuthCodeInterface ;
19
18
use FOS \OAuthServerBundle \Model \AuthCodeManager as BaseAuthCodeManager ;
20
19
@@ -25,24 +24,14 @@ class AuthCodeManager extends BaseAuthCodeManager
25
24
*/
26
25
protected $ dm ;
27
26
28
- /**
29
- * @var DocumentRepository
30
- */
31
- protected $ repository ;
32
-
33
27
/**
34
28
* @var string
35
29
*/
36
30
protected $ class ;
37
31
38
32
public function __construct (DocumentManager $ dm , $ class )
39
33
{
40
- // NOTE: bug in Doctrine, hinting DocumentRepository|ObjectRepository when only DocumentRepository is expected
41
- /** @var DocumentRepository $repository */
42
- $ repository = $ dm ->getRepository ($ class );
43
-
44
34
$ this ->dm = $ dm ;
45
- $ this ->repository = $ repository ;
46
35
$ this ->class = $ class ;
47
36
}
48
37
@@ -59,7 +48,7 @@ public function getClass()
59
48
*/
60
49
public function findAuthCodeBy (array $ criteria )
61
50
{
62
- return $ this ->repository ->findOneBy ($ criteria );
51
+ return $ this ->dm -> getRepository ( $ this -> class ) ->findOneBy ($ criteria );
63
52
}
64
53
65
54
/**
@@ -85,8 +74,10 @@ public function deleteAuthCode(AuthCodeInterface $authCode)
85
74
*/
86
75
public function deleteExpired ()
87
76
{
88
- $ result = $ this
89
- ->repository
77
+ /** @var \Doctrine\ODM\MongoDB\DocumentRepository $repository */
78
+ $ repository = $ this ->dm ->getRepository ($ this ->class );
79
+
80
+ $ result = $ repository
90
81
->createQueryBuilder ()
91
82
->remove ()
92
83
->field ('expiresAt ' )->lt (time ())
Original file line number Diff line number Diff line change @@ -65,13 +65,6 @@ public function setUp()
65
65
;
66
66
$ this ->className = 'TestClassName ' .\random_bytes (5 );
67
67
68
- $ this ->documentManager
69
- ->expects ($ this ->once ())
70
- ->method ('getRepository ' )
71
- ->with ($ this ->className )
72
- ->willReturn ($ this ->repository )
73
- ;
74
-
75
68
$ this ->instance = new AuthCodeManager ($ this ->documentManager , $ this ->className );
76
69
77
70
parent ::setUp ();
@@ -95,6 +88,13 @@ public function testFindAuthCodeBy()
95
88
\random_bytes (10 ),
96
89
];
97
90
91
+ $ this ->documentManager
92
+ ->expects ($ this ->once ())
93
+ ->method ('getRepository ' )
94
+ ->with ($ this ->className )
95
+ ->willReturn ($ this ->repository )
96
+ ;
97
+
98
98
$ this ->repository
99
99
->expects ($ this ->once ())
100
100
->method ('findOneBy ' )
@@ -155,6 +155,13 @@ public function testDeleteAuthCode()
155
155
156
156
public function testDeleteExpired ()
157
157
{
158
+ $ this ->documentManager
159
+ ->expects ($ this ->once ())
160
+ ->method ('getRepository ' )
161
+ ->with ($ this ->className )
162
+ ->willReturn ($ this ->repository )
163
+ ;
164
+
158
165
$ queryBuilder = $ this ->getMockBuilder (Builder::class)
159
166
->disableOriginalConstructor ()
160
167
->getMock ()
You can’t perform that action at this time.
0 commit comments