From 7298ccb30130820efe65deb0ea927f6ddbbf5bfb Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Sun, 30 Apr 2023 09:48:46 +0100 Subject: [PATCH] feat(testing): add a trait to flush the formatter cache in tests (#3811) --- .../integration/extenders/FormatterTest.php | 8 +++---- .../integration/RefreshesFormatterCache.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 php-packages/testing/src/integration/RefreshesFormatterCache.php diff --git a/framework/core/tests/integration/extenders/FormatterTest.php b/framework/core/tests/integration/extenders/FormatterTest.php index 2dfd66554..72af5c8c1 100644 --- a/framework/core/tests/integration/extenders/FormatterTest.php +++ b/framework/core/tests/integration/extenders/FormatterTest.php @@ -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); } /** diff --git a/php-packages/testing/src/integration/RefreshesFormatterCache.php b/php-packages/testing/src/integration/RefreshesFormatterCache.php new file mode 100644 index 000000000..bb79c9911 --- /dev/null +++ b/php-packages/testing/src/integration/RefreshesFormatterCache.php @@ -0,0 +1,22 @@ +app()->getContainer()->make(Formatter::class)->flush(); + + parent::tearDown(); + } +}