当前位置: 首页>>代码示例>>PHP>>正文


PHP SiteTree::create方法代码示例

本文整理汇总了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());
 }
开发者ID:helpfulrobot,项目名称:stojg-dachshund,代码行数:8,代码来源:StaticCachingTest.php

示例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();
 }
开发者ID:nyeholt,项目名称:silverstripe-misdirection,代码行数:56,代码来源:MisdirectionFunctionalTests.php


注:本文中的SiteTree::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。