Skip to content

Commit 113bf8e

Browse files
adridevpatrickbrouwers
authored andcommitted
Add return statement to Illuminate::resetManager() (#250)
Update related tests to check that behavior
1 parent 4fadb0d commit 113bf8e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/IlluminateRegistry.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ public function resetManager($name = null)
280280

281281
unset($this->managersMap[$name]);
282282
unset($this->connectionsMap[$name]);
283+
284+
return $this->getManager($name);
283285
}
284286

285287
/**

tests/IlluminateRegistryTest.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,14 @@ public function test_can_reset_default_manager()
277277
$this->registry->addManager('default');
278278

279279
$this->container->shouldReceive('forgetInstance', 'doctrine.managers.default');
280+
$this->container->shouldReceive('make')
281+
->with('doctrine.managers.default')
282+
->andReturn(m::mock(\Doctrine\Common\Persistence\ObjectManager::class));
280283

281-
$this->registry->resetManager();
284+
$manager = $this->registry->resetManager();
285+
286+
$this->assertInstanceOf(\Doctrine\Common\Persistence\ObjectManager::class, $manager);
287+
$this->assertSame($manager, $this->registry->getManager());
282288
}
283289

284290
public function test_can_reset_custom_manager()
@@ -287,8 +293,14 @@ public function test_can_reset_custom_manager()
287293
$this->registry->addManager('custom');
288294

289295
$this->container->shouldReceive('forgetInstance', 'doctrine.managers.custom');
296+
$this->container->shouldReceive('make')
297+
->with('doctrine.managers.custom')
298+
->andReturn(m::mock(\Doctrine\Common\Persistence\ObjectManager::class));
299+
300+
$manager = $this->registry->resetManager('custom');
290301

291-
$this->registry->resetManager('custom');
302+
$this->assertInstanceOf(\Doctrine\Common\Persistence\ObjectManager::class, $manager);
303+
$this->assertSame($manager, $this->registry->getManager('custom'));
292304
}
293305

294306
public function test_cannot_reset_non_existing_managers()

0 commit comments

Comments
 (0)