phphd/cache-test-bundle
最新稳定版本:1.0.0
Composer 安装命令:
composer require --dev phphd/cache-test-bundle
包简介
Clearing Symfony cache pools between test runs
README 文档
README
🧰 Provides Symfony Cache clearing extension for PHPUnit.
Installation ⚒️
-
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> <extension class="PhPhD\CacheTest\Hook\ClearCachePoolsExtension"/> </extensions>
Usage 🚀
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:
use PhPhD\CacheTest\ClearPool; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; #[ClearPool('my_cache_pool')] final class BlogControllerTest extends WebTestCase { public function testIndex(): 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.
统计信息
- 总下载量: 31
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-18