1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 00:17:31 +02:00

Tests: purge settings cache

Some tests need to change settings, but since MemoryCacheSettingsRepository caches settings in-memory, those changes aren't reflected. The new `purgeSettingsCache` removes it from the container, eliminating that cache.

For UserTest, we also need to regenerate the display name driver, since that's set statically on boot, before we'll get a change to clear the settings cache.
This commit is contained in:
Alexander Skvortsov
2021-01-07 14:10:53 -05:00
parent fd79a14cac
commit 6771b3e3b7
4 changed files with 60 additions and 0 deletions

View File

@@ -15,11 +15,13 @@ use Flarum\Http\SlugDriverInterface;
use Flarum\Http\SlugManager;
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
use Flarum\Tests\integration\TestCase;
use Flarum\Tests\integration\UsesSettings;
use Flarum\User\User;
class ModelUrlTest extends TestCase
{
use RetrievesAuthorizedUsers;
use UsesSettings;
/**
* @inheritDoc
@@ -44,6 +46,8 @@ class ModelUrlTest extends TestCase
*/
public function uses_default_driver_by_default()
{
$this->purgeSettingsCache();
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
$testUser = User::find(1);
@@ -59,6 +63,8 @@ class ModelUrlTest extends TestCase
{
$this->extend((new Extend\ModelUrl(User::class))->addSlugDriver('testDriver', TestSlugDriver::class));
$this->purgeSettingsCache();
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
$testUser = User::find(1);