8
8
use Illuminate \Contracts \Container \Container ;
9
9
use LaravelDoctrine \ORM \DoctrineExtender ;
10
10
use LaravelDoctrine \ORM \DoctrineManager ;
11
+ use LaravelDoctrine \ORM \EntityManagerFactory ;
11
12
use LaravelDoctrine \ORM \Extensions \MappingDriverChain ;
12
13
use Mockery as m ;
13
14
@@ -33,15 +34,21 @@ class DoctrineManagerTest extends PHPUnit_Framework_TestCase
33
34
*/
34
35
protected $ em ;
35
36
37
+ /**
38
+ * @var EntityManagerFactory
39
+ */
40
+ protected $ factory ;
41
+
36
42
protected function setUp ()
37
43
{
38
44
$ this ->container = m::mock (Container::class);
39
45
$ this ->registry = m::mock (ManagerRegistry::class);
40
46
$ this ->em = m::mock (EntityManagerInterface::class);
47
+ $ this ->factory = m::mock (EntityManagerFactory::class)->makePartial ();
41
48
42
49
$ this ->manager = new DoctrineManager (
43
50
$ this ->container ,
44
- $ this ->registry
51
+ $ this ->factory
45
52
);
46
53
}
47
54
@@ -57,6 +64,8 @@ public function test_can_extend_doctrine_on_existing_connection_with_callback()
57
64
$ this ->manager ->extend ('default ' , function ($ configuration , $ connection , $ eventManager ) {
58
65
$ this ->assertExtendedCorrectly ($ configuration , $ connection , $ eventManager );
59
66
});
67
+
68
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
60
69
}
61
70
62
71
public function test_can_extend_doctrine_on_existing_connection_with_class ()
@@ -74,6 +83,8 @@ public function test_can_extend_doctrine_on_existing_connection_with_class()
74
83
$ this ->mockEmCalls ();
75
84
76
85
$ this ->manager ->extend ('default ' , MyDoctrineExtender::class);
86
+
87
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
77
88
}
78
89
79
90
public function test_cant_extend_with_a_non_existing_extender_class ()
@@ -86,6 +97,8 @@ public function test_cant_extend_with_a_non_existing_extender_class()
86
97
$ this ->setExpectedException (InvalidArgumentException::class);
87
98
88
99
$ this ->manager ->extend ('default ' , 'no_class ' );
100
+
101
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
89
102
}
90
103
91
104
public function test_cant_extend_with_an_invalid_class ()
@@ -103,6 +116,8 @@ public function test_cant_extend_with_an_invalid_class()
103
116
$ this ->setExpectedException (InvalidArgumentException::class);
104
117
105
118
$ this ->manager ->extend ('default ' , InvalidDoctrineExtender::class);
119
+
120
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
106
121
}
107
122
108
123
public function test_can_extend_all_connections ()
@@ -132,6 +147,8 @@ public function test_can_extend_all_connections()
132
147
$ this ->manager ->extendAll (function ($ configuration , $ connection , $ eventManager ) {
133
148
$ this ->assertExtendedCorrectly ($ configuration , $ connection , $ eventManager );
134
149
});
150
+
151
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
135
152
}
136
153
137
154
public function test_can_add_a_new_namespace_to_default_connection ()
@@ -154,6 +171,8 @@ public function test_can_add_a_new_namespace_to_default_connection()
154
171
->once ()->andReturn ($ configuration );
155
172
156
173
$ this ->manager ->addNamespace ('NewNamespace ' , 'default ' );
174
+
175
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
157
176
}
158
177
159
178
public function test_can_add_paths_to_default_connection ()
@@ -176,6 +195,8 @@ public function test_can_add_paths_to_default_connection()
176
195
->once ()->andReturn ($ configuration );
177
196
178
197
$ this ->manager ->addPaths (['paths ' ], 'default ' );
198
+
199
+ $ this ->factory ->callResolveCallbacks ($ this ->registry );
179
200
}
180
201
181
202
protected function tearDown ()
0 commit comments