/**
  * 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());
     });
 }
 /**
  * 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", $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", $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", $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", $response->getBody());
     });
 }