feat(testing): add a trait to flush the formatter cache in tests (#3811)

This commit is contained in:
Sami Mazouz 2023-04-30 09:48:46 +01:00 committed by GitHub
parent cfdd6910eb
commit 7298ccb301
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 4 deletions

View File

@ -11,16 +11,16 @@ namespace Flarum\Tests\integration\extenders;
use Flarum\Extend;
use Flarum\Formatter\Formatter;
use Flarum\Testing\integration\RefreshesFormatterCache;
use Flarum\Testing\integration\TestCase;
class FormatterTest extends TestCase
{
use RefreshesFormatterCache;
protected function getFormatter()
{
$formatter = $this->app()->getContainer()->make(Formatter::class);
$formatter->flush();
return $formatter;
return $this->app()->getContainer()->make(Formatter::class);
}
/**

View File

@ -0,0 +1,22 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Testing\integration;
use Flarum\Formatter\Formatter;
trait RefreshesFormatterCache
{
protected function tearDown(): void
{
$this->app()->getContainer()->make(Formatter::class)->flush();
parent::tearDown();
}
}