From 1034826574f39a929023b940430bfd0c37733146 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 8 Oct 2008 03:38:32 +0000 Subject: [PATCH] API CHANGE: Added initial CMS tests to the system. These will execute tests on the data model provided by a user's project code git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@63827 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/CMSMainTest.php | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/CMSMainTest.php b/tests/CMSMainTest.php index 90412e6f..f0567263 100644 --- a/tests/CMSMainTest.php +++ b/tests/CMSMainTest.php @@ -32,4 +32,51 @@ class CMSMainTest extends SapphireTest { */ } + /** + * Test publication of one of every page type + */ + function testPublishOneOfEachKindOfPage() { + return; + $classes = ClassInfo::subclassesFor("SiteTree"); + array_shift($classes); + unset($classes['GhostPage']); //Ghost Pages aren't used anymore + + foreach($classes as $class) { + $page = new $class(); + if($class instanceof TestOnly) continue; + + $page->Title = "Test $class page"; + + $page->write(); + $this->assertEquals("Test $class page", DB::query("SELECT Title FROM SiteTree WHERE ID = $page->ID")->value()); + + $page->doPublish(); + $this->assertEquals("Test $class page", DB::query("SELECT Title FROM SiteTree_Live WHERE ID = $page->ID")->value()); + + // Check that you can visit the page + Director::test($page->Link()); + } + } + + /** + * Test that getCMSFields works on each page type. + * Mostly, this is just checking that the method doesn't return an error + */ + function testThatGetCMSFieldsWorksOnEveryPageType() { + $classes = ClassInfo::subclassesFor("SiteTree"); + array_shift($classes); + unset($classes['GhostPage']); //Ghost Pages aren't used anymore + + foreach($classes as $class) { + $page = new $class(); + if($class instanceof TestOnly) continue; + + $page->Title = "Test $class page"; + $page->write(); + $page->flushCache(); + $page = DataObject::get_by_id("SiteTree", $page->ID); + + $this->assertTrue($page->getCMSFields(null) instanceof FieldSet); + } + } } \ No newline at end of file