Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phphd/cache-test-bundle
Clearing Symfony cache pools between test runs
https://github.com/phphd/cache-test-bundle
cache clear pool symfony test
Last synced: about 1 month ago
JSON representation
Clearing Symfony cache pools between test runs
- Host: GitHub
- URL: https://github.com/phphd/cache-test-bundle
- Owner: phphd
- License: mit
- Created: 2023-11-02T18:52:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-30T15:57:45.000Z (11 months ago)
- Last Synced: 2024-10-01T14:48:54.120Z (about 2 months ago)
- Topics: cache, clear, pool, symfony, test
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PhdCacheTestBundle
==================🧰 Provides Symfony Cache clearing extension for PHPUnit.
[![Codecov](https://codecov.io/gh/phphd/cache-test-bundle/graph/badge.svg?token=4M4X4DFHG6)](https://codecov.io/gh/phphd/cache-test-bundle)
[![Licence](https://img.shields.io/github/license/phphd/cache-test-bundle.svg)](https://github.com/phphd/cache-test-bundle/blob/main/LICENSE)
[![Build Status](https://github.com/phphd/cache-test-bundle/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/phphd/cache-test-bundle/actions?query=branch%3Amain)## Installation ⚒️
1. Install via composer
```sh
composer require --dev phphd/cache-test-bundle
```2. Enable the bundle in the `bundles.php`
```php
PhPhD\CacheTestBundle\PhdCacheTestBundle::class => ['test' => true],
```3. Add PHPUnit extension
```xml
```## 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:
```php
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`.