mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
MINOR: add a test case which create a page with 100 sub-pages so as to develop features that need to based on a page with lots of children such as limit showing number of children to 20 while adding a "show all" node as the 21st node.
This commit is contained in:
parent
ca327d218e
commit
728bcfe470
47
code/BigFamilyPage.php
Normal file
47
code/BigFamilyPage.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class BigFamilyPage extends Page{
|
||||
public function requireDefaultRecords() {
|
||||
parent::requireDefaultRecords();
|
||||
|
||||
//clear all old records
|
||||
$bigFmailyPages = DB::query("SELECT \"SiteTree_Live\".\"ID\" FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ClassName\" = 'BigFamilyPage'")->column();
|
||||
if(count($bigFmailyPages)){
|
||||
$ids = "(".implode(",", $bigFmailyPages).")";
|
||||
//Delete all children from all stages
|
||||
DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ParentID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"ParentID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ParentID\" IN $ids");
|
||||
|
||||
//Delete themselves from all stages
|
||||
DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"RecordID\" IN $ids");
|
||||
DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ID\" IN $ids");
|
||||
}
|
||||
|
||||
//create new records
|
||||
$bigFamilyPages = DataObject::get('BigFamilyPage');
|
||||
foreach ($bigFamilyPages as $page) {
|
||||
foreach($page->AllChildren() as $child){
|
||||
$child->delete();
|
||||
}
|
||||
$page->delete();
|
||||
}
|
||||
|
||||
$familyPage = new BigFamilyPage();
|
||||
$familyPage->Title = "Big Family";
|
||||
$familyPage->write();
|
||||
$familyPage->doPublish();
|
||||
|
||||
foreach(singleton('Employee')->data() as $name){
|
||||
$page = new Page();
|
||||
$page->Title = $name;
|
||||
$page->MenuTitle = $name;
|
||||
$page->ParentID = $familyPage->ID;
|
||||
$page->write();
|
||||
$page->doPublish();
|
||||
}
|
||||
|
||||
DB::alteration_message("Added default 'BigFamilyPage' and its children pages","created");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user