Я выполнил шаги в документации по загрузке ядра:
http://symfony.com/doc/current/testing/doctrine.html
Мой код:
Код: Выделить всё
class PersistingResultTest extends KernelTestCase
{
protected $em;
protected function setUp()
{
$kernel = self::bootKernel();
$this->em = $kernel->getContainer()
->get('doctrine')
->getManager();
}
public function testPersistingLogFile()
{
// Just a simple schema command to test connection
$tool = new SchemaTool($this->em);
$tool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
}
protected function tearDown()
{
parent::tearDown();
$this->em->close();
$this->em = null; // avoid memory leaks
}
}
РЕДАКТИРОВАТЬ:
Очевидно, файл .env не читается должным образом. Я переместил переменную среды DATABASE_URL в файл Doctor.yml, и теперь она работает.
Подробнее здесь: https://stackoverflow.com/questions/481 ... nel-booted
Мобильная версия