mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Use latest version of settings package
This allows us to get rid of hacks for configuring settings and config
This commit is contained in:
parent
ad92d11cf9
commit
d12d52918b
|
@ -70,7 +70,7 @@
|
|||
"wikimedia/less.php": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/testing": "^0.1.0-beta.16"
|
||||
"flarum/testing": "dev-main#81e25f034e2b6dceaea753ad7579b5c61d641993"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
|
@ -26,11 +26,10 @@ class RequireCsrfTokenTest extends TestCase
|
|||
$this->prepareDatabase([
|
||||
'api_keys' => [
|
||||
['user_id' => 1, 'key' => 'superadmin'],
|
||||
],
|
||||
'settings' => [
|
||||
['key' => 'csrf_test', 'value' => 1],
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
$this->setting('csrf_test', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,11 +25,7 @@ class CreateTest extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->prepareDatabase([
|
||||
'settings' => [
|
||||
['key' => 'mail_driver', 'value' => 'log'],
|
||||
],
|
||||
]);
|
||||
$this->setting('mail_driver', 'log');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,7 +83,7 @@ class FilesystemTest extends TestCase
|
|||
*/
|
||||
public function disk_uses_local_adapter_if_configured_adapter_from_config_file_unavailable()
|
||||
{
|
||||
$this->overrideConfigWithDiskDriver();
|
||||
$this->config('disk_driver.flarum-assets', 'null');
|
||||
|
||||
$assetsDisk = $this->app()->getContainer()->make('filesystem')->disk('flarum-assets');
|
||||
|
||||
|
@ -115,25 +115,12 @@ class FilesystemTest extends TestCase
|
|||
(new Extend\Filesystem)->driver('null', NullFilesystemDriver::class)
|
||||
);
|
||||
|
||||
$this->overrideConfigWithDiskDriver();
|
||||
$this->config('disk_driver.flarum-assets', 'null');
|
||||
|
||||
$assetsDisk = $this->app()->getContainer()->make('filesystem')->disk('flarum-assets');
|
||||
|
||||
$this->assertEquals(get_class($assetsDisk->getDriver()->getAdapter()), NullAdapter::class);
|
||||
}
|
||||
|
||||
protected function overrideConfigWithDiskDriver()
|
||||
{
|
||||
$tmp = $this->tmpDir();
|
||||
$configArr = include "$tmp/config.php";
|
||||
$configArr = array_merge($configArr, ['disk_driver' => [
|
||||
'flarum-assets' => 'null'
|
||||
]]);
|
||||
|
||||
$config = new Config($configArr);
|
||||
|
||||
$this->app()->getContainer()->instance('flarum.config', $config);
|
||||
}
|
||||
}
|
||||
|
||||
class NullFilesystemDriver implements DriverInterface
|
||||
|
|
|
@ -15,13 +15,11 @@ use Flarum\Http\SlugDriverInterface;
|
|||
use Flarum\Http\SlugManager;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\Testing\integration\UsesSettings;
|
||||
use Flarum\User\User;
|
||||
|
||||
class ModelUrlTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use UsesSettings;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
@ -31,12 +29,12 @@ class ModelUrlTest extends TestCase
|
|||
parent::setUp();
|
||||
|
||||
$userClass = User::class;
|
||||
|
||||
$this->setting("slug_driver_$userClass", 'testDriver');
|
||||
|
||||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
$this->normalUser(),
|
||||
],
|
||||
'settings' => [
|
||||
['key' => "slug_driver_$userClass", 'value' => 'testDriver'],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
@ -46,8 +44,6 @@ class ModelUrlTest extends TestCase
|
|||
*/
|
||||
public function uses_default_driver_by_default()
|
||||
{
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$slugManager = $this->app()->getContainer()->make(SlugManager::class);
|
||||
|
||||
$testUser = User::find(1);
|
||||
|
@ -63,8 +59,6 @@ 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);
|
||||
|
|
|
@ -12,12 +12,10 @@ namespace Flarum\Tests\integration\extenders;
|
|||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\Testing\integration\UsesSettings;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use UsesSettings;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
@ -29,12 +27,11 @@ class SettingsTest extends TestCase
|
|||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
$this->normalUser()
|
||||
],
|
||||
'settings' => [
|
||||
['key' => 'custom-prefix.custom_setting', 'value' => 'customValue'],
|
||||
['key' => 'custom-prefix.custom_setting2', 'value' => 'customValue']
|
||||
]
|
||||
]);
|
||||
|
||||
$this->setting('custom-prefix.custom_setting', 'customValue');
|
||||
$this->setting('custom-prefix.custom_setting2', 'customValue');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,8 +39,6 @@ class SettingsTest extends TestCase
|
|||
*/
|
||||
public function custom_setting_isnt_serialized_by_default()
|
||||
{
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
@ -65,8 +60,6 @@ class SettingsTest extends TestCase
|
|||
->serializeToForum('customPrefix.customSetting', 'custom-prefix.custom_setting')
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
@ -91,8 +84,6 @@ class SettingsTest extends TestCase
|
|||
})
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
@ -115,8 +106,6 @@ class SettingsTest extends TestCase
|
|||
->serializeToForum('customPrefix.customSetting2', 'custom-prefix.custom_setting2', CustomInvokableClass::class)
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
@ -139,8 +128,6 @@ 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,
|
||||
|
@ -165,8 +152,6 @@ class SettingsTest extends TestCase
|
|||
}, 'customDefault')
|
||||
);
|
||||
|
||||
$this->purgeSettingsCache();
|
||||
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api', [
|
||||
'authenticatedAs' => 1,
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace Flarum\Tests\integration\extenders;
|
|||
use Flarum\Extend;
|
||||
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\Testing\integration\UsesSettings;
|
||||
use Flarum\User\DisplayName\DriverInterface;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Support\Arr;
|
||||
|
@ -20,7 +19,6 @@ use Illuminate\Support\Arr;
|
|||
class UserTest extends TestCase
|
||||
{
|
||||
use RetrievesAuthorizedUsers;
|
||||
use UsesSettings;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
@ -32,22 +30,10 @@ class UserTest extends TestCase
|
|||
$this->prepareDatabase([
|
||||
'users' => [
|
||||
$this->normalUser(),
|
||||
],
|
||||
'settings' => [
|
||||
['key' => 'display_name_driver', 'value' => 'custom'],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge the settings cache and reset the new display name driver.
|
||||
*/
|
||||
protected function recalculateDisplayNameDriver()
|
||||
{
|
||||
$this->purgeSettingsCache();
|
||||
$container = $this->app()->getContainer();
|
||||
$container->forgetInstance('flarum.user.display_name.driver');
|
||||
User::setDisplayNameDriver($container->make('flarum.user.display_name.driver'));
|
||||
$this->setting('display_name_driver', 'custom');
|
||||
}
|
||||
|
||||
protected function registerTestPreference()
|
||||
|
@ -64,7 +50,6 @@ class UserTest extends TestCase
|
|||
public function username_display_name_driver_used_by_default()
|
||||
{
|
||||
$this->app();
|
||||
$this->recalculateDisplayNameDriver();
|
||||
|
||||
$user = User::find(1);
|
||||
|
||||
|
@ -82,7 +67,6 @@ class UserTest extends TestCase
|
|||
);
|
||||
|
||||
$this->app();
|
||||
$this->recalculateDisplayNameDriver();
|
||||
|
||||
$user = User::find(1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user