mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +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:
@@ -10,12 +10,14 @@
|
||||
namespace Flarum\Tests\integration\extenders;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Tests\integration\UsesSettings;
|
||||
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Tests\integration\TestCase;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use UsesSettings;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
@@ -40,6 +42,8 @@ class SettingsTest extends TestCase
|
||||
*/
|
||||
public function custom_setting_isnt_serialized_by_default()
|
||||
{
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
@@ -61,6 +65,8 @@ class SettingsTest extends TestCase
|
||||
->serializeToForum('customPrefix.customSetting', 'custom-prefix.custom_setting')
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
@@ -85,6 +91,8 @@ class SettingsTest extends TestCase
|
||||
})
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
@@ -107,6 +115,8 @@ class SettingsTest extends TestCase
|
||||
->serializeToForum('customPrefix.customSetting2', 'custom-prefix.custom_setting2', CustomInvokableClass::class)
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
@@ -129,6 +139,8 @@ class SettingsTest extends TestCase
|
||||
->serializeToForum('customPrefix.noCustomSetting', 'custom-prefix.no_custom_setting', null, 'customDefault')
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
@@ -153,6 +165,8 @@ class SettingsTest extends TestCase
|
||||
}, 'customDefault')
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
Reference in New Issue
Block a user