Merge pull request #975 from tractorcow/pulls/3.2-fix-controller-tests

BUG Fix ContentControllerTest
This commit is contained in:
Ingo Schommer 2014-03-25 22:38:24 +13:00
commit 8059c9d357
6 changed files with 34 additions and 28 deletions

View File

@ -133,39 +133,42 @@ class ContentControllerTest extends FunctionalTest {
**/
public function testGetViewer() {
// Test a page without a controller (ContentControllerTest_PageWithoutController.ss)
$page = new ContentControllerTestPageWithoutController();
$page->URLSegment = "test";
$page->write();
$page->publish("Stage", "Live");
$self = $this;
$this->useTestTheme(dirname(__FILE__), 'controllertest', function() use ($self) {
$response = $this->get($page->RelativeLink());
$this->assertEquals("ContentControllerTestPageWithoutController", $response->getBody());
// 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());
// // This should fall over to user Page.ss
$page = new ContentControllerTestPage();
$page->URLSegment = "test";
$page->write();
$page->publish("Stage", "Live");
// Test that the action template is rendered.
$page = new ContentControllerTestPage();
$page->URLSegment = "page-without-controller";
$page->write();
$page->publish("Stage", "Live");
$response = $this->get($page->RelativeLink());
$this->assertEquals("Foo", $response->getBody());
$response = $self->get($page->RelativeLink("test"));
$self->assertEquals("ContentControllerTestPage_test", $response->getBody());
// Test that the action template is rendered.
$page = new ContentControllerTestPage();
$page->URLSegment = "page-without-controller";
$page->write();
$page->publish("Stage", "Live");
$response = $this->get($page->RelativeLink("test"));
$this->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 = $this->get($page->RelativeLink("testwithouttemplate"));
$this->assertEquals("Foo", $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());
});
}
}

View File

@ -0,0 +1 @@
Controller

View File

@ -0,0 +1 @@
Page

View File

@ -0,0 +1 @@
$Layout