Skip to content

Commit

Permalink
feat(testing): add a trait to flush the formatter cache in tests (#3811)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Apr 30, 2023
1 parent cfdd691 commit 7298ccb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions framework/core/tests/integration/extenders/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

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);
}

/**
Expand Down
22 changes: 22 additions & 0 deletions php-packages/testing/src/integration/RefreshesFormatterCache.php
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 7298ccb

Please sign in to comment.