Skip to content

Commit

Permalink
Add return statement to Illuminate::resetManager() (#250)
Browse files Browse the repository at this point in the history
Update related tests to check that behavior
  • Loading branch information
adridev authored and patrickbrouwers committed Feb 27, 2018
1 parent 4fadb0d commit 113bf8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/IlluminateRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ public function resetManager($name = null)

unset($this->managersMap[$name]);
unset($this->connectionsMap[$name]);

return $this->getManager($name);
}

/**
Expand Down
16 changes: 14 additions & 2 deletions tests/IlluminateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,14 @@ public function test_can_reset_default_manager()
$this->registry->addManager('default');

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

$this->registry->resetManager();
$manager = $this->registry->resetManager();

$this->assertInstanceOf(\Doctrine\Common\Persistence\ObjectManager::class, $manager);
$this->assertSame($manager, $this->registry->getManager());
}

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

$this->container->shouldReceive('forgetInstance', 'doctrine.managers.custom');
$this->container->shouldReceive('make')
->with('doctrine.managers.custom')
->andReturn(m::mock(\Doctrine\Common\Persistence\ObjectManager::class));

$manager = $this->registry->resetManager('custom');

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

public function test_cannot_reset_non_existing_managers()
Expand Down

0 comments on commit 113bf8e

Please sign in to comment.