Skip to content

Commit

Permalink
Add AggregrateServiecProvider testcase to ensure that
Browse files Browse the repository at this point in the history
aggregating service provider should work with testbench. Closes #91.

Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jun 7, 2015
1 parent 468db68 commit 6df04e3
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/Integrations/AggregateServiceProviderTest.php
@@ -0,0 +1,72 @@
<?php namespace Orchestra\Testbench\Integrations\TestCase;

use Orchestra\Testbench\TestCase;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\AggregateServiceProvider;

class AggregateServiceProviderTest extends TestCase
{
/**
* Get package providers.
*
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
{
return [
'Orchestra\Testbench\Integrations\TestCase\ParentService',
];
}

/**
* Test able to load aggregate service providers.
*
* @test
*/
public function testServiceIsAvailable()
{
$this->assertTrue($this->app->bound('parent.loaded'));
$this->assertTrue($this->app->bound('child.loaded'));
$this->assertTrue($this->app->bound('child.deferred.loaded'));

$this->assertTrue($this->app->make('parent.loaded'));
$this->assertTrue($this->app->make('child.loaded'));
$this->assertTrue($this->app->make('child.deferred.loaded'));
}
}


class ParentService extends AggregateServiceProvider
{
protected $providers = [
'Orchestra\Testbench\Integrations\TestCase\ChildService',
'Orchestra\Testbench\Integrations\TestCase\DeferredChildService',
];

public function register()
{
parent::register();

$this->app['parent.loaded'] = true;
}
}

class ChildService extends ServiceProvider
{
public function register()
{
$this->app['child.loaded'] = true;
}
}

class DeferredChildService extends ServiceProvider
{
protected $defer = true;

public function register()
{
$this->app['child.deferred.loaded'] = true;
}
}

0 comments on commit 6df04e3

Please sign in to comment.