FIX Use merge or set instead of update for config calls

This commit is contained in:
Robbie Averill 2017-07-17 17:19:00 +12:00
parent 732bdd2734
commit c3cda42b92
6 changed files with 41 additions and 41 deletions

View File

@ -169,7 +169,7 @@ class CMSMainTest extends FunctionalTest
*/
public function testThatGetCMSFieldsWorksOnEveryPageType()
{
$classes = ClassInfo::subclassesFor("SilverStripe\\CMS\\Model\\SiteTree");
$classes = ClassInfo::subclassesFor(SiteTree::class);
array_shift($classes);
foreach ($classes as $class) {
@ -184,7 +184,7 @@ class CMSMainTest extends FunctionalTest
$page->Title = "Test $class page";
$page->write();
$page->flushCache();
$page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $page->ID);
$page = DataObject::get_by_id(SiteTree::class, $page->ID);
$this->assertTrue($page->getCMSFields() instanceof FieldList);
}
@ -194,7 +194,7 @@ class CMSMainTest extends FunctionalTest
{
$this->logInWithPermission('ADMIN');
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', true);
$parentPage = $this->objFromFixture(Page::class, 'page3');
$childPage = $this->objFromFixture(Page::class, 'page1');
@ -207,7 +207,7 @@ class CMSMainTest extends FunctionalTest
$actions,
'Can publish a page with an unpublished parent with strict hierarchy off'
);
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', false);
}
/**
@ -228,7 +228,7 @@ class CMSMainTest extends FunctionalTest
$livePage = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, array(
'"SiteTree"."ID"' => $pageID
));
$this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $livePage);
$this->assertInstanceOf(SiteTree::class, $livePage);
$this->assertTrue($livePage->canDelete());
// Check that the 'restore' button exists as a simple way of checking that the correct page is returned.

View File

@ -35,7 +35,7 @@ class ContentControllerTest extends FunctionalTest
public function testNestedPages()
{
RootURLController::reset();
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$this->assertEquals('Home Page', $this->get('/')->getBody());
$this->assertEquals('Home Page', $this->get('/home/index/')->getBody());
@ -50,7 +50,7 @@ class ContentControllerTest extends FunctionalTest
$this->assertEquals('Third Level Page', $this->get('/home/second-level/third-level/second-index/')->getBody());
RootURLController::reset();
SiteTree::config()->nested_urls = false;
Config::modify()->set(SiteTree::class, 'nested_urls', false);
$this->assertEquals('Home Page', $this->get('/')->getBody());
$this->assertEquals('Home Page', $this->get('/home/')->getBody());
@ -72,7 +72,7 @@ class ContentControllerTest extends FunctionalTest
{
$controller = new ContentController();
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$this->assertEquals(1, $controller->ChildrenOf('/')->Count());
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
@ -89,7 +89,7 @@ class ContentControllerTest extends FunctionalTest
public function testDeepNestedURLs()
{
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$page = new Page();
$page->URLSegment = 'base-page';

View File

@ -29,7 +29,7 @@ class ModelAsControllerTest extends FunctionalTest
public function setUp()
{
parent::setUp();
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
}
@ -303,7 +303,7 @@ class ModelAsControllerTest extends FunctionalTest
public function testChildOfDraft()
{
RootURLController::reset();
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$draft = new Page();
$draft->Title = 'Root Leve Draft Page';

View File

@ -17,9 +17,9 @@ class RootURLControllerTest extends SapphireTest
{
$default = $this->objFromFixture('Page', 'home');
SiteTree::config()->nested_urls = false;
Config::modify()->set(SiteTree::class, 'nested_urls', false);
$this->assertEquals('home', RootURLController::get_homepage_link());
Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$this->assertEquals('home', RootURLController::get_homepage_link());
}
}

View File

@ -353,7 +353,7 @@ class SiteTreeTest extends SapphireTest
$this->assertEquals($staff->ID, SiteTree::get_by_link($staff->Link(), false)->ID);
$this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID);
Config::inst()->update(SiteTree::class, 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID);
$this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID);
@ -373,7 +373,7 @@ class SiteTreeTest extends SapphireTest
$about = $this->objFromFixture('Page', 'about');
$staff = $this->objFromFixture('Page', 'staff');
Config::inst()->update(SiteTree::class, 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters');
$this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters');
@ -394,7 +394,7 @@ class SiteTreeTest extends SapphireTest
$parent = $this->objFromFixture('Page', 'about');
$child = $this->objFromFixture('Page', 'staff');
Config::inst()->update(SiteTree::class, 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$parent->URLSegment = 'changed-on-live';
@ -442,7 +442,7 @@ class SiteTreeTest extends SapphireTest
public function testDeleteFromStageOperatesRecursively()
{
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', false);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', false);
$pageAbout = $this->objFromFixture('Page', 'about');
$pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
@ -452,7 +452,7 @@ class SiteTreeTest extends SapphireTest
$this->assertNull(DataObject::get_by_id('Page', $pageAbout->ID));
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', true);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', true);
}
public function testDeleteFromStageOperatesRecursivelyStrict()
@ -479,7 +479,7 @@ class SiteTreeTest extends SapphireTest
public function testDeleteFromLiveOperatesRecursively()
{
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', false);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about');
@ -499,12 +499,12 @@ class SiteTreeTest extends SapphireTest
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::set_stage(Versioned::DRAFT);
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', true);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', true);
}
public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn()
{
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', false);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about');
@ -522,7 +522,7 @@ class SiteTreeTest extends SapphireTest
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::set_stage(Versioned::DRAFT);
Config::inst()->update(SiteTree::class, 'enforce_strict_hierarchy', true);
Config::modify()->set(SiteTree::class, 'enforce_strict_hierarchy', true);
}
public function testDeleteFromLiveOperatesRecursivelyStrict()
@ -909,7 +909,7 @@ class SiteTreeTest extends SapphireTest
$sitetree->URLSegment = 'home';
$this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value');
Config::inst()->update(SiteTree::class, 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$sitetree->ParentID = 0;
$sitetree->URLSegment = 'home';
@ -940,7 +940,7 @@ class SiteTreeTest extends SapphireTest
*/
public function testValidURLSegmentControllerConflicts()
{
Config::inst()->update(SiteTree::class, 'nested_urls', true);
Config::modify()->set(SiteTree::class, 'nested_urls', true);
$sitetree = new SiteTree();
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
@ -1023,7 +1023,7 @@ class SiteTreeTest extends SapphireTest
$this->assertContains('Page', $classes, 'Page types do contain subclasses');
// Testing what happens in an incorrect config value is set - hide_ancestor should be a string
Config::inst()->update(SiteTreeTest_ClassA::class, 'hide_ancestor', true);
Config::modify()->set(SiteTreeTest_ClassA::class, 'hide_ancestor', true);
$newClasses = SiteTree::page_type_classes();
$this->assertEquals(
$classes,
@ -1220,7 +1220,7 @@ class SiteTreeTest extends SapphireTest
);
// test proper escaping of quotes in attribute value
Config::inst()->update(SiteTree::class, 'meta_generator', 'Generator with "quotes" in it');
Config::modify()->set(SiteTree::class, 'meta_generator', 'Generator with "quotes" in it');
$meta = $page->MetaTags();
$this->assertEquals(
1,
@ -1229,7 +1229,7 @@ class SiteTreeTest extends SapphireTest
);
// test empty generator - no tag should appear at all
Config::inst()->update(SiteTree::class, 'meta_generator', '');
Config::modify()->set(SiteTree::class, 'meta_generator', '');
$meta = $page->MetaTags();
$this->assertEquals(
0,
@ -1238,7 +1238,7 @@ class SiteTreeTest extends SapphireTest
);
// reset original value
Config::inst()->update(SiteTree::class, 'meta_generator', $generator);
Config::modify()->set(SiteTree::class, 'meta_generator', $generator);
}

