FIX Use merge and set instead of update for config calls

This commit is contained in:
Robbie Averill 2017-07-17 17:59:40 +12:00
parent 6f50e080ad
commit da4e46e4de
6 changed files with 15 additions and 14 deletions

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Dev;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Control\Session;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Config\Config;
@ -127,10 +128,10 @@ class FunctionalTest extends SapphireTest implements TestOnly
*/
protected function withBaseURL($url, $callback)
{
$oldBase = Config::inst()->get('SilverStripe\\Control\\Director', 'alternate_base_url');
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', $url);
$oldBase = Config::inst()->get(Director::class, 'alternate_base_url');
Config::modify()->set(Director::class, 'alternate_base_url', $url);
$callback($this);
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', $oldBase);
Config::modify()->set(Director::class, 'alternate_base_url', $oldBase);
}
/**
@ -140,10 +141,10 @@ class FunctionalTest extends SapphireTest implements TestOnly
*/
protected function withBaseFolder($folder, $callback)
{
$oldFolder = Config::inst()->get('SilverStripe\\Control\\Director', 'alternate_base_folder');
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_folder', $folder);
$oldFolder = Config::inst()->get(Director::class, 'alternate_base_folder');
Config::modify()->set(Director::class, 'alternate_base_folder', $folder);
$callback($this);
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_folder', $oldFolder);
Config::modify()->set(Director::class, 'alternate_base_folder', $oldFolder);
}
/**

View File

@ -15,7 +15,7 @@ use SilverStripe\Core\TempFolder;
* Initialized constants:
* - BASE_URL: Full URL to the webroot, e.g. "http://my-host.com/my-webroot" (no trailing slash).
* - BASE_PATH: Absolute path to the webroot, e.g. "/var/www/my-webroot" (no trailing slash).
* See Director::baseFolder(). Can be overwritten by Config::inst()->update('Director', 'alternate_base_folder', ).
* See Director::baseFolder(). Can be overwritten by Config::modify()->set(Director::class, 'alternate_base_folder', ).
* - TEMP_FOLDER: Absolute path to temporary folder, used for manifest and template caches. Example: "/var/tmp"
* See getTempFolder(). No trailing slash.
* - THEMES_DIR: Path relative to webroot, e.g. "themes"

View File

@ -704,7 +704,7 @@ class InjectorTest extends SapphireTest
// Test that child class does not automatically inherit config
$injector = new Injector(array('locator' => SilverStripeServiceConfigurationLocator::class));
Config::inst()->update(
Config::modify()->merge(
Injector::class,
MyParentClass::class,
[
@ -727,7 +727,7 @@ class InjectorTest extends SapphireTest
'locator' => SilverStripeServiceConfigurationLocator::class
)
);
Config::inst()->update(
Config::modify()->merge(
Injector::class,
MyChildClass::class,
'%$'.MyParentClass::class

View File

@ -283,7 +283,7 @@ class CsvBulkLoaderTest extends SapphireTest
public function testLargeFileSplitIntoSmallerFiles()
{
Config::inst()->update(CsvBulkLoader::class, 'lines', 3);
Config::modify()->set(CsvBulkLoader::class, 'lines', 3);
$loader = new CsvBulkLoader(Player::class);
$path = $this->csvPath . 'LargeListOfPlayers.csv';

View File

@ -29,7 +29,7 @@ class FulltextSearchableTest extends SapphireTest
parent::tearDown();
File::remove_extension(FulltextSearchable::class);
Config::inst()->update(
Config::modify()->merge(
File::class,
'create_table_options',
array(

View File

@ -142,14 +142,14 @@ class PermissionTest extends SapphireTest
public function testHiddenPermissions()
{
$permissionCheckboxSet = new PermissionCheckboxSetField('Permissions', 'Permissions', 'SilverStripe\\Security\\Permission', 'GroupID');
$permissionCheckboxSet = new PermissionCheckboxSetField('Permissions', 'Permissions', Permission::class, 'GroupID');
$this->assertContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
Config::inst()->update('SilverStripe\\Security\\Permission', 'hidden_permissions', array('CMS_ACCESS_LeftAndMain'));
Config::modify()->merge(Permission::class, 'hidden_permissions', array('CMS_ACCESS_LeftAndMain'));
$this->assertNotContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
Config::inst()->remove('SilverStripe\\Security\\Permission', 'hidden_permissions');
Config::inst()->remove(Permission::class, 'hidden_permissions');
$this->assertContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
}