From 8393f9ac99b301a0b2e7975b49706c55135aaf30 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 13 Nov 2008 21:32:37 +0000 Subject: [PATCH] Add some more tests --- _config.php | 6 +++++- code/BasicFieldsTestPage.php | 2 ++ code/TestPage.php | 27 +++++++++++++++++++++++++++ code/model/FrameworkTestRole.php | 18 ++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 code/model/FrameworkTestRole.php diff --git a/_config.php b/_config.php index cdd601c..ca4add3 100644 --- a/_config.php +++ b/_config.php @@ -1,7 +1,11 @@ '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'); \ No newline at end of file diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 4414bbd..76678e4 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -107,7 +107,9 @@ class BasicFieldsTestPage extends TestPage { new FileField('File2','FileField'), new FileIFrameField('File3','FileIFrameField'), )); + return $fields; + } } diff --git a/code/TestPage.php b/code/TestPage.php index c2dce3c..0ce1465 100644 --- a/code/TestPage.php +++ b/code/TestPage.php @@ -31,6 +31,12 @@ class TestPage extends Page { * Parent class of all test page controllers */ 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 */ @@ -47,5 +53,26 @@ class TestPage_Controller extends Page_Controller { $this->dataRecord->write(); Director::redirectBack(); } + + /** + * Create a bunch of pages + */ + function makelotsofpages() { + echo "

Making pages

"; + $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 "
  • Created '$page->Title'"; + if($depth > 1) $this->makePages($count, $depth-1, $prefix."$i.", $page->ID); + } + } } ?> \ No newline at end of file diff --git a/code/model/FrameworkTestRole.php b/code/model/FrameworkTestRole.php new file mode 100644 index 0000000..fba586e --- /dev/null +++ b/code/model/FrameworkTestRole.php @@ -0,0 +1,18 @@ + array( + 'FavouritePage' => 'SiteTree', + ), + ); + } + + function updateCMSFields($fields) { + $fields->push(new TreeDropdownField("FavouritePageID", "Favourite page", "SiteTree")); + } + +} + +?> \ No newline at end of file