diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_PageList_Sidebar.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_PageList_Sidebar.ss
deleted file mode 100644
index 296f8a6e05..0000000000
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_PageList_Sidebar.ss
+++ /dev/null
@@ -1 +0,0 @@
-<% include SilverStripe\\CMS\\Controllers\\CMSMain_PageList %>
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_PageList.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_RecordList.ss
similarity index 100%
rename from templates/SilverStripe/CMS/Controllers/Includes/CMSMain_PageList.ss
rename to templates/SilverStripe/CMS/Controllers/Includes/CMSMain_RecordList.ss
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_SubTree.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_SubTree.ss
index 34140b294a..adf95e06a2 100644
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_SubTree.ss
+++ b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_SubTree.ss
@@ -4,13 +4,13 @@
<% if $limited %>
<% end_if %>
<% if not $node.IsInDB %>
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_Tools.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_Tools.ss
index d3d94aebda..356780a793 100644
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_Tools.ss
+++ b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_Tools.ss
@@ -1,26 +1,13 @@
-
-
<% end_if %>
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_ViewControls.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_ViewControls.ss
index c9709e9ad8..a91c480623 100644
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_ViewControls.ss
+++ b/templates/SilverStripe/CMS/Controllers/Includes/CMSMain_ViewControls.ss
@@ -1,18 +1,18 @@
<% if not $TreeIsFiltered %>
- <%-- Change to data-pjax-target="Content-PageList" to enable in-edit listview --%>
+ <%-- Change to data-pjax-target="Content-RecordList" to enable in-edit listview --%>
<% end_if %>
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSPageAddController_Content.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSPageAddController_Content.ss
deleted file mode 100644
index b8e50ac91e..0000000000
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSPageAddController_Content.ss
+++ /dev/null
@@ -1,45 +0,0 @@
-
- <% with $AddForm %>
-
- <% end_with %>
-
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Content.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Content.ss
deleted file mode 100644
index 956e7536a4..0000000000
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Content.ss
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- $Tools
- $PageList
-
-
diff --git a/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Tools.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Tools.ss
deleted file mode 100644
index d82c105fb9..0000000000
--- a/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_Tools.ss
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/tests/php/Controllers/CMSMainTest.php b/tests/php/Controllers/CMSMainTest.php
index 205166b404..a1930af850 100644
--- a/tests/php/Controllers/CMSMainTest.php
+++ b/tests/php/Controllers/CMSMainTest.php
@@ -3,6 +3,7 @@
namespace SilverStripe\CMS\Tests\Controllers;
use Psr\SimpleCache\CacheInterface;
+use ReflectionMethod;
use SilverStripe\Admin\CMSBatchActionHandler;
use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Model\RedirectorPage;
@@ -44,15 +45,15 @@ protected function setUp(): void
}
}
- public function testSiteTreeHints()
+ public function testTreeHints()
{
- $cache = Injector::inst()->get(CacheInterface::class . '.CMSMain_SiteTreeHints');
+ $cache = Injector::inst()->get(CacheInterface::class . '.CMSMain_TreeHints');
// Login as user with root creation privileges
$user = $this->objFromFixture(Member::class, 'rootedituser');
Security::setCurrentUser($user);
$cache->clear();
- $rawHints = singleton(CMSMain::class)->SiteTreeHints();
+ $rawHints = singleton(CMSMain::class)->TreeHints();
$this->assertNotNull($rawHints);
$rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints) ?? '');
@@ -423,7 +424,7 @@ public function testBreadcrumbsSearchView()
);
$jsonStr = $response->getBody();
$data = json_decode($jsonStr, true);
-
+
$parser = new CSSContentParser($data['Breadcrumbs']);
$crumbs = $parser->getBySelector('.breadcrumbs-wrapper .crumb');
@@ -611,13 +612,15 @@ public function testChangeClass()
$this->assertEquals('Class A', $newPage->Title);
}
- public function testSiteTreeHintsCache()
+ public function testTreeHintsCache()
{
$cms = CMSMain::create();
+ $reflectionAllowedSubclasses = new ReflectionMethod($cms, 'getAllowedSubClasses');
+ $reflectionAllowedSubclasses->setAccessible(true);
/** @var Member $user */
$user = $this->objFromFixture(Member::class, 'rootedituser');
Security::setCurrentUser($user);
- $pageClass = array_values(SiteTree::page_type_classes())[0];
+ $pageClass = array_values($reflectionAllowedSubclasses->invoke($cms))[0];
$mockPageMissesCache = $this->getMockBuilder($pageClass)
->onlyMethods(['canCreate'])
->getMock();
@@ -635,31 +638,31 @@ public function testSiteTreeHintsCache()
// Initially, cache misses (1)
Injector::inst()->registerService($mockPageMissesCache, $pageClass);
- $hints = $cms->SiteTreeHints();
+ $hints = $cms->TreeHints();
$this->assertNotNull($hints);
// Now it hits
Injector::inst()->registerService($mockPageHitsCache, $pageClass);
- $hints = $cms->SiteTreeHints();
+ $hints = $cms->TreeHints();
$this->assertNotNull($hints);
// Mutating member record invalidates cache. Misses (2)
$user->FirstName = 'changed';
$user->write();
Injector::inst()->registerService($mockPageMissesCache, $pageClass);
- $hints = $cms->SiteTreeHints();
+ $hints = $cms->TreeHints();
$this->assertNotNull($hints);
// Now it hits again
Injector::inst()->registerService($mockPageHitsCache, $pageClass);
- $hints = $cms->SiteTreeHints();
+ $hints = $cms->TreeHints();
$this->assertNotNull($hints);
// Different user. Misses. (3)
$user = $this->objFromFixture(Member::class, 'allcmssectionsuser');
Security::setCurrentUser($user);
Injector::inst()->registerService($mockPageMissesCache, $pageClass);
- $hints = $cms->SiteTreeHints();
+ $hints = $cms->TreeHints();
$this->assertNotNull($hints);
}
@@ -703,21 +706,21 @@ public function testSearchField()
);
}
- public function testCanOrganiseSitetree()
+ public function testCanOrganiseTree()
{
$cms = CMSMain::create();
- $this->assertFalse($cms->CanOrganiseSitetree());
+ $this->assertFalse($cms->CanOrganiseTree());
$this->logInWithPermission('CMS_ACCESS_CMSMain');
- $this->assertFalse($cms->CanOrganiseSitetree());
+ $this->assertFalse($cms->CanOrganiseTree());
$this->logOut();
$this->logInWithPermission('SITETREE_REORGANISE');
- $this->assertTrue($cms->CanOrganiseSitetree());
+ $this->assertTrue($cms->CanOrganiseTree());
$this->logOut();
$this->logInWithPermission('ADMIN');
- $this->assertTrue($cms->CanOrganiseSitetree());
+ $this->assertTrue($cms->CanOrganiseTree());
}
}
diff --git a/tests/php/Controllers/CMSSiteTreeFilterTest.php b/tests/php/Controllers/CMSSiteTreeFilterTest.php
index bf2a925323..9eefb1ce1e 100644
--- a/tests/php/Controllers/CMSSiteTreeFilterTest.php
+++ b/tests/php/Controllers/CMSSiteTreeFilterTest.php
@@ -24,8 +24,8 @@ public function testSearchFilterEmpty()
$f = new CMSSiteTreeFilter_Search();
$results = $f->pagesIncluded();
- $this->assertTrue($f->isPageIncluded($page1));
- $this->assertTrue($f->isPageIncluded($page2));
+ $this->assertTrue($f->isRecordIncluded($page1));
+ $this->assertTrue($f->isRecordIncluded($page2));
}
public function testSearchFilterByTitle()
@@ -36,8 +36,8 @@ public function testSearchFilterByTitle()
$f = new CMSSiteTreeFilter_Search(['Title' => 'Page 1']);
$results = $f->pagesIncluded();
- $this->assertTrue($f->isPageIncluded($page1));
- $this->assertFalse($f->isPageIncluded($page2));
+ $this->assertTrue($f->isRecordIncluded($page1));
+ $this->assertFalse($f->isRecordIncluded($page2));
$this->assertEquals(1, count($results ?? []));
$this->assertEquals(
['ID' => $page1->ID, 'ParentID' => 0],
@@ -50,10 +50,10 @@ public function testUrlSegmentFilter()
$page = $this->objFromFixture(SiteTree::class, 'page8');
$filter = CMSSiteTreeFilter_Search::create(['Term' => 'lake-wanaka+adventure']);
- $this->assertTrue($filter->isPageIncluded($page));
+ $this->assertTrue($filter->isRecordIncluded($page));
$filter = CMSSiteTreeFilter_Search::create(['URLSegment' => 'lake-wanaka+adventure']);
- $this->assertTrue($filter->isPageIncluded($page));
+ $this->assertTrue($filter->isRecordIncluded($page));
}
public function testIncludesParentsForNestedMatches()
@@ -64,8 +64,8 @@ public function testIncludesParentsForNestedMatches()
$f = new CMSSiteTreeFilter_Search(['Title' => 'Page 3b']);
$results = $f->pagesIncluded();
- $this->assertTrue($f->isPageIncluded($parent));
- $this->assertTrue($f->isPageIncluded($child));
+ $this->assertTrue($f->isRecordIncluded($parent));
+ $this->assertTrue($f->isRecordIncluded($child));
$this->assertEquals(1, count($results ?? []));
$this->assertEquals(
['ID' => $child->ID, 'ParentID' => $parent->ID],
@@ -91,8 +91,8 @@ public function testChangedPagesFilter()
$f = new CMSSiteTreeFilter_ChangedPages(['Term' => 'Changed']);
$results = $f->pagesIncluded();
- $this->assertTrue($f->isPageIncluded($changedPage));
- $this->assertFalse($f->isPageIncluded($unchangedPage));
+ $this->assertTrue($f->isRecordIncluded($changedPage));
+ $this->assertFalse($f->isRecordIncluded($unchangedPage));
$this->assertEquals(1, count($results ?? []));
$this->assertEquals(
['ID' => $changedPage->ID, 'ParentID' => 0],
@@ -130,11 +130,11 @@ public function testDeletedPagesFilter()
);
$f = new CMSSiteTreeFilter_DeletedPages(['Term' => 'Page']);
- $this->assertTrue($f->isPageIncluded($deletedPage));
+ $this->assertTrue($f->isRecordIncluded($deletedPage));
// Check that only changed pages are returned
$f = new CMSSiteTreeFilter_DeletedPages(['Term' => 'No Matches']);
- $this->assertFalse($f->isPageIncluded($deletedPage));
+ $this->assertFalse($f->isRecordIncluded($deletedPage));
}
public function testStatusDraftPagesFilter()
@@ -148,16 +148,16 @@ public function testStatusDraftPagesFilter()
// Check draft page is shown
$f = new CMSSiteTreeFilter_StatusDraftPages(['Term' => 'Page']);
- $this->assertTrue($f->isPageIncluded($draftPage));
+ $this->assertTrue($f->isRecordIncluded($draftPage));
// Check filter respects parameters
$f = new CMSSiteTreeFilter_StatusDraftPages(['Term' => 'No Match']);
- $this->assertEmpty($f->isPageIncluded($draftPage));
+ $this->assertEmpty($f->isRecordIncluded($draftPage));
// Ensures empty array returned if no data to show
$f = new CMSSiteTreeFilter_StatusDraftPages();
$draftPage->delete();
- $this->assertEmpty($f->isPageIncluded($draftPage));
+ $this->assertEmpty($f->isRecordIncluded($draftPage));
}
public function testDateFromToLastSameDate()
@@ -171,7 +171,7 @@ public function testDateFromToLastSameDate()
'LastEditedTo' => $date,
]);
$this->assertTrue(
- $filter->isPageIncluded($draftPage),
+ $filter->isRecordIncluded($draftPage),
'Using the same date for from and to should show find that page'
);
}
@@ -189,16 +189,16 @@ public function testStatusRemovedFromDraftFilter()
// Check live-only page is included
$f = new CMSSiteTreeFilter_StatusRemovedFromDraftPages(['LastEditedFrom' => '2000-01-01 00:00']);
- $this->assertTrue($f->isPageIncluded($removedDraftPage));
+ $this->assertTrue($f->isRecordIncluded($removedDraftPage));
// Check filter is respected
$f = new CMSSiteTreeFilter_StatusRemovedFromDraftPages(['LastEditedTo' => '1999-01-01 00:00']);
- $this->assertEmpty($f->isPageIncluded($removedDraftPage));
+ $this->assertEmpty($f->isRecordIncluded($removedDraftPage));
// Ensures empty array returned if no data to show
$f = new CMSSiteTreeFilter_StatusRemovedFromDraftPages();
$removedDraftPage->delete();
- $this->assertEmpty($f->isPageIncluded($removedDraftPage));
+ $this->assertEmpty($f->isRecordIncluded($removedDraftPage));
}
public function testStatusDeletedFilter()
@@ -214,10 +214,10 @@ public function testStatusDeletedFilter()
// Check deleted page is included
$f = new CMSSiteTreeFilter_StatusDeletedPages(['Title' => 'Page']);
- $this->assertTrue($f->isPageIncluded($checkParentExists));
+ $this->assertTrue($f->isRecordIncluded($checkParentExists));
// Check filter is respected
$f = new CMSSiteTreeFilter_StatusDeletedPages(['Title' => 'Bobby']);
- $this->assertFalse($f->isPageIncluded($checkParentExists));
+ $this->assertFalse($f->isRecordIncluded($checkParentExists));
}
}
diff --git a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest.php b/tests/php/Controllers/LeftAndMainPageIconsExtensionTest.php
deleted file mode 100644
index 4529a826d7..0000000000
--- a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-generatePageIconsCss();
- $this->assertStringNotContainsString('some invalid string', $css);
- $this->assertStringContainsString(
- 'tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_b.jpg?m=',
- $css
- );
- $this->assertStringContainsString(
- 'tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_c.jpg?m=',
- $css
- );
- }
-}
diff --git a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconB.php b/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconB.php
deleted file mode 100644
index 147a044ea0..0000000000
--- a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconB.php
+++ /dev/null
@@ -1,11 +0,0 @@
-generateRecordIconsCss();
+ $this->assertStringNotContainsString('some invalid string', $css);
+ $this->assertStringContainsString(
+ 'tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_b.jpg?m=',
+ $css
+ );
+ $this->assertStringContainsString(
+ 'tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_c.jpg?m=',
+ $css
+ );
+ $this->assertStringNotContainsString(
+ 'tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_d.jpg?m=',
+ $css
+ );
+ }
+}
diff --git a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconA.php b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/ModuleIconA.php
similarity index 50%
rename from tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconA.php
rename to tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/ModuleIconA.php
index 3b503a34bf..5c1d907104 100644
--- a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/ModuleIconA.php
+++ b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/ModuleIconA.php
@@ -1,11 +1,11 @@
$path,
+ 'cms_icon' => $path,
];
}
}
diff --git a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_b.jpg b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_b.jpg
similarity index 100%
rename from tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_b.jpg
rename to tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_b.jpg
diff --git a/tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_c.jpg b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_c.jpg
similarity index 100%
rename from tests/php/Controllers/LeftAndMainPageIconsExtensionTest/icon_c.jpg
rename to tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_c.jpg
diff --git a/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_d.jpg b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_d.jpg
new file mode 100644
index 0000000000..beb5a91b0a
Binary files /dev/null and b/tests/php/Controllers/LeftAndMainRecordIconsExtensionTest/icon_d.jpg differ
diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php
index 29476014fb..9f3f91f1d2 100644
--- a/tests/php/Model/SiteTreeTest.php
+++ b/tests/php/Model/SiteTreeTest.php
@@ -43,6 +43,7 @@
use const RESOURCES_DIR;
use PHPUnit\Framework\Attributes\DataProvider;
+use SilverStripe\Core\ClassInfo;
class SiteTreeTest extends SapphireTest
{
@@ -1216,19 +1217,22 @@ public function testVersionsAreCreated()
public function testHidePagetypes()
{
SiteTree::config()->set('hide_pagetypes', ['Page']);
- $classes = SiteTree::page_type_classes();
+ $classes = ClassInfo::getValidSubClasses(SiteTree::class);
+ SiteTree::singleton()->updateAllowedSubClasses($classes);
$this->assertNotContains('Page', $classes);
}
public function testPageTypeClasses()
{
- $classes = SiteTree::page_type_classes();
+ $classes = ClassInfo::getValidSubClasses(SiteTree::class);
+ SiteTree::singleton()->updateAllowedSubClasses($classes);
$this->assertNotContains(SiteTree::class, $classes, 'Page types do not include base class');
$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::modify()->set(SiteTreeTest_ClassA::class, 'hide_ancestor', true);
- $newClasses = SiteTree::page_type_classes();
+ $newClasses = ClassInfo::getValidSubClasses(SiteTree::class);
+ SiteTree::singleton()->updateAllowedSubClasses($newClasses);
$this->assertEquals(
$classes,
$newClasses,
@@ -1237,7 +1241,8 @@ public function testPageTypeClasses()
// Testing what happens if a valid config value is set
Config::modify()->set(SiteTreeTest_ClassA::class, 'hide_ancestor', 'Page');
- $classes = SiteTree::page_type_classes();
+ $classes = ClassInfo::getValidSubClasses(SiteTree::class);
+ SiteTree::singleton()->updateAllowedSubClasses($classes);
$this->assertNotContains('Page', $classes);
}
@@ -1413,6 +1418,7 @@ public function testCanBeRoot()
public function testModifyStatusFlagByInheritance()
{
+ //@todo move this to CMSMain test
$node = new SiteTreeTest_StageStatusInherit();
$treeTitle = $node->getTreeTitle();
$this->assertStringContainsString('InheritedTitle', $treeTitle);
@@ -1767,7 +1773,9 @@ public function testTreeTitleCache()
$siteTree = new SiteTree();
$user = $this->objFromFixture(Member::class, 'allsections');
Security::setCurrentUser($user);
- $pageClass = array_values(SiteTree::page_type_classes())[0];
+ $classes = ClassInfo::getValidSubClasses(SiteTree::class);
+ SiteTree::singleton()->updateAllowedSubClasses($classes);
+ $pageClass = array_values($classes)[0];
$mockPageMissesCache = $this->getMockBuilder($pageClass)
->onlyMethods(['canCreate'])
diff --git a/tests/php/Model/SiteTreeTest_ClassA.php b/tests/php/Model/SiteTreeTest_ClassA.php
index 7cf2020f4d..bf878c9676 100644
--- a/tests/php/Model/SiteTreeTest_ClassA.php
+++ b/tests/php/Model/SiteTreeTest_ClassA.php
@@ -9,11 +9,6 @@ class SiteTreeTest_ClassA extends SiteTree implements TestOnly
{
private static $table_name = 'SiteTreeTest_ClassA';
- private static $need_permission = [
- 'ADMIN',
- 'CMS_ACCESS_CMSMain',
- ];
-
private static $allowed_children = [
SiteTreeTest_ClassB::class,
];