Create a container in service.php
$container->setDefinition('repository.access_token',
new Definition(\Ftob\OauthServerApp\Repositories\AccessTokenRepository::class))
->setFactory([new Reference('doctrine'), 'getRepository'])
->setArguments([\Ftob\OauthServerApp\Entity\AccessToken::class]);
I try to call it in the test -
class AccessTokenRepositoryTest extends KernelTestCase
{
protected $repository;
public function setUp()
{
$this->bootKernel();
$this->repository = self::$kernel->getContainer()->get('repository.access_token');
}
public function testDi()
{
$this->assertInstanceOf( AccessTokenRepository::class, $this->repository);
}
}
I receive an error (fail) -
AccessTokenRepositoryTest::testDi Failed asserting that Doctrine\ORM\EntityRepository Object (...) is an instance of class "Ftob\OauthServerApp\Repositories\AccessTokenRepository".
/var/www/tests/Repositories/AccessTokenRepositoryTest.php:23
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Why call instance Doctrine\ORM\EntityRepository, not AccessTokenRepository?
Thanks!