mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 07:50:24 +08: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:
parent
ab43c31ff5
commit
1afbb07037
25
php-packages/testing/tests/integration/UsesSettings.php
Normal file
25
php-packages/testing/tests/integration/UsesSettings.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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\Tests\integration;
|
||||
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
|
||||
trait UsesSettings
|
||||
{
|
||||
/**
|
||||
* Removes the settings respository instance from the IoC container.
|
||||
*
|
||||
* This allows test cases that add/modify settings to refresh the in-memory settings cache.
|
||||
*/
|
||||
protected function purgeSettingsCache()
|
||||
{
|
||||
$this->app()->getContainer()->forgetInstance(SettingsRepositoryInterface::class);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user