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; namespace SilverStripe\Dev;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
use SilverStripe\Control\Session; use SilverStripe\Control\Session;
use SilverStripe\Control\HTTPResponse; use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
@ -127,10 +128,10 @@ class FunctionalTest extends SapphireTest implements TestOnly
*/ */
protected function withBaseURL($url, $callback) protected function withBaseURL($url, $callback)
{ {
$oldBase = Config::inst()->get('SilverStripe\\Control\\Director', 'alternate_base_url'); $oldBase = Config::inst()->get(Director::class, 'alternate_base_url');
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', $url); Config::modify()->set(Director::class, 'alternate_base_url', $url);
$callback($this); $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) protected function withBaseFolder($folder, $callback)
{ {
$oldFolder = Config::inst()->get('SilverStripe\\Control\\Director', 'alternate_base_folder'); $oldFolder = Config::inst()->get(Director::class, 'alternate_base_folder');
Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_folder', $folder); Config::modify()->set(Director::class, 'alternate_base_folder', $folder);
$callback($this); $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: * Initialized constants:
* - BASE_URL: Full URL to the webroot, e.g. "http://my-host.com/my-webroot" (no trailing slash). * - 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). * - 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" * - TEMP_FOLDER: Absolute path to temporary folder, used for manifest and template caches. Example: "/var/tmp"
* See getTempFolder(). No trailing slash. * See getTempFolder(). No trailing slash.
* - THEMES_DIR: Path relative to webroot, e.g. "themes" * - 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 // Test that child class does not automatically inherit config
$injector = new Injector(array('locator' => SilverStripeServiceConfigurationLocator::class)); $injector = new Injector(array('locator' => SilverStripeServiceConfigurationLocator::class));
Config::inst()->update( Config::modify()->merge(
Injector::class, Injector::class,
MyParentClass::class, MyParentClass::class,
[ [
@ -727,7 +727,7 @@ class InjectorTest extends SapphireTest
'locator' => SilverStripeServiceConfigurationLocator::class 'locator' => SilverStripeServiceConfigurationLocator::class
) )
); );
Config::inst()->update( Config::modify()->merge(
Injector::class, Injector::class,
MyChildClass::class, MyChildClass::class,
'%$'.MyParentClass::class '%$'.MyParentClass::class

View File

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

View File

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

View File

@ -142,14 +142,14 @@ class PermissionTest extends SapphireTest
public function testHiddenPermissions() 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()); $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()); $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()); $this->assertContains('CMS_ACCESS_LeftAndMain', $permissionCheckboxSet->Field());
} }