View File

@ -47,8 +47,8 @@ class VirtualPageTest extends FunctionalTest
$this->logInWithPermission("ADMIN");
// Add extra fields
Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'initially_copied_fields', array('MyInitiallyCopiedField'));
Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField'));
Config::modify()->merge(VirtualPage::class, 'initially_copied_fields', array('MyInitiallyCopiedField'));
Config::modify()->merge(VirtualPage::class, 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField'));
}
/**
@ -63,8 +63,8 @@ class VirtualPageTest extends FunctionalTest
$master->Content = "<p>New content</p>";
$master->write();
$vp1 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1');
$vp2 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2');
$vp1 = $this->objFromFixture(VirtualPage::class, 'vp1');
$vp2 = $this->objFromFixture(VirtualPage::class, 'vp2');
$this->assertEquals("New title", $vp1->Title);
$this->assertEquals("New title", $vp2->Title);
@ -90,16 +90,16 @@ class VirtualPageTest extends FunctionalTest
$master->Content = "<p>New content</p>";
$master->write();
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp2'));
$this->assertTrue($vp1->publishRecursive());
$this->assertTrue($vp2->publishRecursive());
$master->publishRecursive();
Versioned::set_stage(Versioned::LIVE);
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'));
$vp1 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp1'));
$vp2 = DataObject::get_by_id(VirtualPage::class, $this->idFromFixture(VirtualPage::class, 'vp2'));
$this->assertNotNull($vp1);
$this->assertNotNull($vp2);
@ -242,7 +242,7 @@ class VirtualPageTest extends FunctionalTest
public function testCanEdit()
{
$parentPage = $this->objFromFixture('Page', 'master3');
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3');
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp3');
$bob = $this->objFromFixture('SilverStripe\\Security\\Member', 'bob');
$andrew = $this->objFromFixture('SilverStripe\\Security\\Member', 'andrew');
@ -261,7 +261,7 @@ class VirtualPageTest extends FunctionalTest
{
$parentPage = $this->objFromFixture('Page', 'master3');
$parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3');
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp3');
$virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
$cindy = $this->objFromFixture('SilverStripe\\Security\\Member', 'cindy');
$alice = $this->objFromFixture('SilverStripe\\Security\\Member', 'alice');
@ -487,7 +487,7 @@ class VirtualPageTest extends FunctionalTest
$virtual->CopyContentFromID = $page->ID;
$virtual->write();
$virtual = DataObject::get_by_id('SilverStripe\\CMS\\Model\\VirtualPage', $virtual->ID, false);
$virtual = DataObject::get_by_id(VirtualPage::class, $virtual->ID, false);
$virtual->CopyContentFromID = $notRootPage->ID;
$virtual->flushCache();
@ -632,7 +632,7 @@ class VirtualPageTest extends FunctionalTest
public function testMethod()
{
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp4');
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp4');
$controller = ModelAsController::controller_for($virtualPage);
$this->assertInstanceOf('VirtualPageTest_ClassAController', $controller);
@ -644,7 +644,7 @@ class VirtualPageTest extends FunctionalTest
public function testAllowedActions()
{
$virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp4');
$virtualPage = $this->objFromFixture(VirtualPage::class, 'vp4');
$controller = ModelAsController::controller_for($virtualPage);
$this->assertContains('testaction', $controller->allowedActions());
}