From 10b2fdc3181310ec3ca75361852deca57ccbbe4c Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Thu, 23 Jul 2015 18:24:13 +0100 Subject: [PATCH 1/3] FIX: ContentController::getViewer() not returning all found templates (fixes #1244) --- code/controllers/ContentController.php | 18 +++++++++--------- tests/controller/ContentControllerTest.php | 8 ++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/code/controllers/ContentController.php b/code/controllers/ContentController.php index c4e2c1f2..11e22cd7 100755 --- a/code/controllers/ContentController.php +++ b/code/controllers/ContentController.php @@ -402,15 +402,15 @@ HTML; if($action == "index") $action = ""; else $action = '_' . $action; - // Find templates by dataRecord - $templates = SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"); - - // Next, we need to add templates for all controllers - $templates += SSViewer::get_templates_by_class(get_class($this), $action, "Controller"); - - // Fail-over to the same for the "index" action - $templates += SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"); - $templates += SSViewer::get_templates_by_class(get_class($this), "", "Controller"); + $templates = array_merge( + // Find templates by dataRecord + SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"), + // Next, we need to add templates for all controllers + SSViewer::get_templates_by_class(get_class($this), $action, "Controller"), + // Fail-over to the same for the "index" action + SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"), + SSViewer::get_templates_by_class(get_class($this), "", "Controller") + ); return new SSViewer($templates); } diff --git a/tests/controller/ContentControllerTest.php b/tests/controller/ContentControllerTest.php index 8351c145..a39b34f6 100755 --- a/tests/controller/ContentControllerTest.php +++ b/tests/controller/ContentControllerTest.php @@ -168,6 +168,14 @@ class ContentControllerTest extends FunctionalTest { // to say the default Page.ss template $response = $self->get($page->RelativeLink("testwithouttemplate")); $self->assertEquals("Page", $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()); }); } From 6050cc5403a99b27aa31aee7bb313943f3afd706 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Mon, 20 Jul 2015 15:52:46 +0100 Subject: [PATCH 2/3] Move to new travis containerised infrastructure --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 15dbc899..c84de5b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,11 @@ -language: php +language: php + +sudo: false + +addons: + apt: + packages: + - tidy php: - 5.4 @@ -32,9 +39,6 @@ matrix: env: DB=MYSQL - php: hhvm-nightly env: DB=MYSQL - before_install: - - sudo apt-get update -qq - - sudo apt-get install -y tidy before_script: - composer self-update || true From af4150312cd895c31405be6dbd7bf700097f2c95 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Fri, 24 Jul 2015 11:37:35 +0100 Subject: [PATCH 3/3] Update .travis.yml to match framework --- .travis.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c84de5b5..cbe0f141 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,13 @@ env: matrix: allow_failures: - - php: hhvm-nightly + - php: hhvm + - php: 7.0 + - php: nightly + include: + - php: 5.4 + env: DB=MYSQL PDO=1 - php: 5.5 env: DB=MYSQL - php: 5.6 @@ -37,7 +42,11 @@ matrix: env: DB=MYSQL BEHAT_TEST=1 - php: 5.3 env: DB=MYSQL - - php: hhvm-nightly + - php: 7.0 + env: DB=MYSQL + - php: nightly + env: DB=MYSQL + - php: hhvm env: DB=MYSQL before_script: