Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 1c6475a

Browse files
committed
Clear DI cache
1 parent bf52f31 commit 1c6475a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Tests/Features/Context/ResourceContext.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Behat\Symfony2Extension\Context\KernelAwareContext;
1111
use Behat\Behat\Context\Context;
1212
use Symfony\Component\HttpKernel\KernelInterface;
13+
use Symfony\Component\Filesystem\Filesystem;
14+
use Symfony\Component\Finder\Finder;
1315

1416
class ResourceContext implements Context, KernelAwareContext
1517
{
@@ -45,11 +47,7 @@ public function beforeScenario(BeforeScenarioScope $scope)
4547
unlink(self::getConfigurationFile());
4648
}
4749

48-
touch(__DIR__ . '/../../Resources/app/config/config.php');
49-
50-
$this->cacheClearer = $this->kernel->getContainer()->get('cache_clearer')->clear(
51-
$this->kernel->getCacheDir()
52-
);
50+
$this->clearDiCache();
5351

5452
$this->manager = $this->kernel->getContainer()->get('doctrine_phpcr.odm.document_manager');
5553
$this->session = $this->manager->getPhpcrSession();
@@ -99,4 +97,14 @@ public function givenThereExistsDocument($class, $path, TableNode $fields)
9997
$this->manager->persist($document);
10098
$this->manager->flush();
10199
}
100+
101+
private function clearDiCache()
102+
{
103+
$finder = new Finder();
104+
$finder->in($this->kernel->getCacheDir());
105+
$finder->name('*.php');
106+
$finder->name('*.php.meta');
107+
$filesystem = new Filesystem();
108+
$filesystem->remove($finder);
109+
}
102110
}

0 commit comments

Comments
 (0)