Skip to content

Commit

Permalink
Fixing wrong assertion in test for CakeTestCase::testAction. Fixing t…
Browse files Browse the repository at this point in the history
…estAction issue that would always include layout
  • Loading branch information
mariano authored and lorenzo committed Nov 11, 2010
1 parent e8678b3 commit a146782
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cake/tests/cases/libs/cake_test_case.test.php
Expand Up @@ -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'),
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -499,4 +499,4 @@ function testTestDispatcher() {

$return = $Dispatcher->dispatch('/tests_apps/index', array('autoRender' => 0, 'return' => 1, 'requested' => 1));
}
}
}
6 changes: 5 additions & 1 deletion cake/tests/lib/cake_test_case.php
Expand Up @@ -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);
}
Expand Down Expand Up @@ -828,4 +832,4 @@ function __array_permute($items, $perms = array()) {
return $permuted;
}
}
}
}

0 comments on commit a146782

Please sign in to comment.