🧰 Provides Symfony Cache clearing extension for PHPUnit.
Install via composer
composer require --dev phphd/cache-test-bundle
Enable the bundle in the
bundles.phpPhPhD\CacheTestBundle\PhdCacheTestBundle::class => ['test' => true],
Add PHPUnit extension
<extensions> <extensionclass="PhPhD\CacheTest\Hook\ClearCachePoolsExtension"/> </extensions>
It is possible to use this bundle to clear cache pools for any tests that extend
Symfony\Bundle\FrameworkBundle\Test\KernelTestCase (WebTestCase, ApiTestCase, etc.)
Use #[ClearPool] attribute in order to clear caches:
usePhPhD\CacheTest\ClearPool;
useSymfony\Bundle\FrameworkBundle\Test\WebTestCase;
#[ClearPool('my_cache_pool')]
finalclass BlogControllerTest extends WebTestCase
{
publicfunctiontestIndex(): void
{
$client = static::createClient();
$client->request('GET', '/en/blog/');
self::assertResponseIsSuccessful();
}
}In the example above, my_cache_pool will be cleared before every test from BlogControllerTest.