Skip to content

Commit

Permalink
provired differing
Browse files Browse the repository at this point in the history
  • Loading branch information
dubpub committed May 3, 2015
1 parent 9aeb234 commit 366145c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/LaravelCommode/Common/GhostService/GhostService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ private function prepareService()

/**
* Register service proviers in laravel app
* differing from already used ones
*/
$this->services($services);
$this->services(array_diff($services, array_keys($this->app->getLoadedProviders())));

/**
* Mark current service as registered
Expand Down Expand Up @@ -223,6 +224,7 @@ private function services(array $services = [])
{
foreach($services as $service)
{

$this->app->forceRegister($service, []);
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/GhostService/GhostServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function testRegistrationEmpty()
$appMock = $this->buildAppMockForUseTest();
$appMock->shouldReceive('bound')->once()->andReturn(false);

$appMock->shouldReceive('getLoadedProviders')->zeroOrMoreTimes()->andReturn([]);
$appMock->shouldReceive('forceRegister')->once();

/**
Expand All @@ -105,6 +106,7 @@ public function testRegistration()
$appMock = $this->buildAppMockForUseTest();

$appMock->shouldReceive('bound')->once()->andReturn(true);
$appMock->shouldReceive('getLoadedProviders')->zeroOrMoreTimes()->andReturn([]);

/**
* @var \PHPUnit_Framework_MockObject_MockObject|GhostService $service
Expand All @@ -128,6 +130,7 @@ public function testUsesAllNew()
$resolver = new Resolver($resolverAppMock);

$appMock = $this->buildAppMock();
$appMock->shouldReceive('getLoadedProviders')->zeroOrMoreTimes()->andReturn([]);

$appMock->shouldReceive('bound')->zeroOrMoreTimes()->andReturn(false, true);

Expand Down Expand Up @@ -186,6 +189,8 @@ public function testUses()

$appMock = $this->buildAppMock();

$appMock->shouldReceive('getLoadedProviders')->zeroOrMoreTimes()->andReturn([]);

$appMock->shouldReceive('bound')->zeroOrMoreTimes()->andReturn(true, true);

$appMock->shouldReceive('forceRegister')->twice()->andReturnUsing(function($service) use ($additionals)
Expand Down

0 comments on commit 366145c

Please sign in to comment.