2008-08-12 04:59:27 +02:00
|
|
|
<?php
|
2009-03-22 23:58:18 +01:00
|
|
|
/**
|
|
|
|
* @package cms
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2008-08-12 04:59:27 +02:00
|
|
|
class CMSMainTest extends SapphireTest {
|
|
|
|
static $fixture_file = 'cms/tests/CMSMainTest.yml';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Test the results of a publication better
|
|
|
|
*/
|
|
|
|
function testPublish() {
|
|
|
|
$session = new Session(array(
|
|
|
|
'loggedInAs' => $this->idFromFixture('Member', 'admin')
|
|
|
|
));
|
|
|
|
|
2008-08-13 09:54:34 +02:00
|
|
|
$response = Director::test("admin/cms/publishall", array('confirm' => 1), $session);
|
2008-11-01 14:42:19 +01:00
|
|
|
$this->assertContains(
|
|
|
|
sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), 5),
|
|
|
|
$response->getBody()
|
|
|
|
);
|
2008-08-12 04:59:27 +02:00
|
|
|
|
2008-08-13 09:54:34 +02:00
|
|
|
$response = Director::test("admin/cms/publishitems", array('csvIDs' => '1,2', 'ajax' => 1), $session);
|
2008-08-12 04:59:27 +02:00
|
|
|
$this->assertContains('setNodeTitle(1, \'Page 1\');', $response->getBody());
|
|
|
|
$this->assertContains('setNodeTitle(2, \'Page 2\');', $response->getBody());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//$this->assertRegexp('/Done: Published 4 pages/', $response->getBody())
|
|
|
|
|
|
|
|
/*
|
|
|
|
$response = Director::test("admin/publishitems", array(
|
|
|
|
'ID' => ''
|
|
|
|
'Title' => ''
|
|
|
|
'action_publish' => 'Save and publish',
|
|
|
|
), $session);
|
|
|
|
$this->assertRegexp('/Done: Published 4 pages/', $response->getBody())
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2008-10-08 05:38:32 +02:00
|
|
|
/**
|
|
|
|
* 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();
|
2008-11-23 23:58:18 +01:00
|
|
|
$this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree\" WHERE \"ID\" = $page->ID")->value());
|
2008-10-08 05:38:32 +02:00
|
|
|
|
|
|
|
$page->doPublish();
|
2008-11-23 23:58:18 +01:00
|
|
|
$this->assertEquals("Test $class page", DB::query("SELECT \"Title\" FROM \"SiteTree_Live\" WHERE \"ID\" = $page->ID")->value());
|
2008-10-08 05:38:32 +02:00
|
|
|
|
|
|
|
// 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();
|
2009-04-22 06:23:56 +02:00
|
|
|
if($page instanceof TestOnly) continue;
|
2008-10-08 05:38:32 +02:00
|
|
|
|
|
|
|
$page->Title = "Test $class page";
|
|
|
|
$page->write();
|
|
|
|
$page->flushCache();
|
|
|
|
$page = DataObject::get_by_id("SiteTree", $page->ID);
|
|
|
|
|
|
|
|
$this->assertTrue($page->getCMSFields(null) instanceof FieldSet);
|
|
|
|
}
|
|
|
|
}
|
2008-08-12 04:59:27 +02:00
|
|
|
}
|