Skip to content

Instantly share code, notes, and snippets.

@bcremer
Last active February 4, 2020 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcremer/b89092da07a6aea7417b013bfe2f0d8e to your computer and use it in GitHub Desktop.
Save bcremer/b89092da07a6aea7417b013bfe2f0d8e to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
namespace AppTest;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use function assert;
use function strpos;
/**
* @coversNothing
*/
final class ContainerTest extends TestCase
{
public function testContainer() : void
{
$container = require __DIR__ . '/../config/container.php';
assert($container instanceof ContainerInterface);
foreach ($container->get('config')['dependencies']['factories'] as $id => $factory) {
if (strpos($id, 'App\\') !== 0) { // only instanciate services in application namespace, no third party libs
continue;
}
$instance = $container->get($id);
self::assertInstanceOf($id, $instance);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment