Permalink
Browse files

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

…estAction issue that would always include layout
  • Loading branch information...
1 parent e8678b3 commit a1467822fbb50d4b524e2a98560ff74783f8af70 @mariano mariano committed with lorenzo Nov 10, 2010
Showing with 9 additions and 5 deletions.
  1. +4 −4 cake/tests/cases/libs/cake_test_case.test.php
  2. +5 −1 cake/tests/lib/cake_test_case.php
@@ -184,7 +184,7 @@ function testAssertTagsQuotes() {
'/a'
);
$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));
}
-}
+}
@@ -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;
}
}
-}
+}

0 comments on commit a146782

Please sign in to comment.