I'm trying to disable "Soft Deleteable" filter during functional testing and I do it as follow:
First option: tried to disable at tearDown()
in my test:
protected function tearDown() {
parent::tearDown();
$entityUser = $this->em->getRepository("UserSecurityBundle:User")->find($this->user->getUser()->getId());
$filter = $this->em->getFilters()->disable('softdeleteable');
$this->em->remove($entityUser);
$this->em->flush();
$this->em->close();
}
Didn't work.
Second option: make a doctrine_test.yml and import in config_test.yml:
imports:
- { resource: config.yml }
- { resource: doctrine_test.yml }
- { resource: security_test.yml }
In this case I remove the doctrine.yml
and include in config_prod.yml
.
Didn't work.
This is how my doctrine_test.yml
section look like:
filters:
softdeleteable:
class: GedmoSoftDeleteableFilterSoftDeleteableFilter
enabled: false
Third option: disable the filter in setUp()
:
public function setUp() {
static::$kernel = static::createKernel();
static::$kernel->boot();
$this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
$fixture = new LoadFeeData();
$fixture->load($this->em);
$this->em->getFilters()->disable('softdeleteable');
$this->user = $this->createUser();
parent::setUp();
}
Didn't work.
Any advice? Solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…