mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Add some more tests
This commit is contained in:
parent
4c9945d0fa
commit
8393f9ac99
@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Set up TestModelAdmin
|
// Set up TestModelAdmin
|
||||||
|
/*
|
||||||
Director::addRules(100, array(
|
Director::addRules(100, array(
|
||||||
'admin/test' => 'TestModelAdmin',
|
'admin/test' => 'TestModelAdmin',
|
||||||
));
|
));
|
||||||
LeftAndMain::add_menu_item('test', 'Test ModelAdmin', 'admin/test', 'TestModelAdmin');
|
CMSMenu::add_menu_item('test', 'Test ModelAdmin', 'admin/test', 'TestModelAdmin');
|
||||||
|
*/
|
||||||
|
|
||||||
|
Object::add_extension('Member', 'FrameworkTestRole');
|
@ -107,7 +107,9 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
new FileField('File2','FileField'),
|
new FileField('File2','FileField'),
|
||||||
new FileIFrameField('File3','FileIFrameField'),
|
new FileIFrameField('File3','FileIFrameField'),
|
||||||
));
|
));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ class TestPage extends Page {
|
|||||||
* Parent class of all test page controllers
|
* Parent class of all test page controllers
|
||||||
*/
|
*/
|
||||||
class TestPage_Controller extends Page_Controller {
|
class TestPage_Controller extends Page_Controller {
|
||||||
|
static $allowed_actions = array(
|
||||||
|
'makelotsofpages',
|
||||||
|
'Form',
|
||||||
|
'save',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
||||||
*/
|
*/
|
||||||
@ -47,5 +53,26 @@ class TestPage_Controller extends Page_Controller {
|
|||||||
$this->dataRecord->write();
|
$this->dataRecord->write();
|
||||||
Director::redirectBack();
|
Director::redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a bunch of pages
|
||||||
|
*/
|
||||||
|
function makelotsofpages() {
|
||||||
|
echo "<h1>Making pages</h1>";
|
||||||
|
$this->makePages(5,5);
|
||||||
|
}
|
||||||
|
|
||||||
|
function makePages($count, $depth, $prefix = "", $parentID = 0) {
|
||||||
|
for($i=1;$i<=$count;$i++) {
|
||||||
|
$page = new Page();
|
||||||
|
$page->ParentID = $parentID;
|
||||||
|
$page->Title = "Test page $prefix$i";
|
||||||
|
$page->write();
|
||||||
|
$page->doPublish();
|
||||||
|
|
||||||
|
echo "<li>Created '$page->Title'";
|
||||||
|
if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
18
code/model/FrameworkTestRole.php
Normal file
18
code/model/FrameworkTestRole.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class FrameworkTestRole extends DataObjectDecorator {
|
||||||
|
function extraStatics() {
|
||||||
|
return array(
|
||||||
|
'has_one' => array(
|
||||||
|
'FavouritePage' => 'SiteTree',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCMSFields($fields) {
|
||||||
|
$fields->push(new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user