1. Go to this page and download the library: Download reedware/container-testcase library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reedware / container-testcase example snippets
use Reedware\ContainerTestCase\ContainerTestCase;
class TestCase extends ContainerTestCase
{
/* ... */
}
use PHPUnit\Framework\TestCase as BaseTestCase;
use Reedware\ContainerTestCase\ServiceContainer;
class TestCase extends BaseTestCase
{
use ServiceContainer;
}
protected function setUp(): void
{
parent::setUp();
$this->setUpServiceContainer();
}
protected function tearDown(): void
{
$this->tearDownServiceContainer();
parent::tearDown();
}
protected function setUp(): void
{
parent::setUp();
$this->registerServiceProvider(MyServiceProvider::class);
}
protected function setUp(): void
{
parent::setUp();
$this->bootServiceProvider(MyServiceProvider::class);
}
/** @test */
public function it_bails_on_production(): void
{
$this->app
->shouldReceive('environment')
->withNoArgs()
->once()
->andReturn('production');
$this->registerServiceProvider(MyServiceProvider::class);
$this->assertFalse($this->app->bound(MyService::class));
}