Skip to content

Commit 15b92b1

Browse files
New paths and namespaces should never be added to all connections
1 parent e55a434 commit 15b92b1

File tree

3 files changed

+5
-75
lines changed

3 files changed

+5
-75
lines changed

src/Auth/Passwords/PasswordResetServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function boot(DoctrineManager $manager)
1717
// The path to PasswordReminder should be added, so the entity can be found
1818
$manager->addPaths([
1919
__DIR__
20-
], $manager->getDefaultManagerName());
20+
]);
2121
}
2222

2323
/**

src/DoctrineManager.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ public function extendAll($callback)
8080
*/
8181
public function addNamespace($namespace, $connection = false)
8282
{
83-
$connections = $connection ? [$connection] : $this->registry->getManagerNames();
83+
$connection = $connection ?: $this->registry->getDefaultManagerName();
8484

85-
foreach ($connections as $connection) {
86-
$this->getMetaDataDriver($connection)->addNamespace($namespace);
87-
}
85+
$this->getMetaDataDriver($connection)->addNamespace($namespace);
8886
}
8987

9088
/**
@@ -93,11 +91,9 @@ public function addNamespace($namespace, $connection = false)
9391
*/
9492
public function addPaths(array $paths = [], $connection = false)
9593
{
96-
$connections = $connection ? [$connection] : $this->registry->getManagerNames();
94+
$connection = $connection ?: $this->registry->getDefaultManagerName();
9795

98-
foreach ($connections as $connection) {
99-
$this->getMetaDataDriver($connection)->addPaths($paths);
100-
}
96+
$this->getMetaDataDriver($connection)->addPaths($paths);
10197
}
10298

10399
/**

tests/DoctrineManagerTest.php

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -156,39 +156,6 @@ public function test_can_add_a_new_namespace_to_default_connection()
156156
$this->manager->addNamespace('NewNamespace', 'default');
157157
}
158158

159-
public function test_can_add_a_new_namespace_to_all_connections()
160-
{
161-
$this->registry->shouldReceive('getManagerNames')->once()->andReturn([
162-
'default',
163-
'custom'
164-
]);
165-
166-
$this->registry->shouldReceive('getManager')
167-
->once()
168-
->with('default')
169-
->andReturn($this->em);
170-
171-
$this->registry->shouldReceive('getManager')
172-
->once()
173-
->with('custom')
174-
->andReturn($this->em);
175-
176-
$configuration = m::mock(Configuration::class);
177-
178-
$mappingDriver = m::mock(MappingDriverChain::class);
179-
$mappingDriver->shouldReceive('addNamespace')
180-
->twice()->with('NewNamespace');
181-
182-
$configuration->shouldReceive('getMetadataDriverImpl')
183-
->twice()
184-
->andReturn($mappingDriver);
185-
186-
$this->em->shouldReceive('getConfiguration')
187-
->twice()->andReturn($configuration);
188-
189-
$this->manager->addNamespace('NewNamespace');
190-
}
191-
192159
public function test_can_add_paths_to_default_connection()
193160
{
194161
$this->registry->shouldReceive('getManager')
@@ -211,39 +178,6 @@ public function test_can_add_paths_to_default_connection()
211178
$this->manager->addPaths(['paths'], 'default');
212179
}
213180

214-
public function test_can_add_paths_to_all_connections()
215-
{
216-
$this->registry->shouldReceive('getManagerNames')->once()->andReturn([
217-
'default',
218-
'custom'
219-
]);
220-
221-
$this->registry->shouldReceive('getManager')
222-
->once()
223-
->with('default')
224-
->andReturn($this->em);
225-
226-
$this->registry->shouldReceive('getManager')
227-
->once()
228-
->with('custom')
229-
->andReturn($this->em);
230-
231-
$configuration = m::mock(Configuration::class);
232-
233-
$mappingDriver = m::mock(MappingDriverChain::class);
234-
$mappingDriver->shouldReceive('addPaths')
235-
->twice()->with(['paths']);
236-
237-
$configuration->shouldReceive('getMetadataDriverImpl')
238-
->twice()
239-
->andReturn($mappingDriver);
240-
241-
$this->em->shouldReceive('getConfiguration')
242-
->twice()->andReturn($configuration);
243-
244-
$this->manager->addPaths(['paths']);
245-
}
246-
247181
protected function tearDown()
248182
{
249183
m::close();

0 commit comments

Comments
 (0)