Skip to content

Commit 2b7acc8

Browse files
Fix tests
1 parent 1510e81 commit 2b7acc8

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

src/DoctrineManager.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class DoctrineManager
2222
/**
2323
* @param Container $container
2424
* @param EntityManagerFactory $factory
25-
* @internal param ManagerRegistry $registry
2625
*/
2726
public function __construct(Container $container, EntityManagerFactory $factory)
2827
{

tests/DoctrineManagerTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Contracts\Container\Container;
99
use LaravelDoctrine\ORM\DoctrineExtender;
1010
use LaravelDoctrine\ORM\DoctrineManager;
11+
use LaravelDoctrine\ORM\EntityManagerFactory;
1112
use LaravelDoctrine\ORM\Extensions\MappingDriverChain;
1213
use Mockery as m;
1314

@@ -33,15 +34,21 @@ class DoctrineManagerTest extends PHPUnit_Framework_TestCase
3334
*/
3435
protected $em;
3536

37+
/**
38+
* @var EntityManagerFactory
39+
*/
40+
protected $factory;
41+
3642
protected function setUp()
3743
{
3844
$this->container = m::mock(Container::class);
3945
$this->registry = m::mock(ManagerRegistry::class);
4046
$this->em = m::mock(EntityManagerInterface::class);
47+
$this->factory = m::mock(EntityManagerFactory::class)->makePartial();
4148

4249
$this->manager = new DoctrineManager(
4350
$this->container,
44-
$this->registry
51+
$this->factory
4552
);
4653
}
4754

@@ -57,6 +64,8 @@ public function test_can_extend_doctrine_on_existing_connection_with_callback()
5764
$this->manager->extend('default', function ($configuration, $connection, $eventManager) {
5865
$this->assertExtendedCorrectly($configuration, $connection, $eventManager);
5966
});
67+
68+
$this->factory->callResolveCallbacks($this->registry);
6069
}
6170

6271
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()
7483
$this->mockEmCalls();
7584

7685
$this->manager->extend('default', MyDoctrineExtender::class);
86+
87+
$this->factory->callResolveCallbacks($this->registry);
7788
}
7889

7990
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()
8697
$this->setExpectedException(InvalidArgumentException::class);
8798

8899
$this->manager->extend('default', 'no_class');
100+
101+
$this->factory->callResolveCallbacks($this->registry);
89102
}
90103

91104
public function test_cant_extend_with_an_invalid_class()
@@ -103,6 +116,8 @@ public function test_cant_extend_with_an_invalid_class()
103116
$this->setExpectedException(InvalidArgumentException::class);
104117

105118
$this->manager->extend('default', InvalidDoctrineExtender::class);
119+
120+
$this->factory->callResolveCallbacks($this->registry);
106121
}
107122

108123
public function test_can_extend_all_connections()
@@ -132,6 +147,8 @@ public function test_can_extend_all_connections()
132147
$this->manager->extendAll(function ($configuration, $connection, $eventManager) {
133148
$this->assertExtendedCorrectly($configuration, $connection, $eventManager);
134149
});
150+
151+
$this->factory->callResolveCallbacks($this->registry);
135152
}
136153

137154
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()
154171
->once()->andReturn($configuration);
155172

156173
$this->manager->addNamespace('NewNamespace', 'default');
174+
175+
$this->factory->callResolveCallbacks($this->registry);
157176
}
158177

159178
public function test_can_add_paths_to_default_connection()
@@ -176,6 +195,8 @@ public function test_can_add_paths_to_default_connection()
176195
->once()->andReturn($configuration);
177196

178197
$this->manager->addPaths(['paths'], 'default');
198+
199+
$this->factory->callResolveCallbacks($this->registry);
179200
}
180201

181202
protected function tearDown()

tests/Extensions/ExtensionManagerTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function test_boot_manager_with_one_manager_and_one_extension()
8585
// Register
8686
$this->manager->register(new ExtensionMock);
8787

88-
$this->manager->boot();
88+
$this->manager->boot($this->registry);
8989

9090
// Should be inside booted extensions now
9191
$booted = $this->manager->getBootedExtensions();
@@ -108,7 +108,7 @@ public function test_boot_manager_with_two_managers_and_one_extension()
108108
// Register
109109
$this->manager->register(new ExtensionMock);
110110

111-
$this->manager->boot();
111+
$this->manager->boot($this->registry);
112112

113113
// Should be inside booted extensions now
114114
$booted = $this->manager->getBootedExtensions();
@@ -132,7 +132,7 @@ public function test_boot_manager_with_one_manager_and_two_extensions()
132132
$this->manager->register(new ExtensionMock);
133133
$this->manager->register(new ExtensionMock2);
134134

135-
$this->manager->boot();
135+
$this->manager->boot($this->registry);
136136

137137
// Should be inside booted extensions now
138138
$booted = $this->manager->getBootedExtensions();
@@ -157,7 +157,7 @@ public function test_extension_will_only_be_booted_once()
157157
$this->manager->register(new ExtensionMock);
158158
$this->manager->register(new ExtensionMock);
159159

160-
$this->manager->boot();
160+
$this->manager->boot($this->registry);
161161

162162
// Should be inside booted extensions now
163163
$booted = $this->manager->getBootedExtensions();
@@ -189,7 +189,7 @@ public function test_filters_get_registerd_on_boot()
189189
// Register
190190
$this->manager->register(new ExtensionWithFiltersMock);
191191

192-
$this->manager->boot();
192+
$this->manager->boot($this->registry);
193193

194194
// Should be inside booted extensions now
195195
$booted = $this->manager->getBootedExtensions();
@@ -205,9 +205,7 @@ protected function tearDown()
205205

206206
protected function newManager()
207207
{
208-
return new ExtensionManager(
209-
$this->registry
210-
);
208+
return new ExtensionManager();
211209
}
212210
}
213211

0 commit comments

Comments
 (0)