當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。