Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


1.3 #17

wants to merge 1 commit into from

2 participants

Mariano Iglesias Mark Story
Mariano Iglesias

This fixes an issue where CakeTestCase::testAction() would always include the layout, regardless if the setting return was set to either 'view' or 'contents'. Previous unit test was always succeeding because it did not correctly checked that the layout was not included when return was set to 'view'.

NOTE: This was originally pull request #12, but Mark correctly pointed out that the solution included a feature that was removed in 1.3, so I refactored the code to still fix the failing test case, but only do the appropriate fix in CakeTestCase

Mark Story

This is a much more reasonable change I think.

Mark Story

Looks like its been merged in, thanks for the patch :)

Thomas Ploch tPl0ch referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 10, 2010
  1. Mariano Iglesias

    Fixing wrong assertion in test for CakeTestCase::testAction. Fixing t…

    mariano authored
    …estAction issue that would always include layout
This page is out of date. Refresh to see the latest.
8 cake/tests/cases/libs/cake_test_case.test.php
@@ -184,7 +184,7 @@ function testAssertTagsQuotes() {
$this->assertTrue($this->Case->assertTags($input, $pattern), 'Single quoted attributes %s');
$input = "<a href='/test.html' class='active'>My link</a>";
$pattern = array(
'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'),
@@ -348,10 +348,10 @@ function testTestAction() {
), true);
$result = $this->Case->testAction('/tests_apps/index', array('return' => 'view'));
- $this->assertPattern('/This is the TestsAppsController index view/', $result);
+ $this->assertPattern('/^\s*This is the TestsAppsController index view\s*$/i', $result);
$result = $this->Case->testAction('/tests_apps/index', array('return' => 'contents'));
- $this->assertPattern('/This is the TestsAppsController index view/', $result);
+ $this->assertPattern('/\bThis is the TestsAppsController index view\b/i', $result);
$this->assertPattern('/<html/', $result);
$this->assertPattern('/<\/html>/', $result);
@@ -499,4 +499,4 @@ function testTestDispatcher() {
$return = $Dispatcher->dispatch('/tests_apps/index', array('autoRender' => 0, 'return' => 1, 'requested' => 1));
6 cake/tests/lib/cake_test_case.php
@@ -64,6 +64,10 @@ function testCase(&$testCase) {
function _invoke(&$controller, $params, $missingAction = false) {
$this->controller =& $controller;
+ if (array_key_exists('layout', $params)) {
+ $this->controller->layout = $params['layout'];
+ }
if (isset($this->testCase) && method_exists($this->testCase, 'startController')) {
$this->testCase->startController($this->controller, $params);
@@ -828,4 +832,4 @@ function __array_permute($items, $perms = array()) {
return $permuted;
Something went wrong with that request. Please try again.