我试图完成的是: 在执行WebTestCase之前,在PHP代码中加载新的fixture。据我所知,这段代码应该完成它的工作:
// Get a kernel instance and boot it up!
static::$kernel = static::createKernel();
static::$kernel->boot();
// Get entity manager
$em = static::$kernel->getContainer()->get('doctrine_phpcr.odm.default_document_manager');
$loader = new Loader();
foreach (self::$fixturesRequired as $fixtureClass) {
$loader->addFixture(new $fixtureClass);
}
$purger = new ORMPurger($em);
$executor = new ORMExecutor($em, $purger);
$executor->execute($loader->getFixtures());
...但它失败了:
AnnounceControllerTest::testAnnounce
Argument 1 passed to Doctrine\Common\DataFixtures\Purger\ORMPurger::__construct() must be an instance of Doctrine\ORM\EntityManagerInterface, instance of Doctrine\ODM\PHPCR\DocumentManager given, called in /opt/development/cms/.../WebTestCase.php
所以有人知道我错过了什么吗?
提前多多感谢:)
答案 0 :(得分:0)
为PHPCR清除和加载新灯具的解决方案:
// Get a kernel instance and boot it up!
static::$kernel = static::createKernel();
static::$kernel->boot();
// Get entity manager
$em = static::$kernel->getContainer()->get('doctrine_phpcr.odm.default_document_manager');
$loader = new Loader();
foreach (self::$fixturesRequired as $fixtureClass) {
$loader->addFixture(new $fixtureClass);
}
$purger = new PHPCRPurger($em);
$executor = new PHPCRExecutor($em, $purger);
$executor->execute($loader->getFixtures());
感谢您的帮助!