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


PHP ContentController::getViewer方法代码示例

本文整理汇总了PHP中ContentController::getViewer方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentController::getViewer方法的具体用法?PHP ContentController::getViewer怎么用?PHP ContentController::getViewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentController的用法示例。


在下文中一共展示了ContentController::getViewer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetViewer

 /**
  * Tests that {@link ContentController::getViewer()} chooses the correct templates.
  *
  * @covers ContentController::getViewer()
  **/
 public function testGetViewer()
 {
     $self = $this;
     $this->useTestTheme(dirname(__FILE__), 'controllertest', function () use($self) {
         // Test a page without a controller (ContentControllerTest_PageWithoutController.ss)
         $page = new ContentControllerTestPageWithoutController();
         $page->URLSegment = "test";
         $page->write();
         $page->publish("Stage", "Live");
         $response = $self->get($page->RelativeLink());
         $self->assertEquals("ContentControllerTestPageWithoutController", trim($response->getBody()));
         // // This should fall over to user Page.ss
         $page = new ContentControllerTestPage();
         $page->URLSegment = "test";
         $page->write();
         $page->publish("Stage", "Live");
         $response = $self->get($page->RelativeLink());
         $self->assertEquals("Page", trim($response->getBody()));
         // Test that the action template is rendered.
         $page = new ContentControllerTestPage();
         $page->URLSegment = "page-without-controller";
         $page->write();
         $page->publish("Stage", "Live");
         $response = $self->get($page->RelativeLink("test"));
         $self->assertEquals("ContentControllerTestPage_test", trim($response->getBody()));
         // Test that an action without a template will default to the index template, which is
         // to say the default Page.ss template
         $response = $self->get($page->RelativeLink("testwithouttemplate"));
         $self->assertEquals("Page", trim($response->getBody()));
         // Test that an action with a template will render the both action template *and* the
         // correct parent template
         $controller = new ContentController($page);
         $viewer = $controller->getViewer('test');
         $templateList = array('ContentControllerTestPage_test', 'Page');
         $expected = SS_TemplateLoader::instance()->findTemplates($templateList, 'controllertest');
         $self->assertEquals($expected, $viewer->templates());
     });
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:43,代码来源:ContentControllerTest.php


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