本文整理汇总了PHP中SiteTree::create方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteTree::create方法的具体用法?PHP SiteTree::create怎么用?PHP SiteTree::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteTree
的用法示例。
在下文中一共展示了SiteTree::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddingToQueueShouldNotifyDefaultBuilder
public function testAddingToQueueShouldNotifyDefaultBuilder()
{
$page = SiteTree::create(array('URLSegment' => 'test'));
$page->write();
$page->publish('Stage', 'Live');
$sc = StaticCaching::create()->publish($page);
$this->assertTrue($sc->getBuilder()->queueHasChanged());
}
示例2: testRequestFilter
/**
* The test to ensure the request filter is functioning correctly.
*/
public function testRequestFilter()
{
// Instantiate link mappings to use.
$mapping = LinkMapping::create(array('LinkType' => 'Simple', 'MappedLink' => 'wrong/page', 'RedirectLink' => 'pending'));
$mapping->write();
LinkMapping::create(array('LinkType' => 'Simple', 'MappedLink' => 'pending', 'RedirectLink' => 'correct/page'))->write();
// The CMS module needs to be present to test page behaviour.
if (ClassInfo::exists('SiteTree')) {
// This is required to support multiple sites.
$this->logInAs(Member::default_admin());
$parentID = ClassInfo::exists('Multisites') ? Multisites::inst()->getCurrentSiteId() : 0;
// Instantiate pages to use.
$first = SiteTree::create(array('URLSegment' => 'wrong', 'ParentID' => $parentID));
$first->writeToStage('Stage');
$first->writeToStage('Live');
$second = SiteTree::create(array('URLSegment' => 'page', 'ParentID' => $first->ID));
$second->writeToStage('Stage');
$second->writeToStage('Live');
}
// Determine whether the enforce misdirection is functioning correctly.
$response = $this->get('wrong/page');
$this->assertEquals($response->getStatusCode(), 303);
$this->assertEquals($response->getHeader('Location'), '/correct/page');
// The CMS module needs to be present to test page behaviour.
if (ClassInfo::exists('SiteTree')) {
// Update the default enforce misdirection.
Config::inst()->update('MisdirectionRequestFilter', 'enforce_misdirection', false);
// Determine whether the page is now matched.
$response = $this->get('wrong/page');
$this->assertEquals($response->getStatusCode(), 200);
$this->assertEquals($response->getHeader('Location'), null);
// Instantiate a fallback to use.
$first->Fallback = 'Nearest';
$first->writeToStage('Stage');
$first->writeToStage('Live');
// The database needs to be cleaned up to prevent further testing conflict.
$second->deleteFromStage('Live');
$second->deleteFromStage('Stage');
$mapping->delete();
// Determine whether the fallback is matched.
$response = $this->get('wrong/page');
$this->assertEquals($response->getStatusCode(), 303);
$this->assertEquals($response->getHeader('Location'), '/wrong/?misdirected=1');
}
// Instantiate a director rule to use.
Config::inst()->update('Director', 'rules', array('wrong/page' => 'Controller'));
// Determine whether the director rule is matched.
$response = $this->get('wrong/page');
$this->assertEquals($response->getStatusCode(), 200);
$this->assertEquals($response->getHeader('Location'), null);
// The database needs to be emptied to prevent further testing conflict.
self::empty_temp_db();
}