for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TheCodingMachine\Tdbm\GraphQL\Registry;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use TheCodingMachine\Tdbm\GraphQL\Fixtures\TestType;
class RegistryTest extends TestCase
{
private function getContainer(): ContainerInterface
return new class implements ContainerInterface {
public function get($id)
return 'foo';
}
public function has($id)
return $id === 'foo';
};
public function testFromContainer()
$registry = new Registry($this->getContainer());
$this->assertTrue($registry->has('foo'));
$this->assertFalse($registry->has('bar'));
$this->assertSame('foo', $registry->get('foo'));
public function testInstantiate()
$this->assertTrue($registry->has(TestType::class));
$type = $registry->get(TestType::class);
$this->assertInstanceOf(TestType::class, $type);
$this->assertSame($type, $registry->get(TestType::class));
public function testNotFound()
$this->expectException(NotFoundException::class);
$registry->get('notfound');