Skip to content

Commit

Permalink
Fixing failing tests and group test situational fails in console test…
Browse files Browse the repository at this point in the history
…s. Adding console tests to all tests.
  • Loading branch information
markstory committed Sep 25, 2010
1 parent 0bb2309 commit 94d738e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/view.php
Expand Up @@ -344,7 +344,7 @@ public function customAction() {
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
$this->bake($action);
$this->bake($action, ' ');
$this->_stop();
} else {
$this->out(__('Bake Aborted.'));
Expand Down
53 changes: 23 additions & 30 deletions cake/tests/cases/console/libs/tasks/controller.test.php
Expand Up @@ -72,11 +72,11 @@ class ControllerTaskTest extends CakeTestCase {
public $fixtures = array('core.bake_article', 'core.bake_articles_bake_tag', 'core.bake_comment', 'core.bake_tag');

/**
* startTest method
* setUp method
*
* @return void
*/
public function startTest() {
public function setUp() {
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
));
Expand All @@ -101,11 +101,11 @@ public function startTest() {
}

/**
* endTest method
* teardown method
*
* @return void
*/
public function endTest() {
public function teardown() {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
Expand Down Expand Up @@ -150,8 +150,9 @@ public function testGetNameValidIndex() {
$this->markTestSkipped('Additional tables detected.');
}
$this->Task->interactive = true;
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
$this->Task->expects($this->any())->method('in')->will(
$this->onConsecutiveCalls(3, 1)
);

$result = $this->Task->getName('test');
$expected = 'BakeComments';
Expand Down Expand Up @@ -511,10 +512,12 @@ function testInteractiveAdminMethodsNotInteractive() {
* @return void
*/
public function testExecuteIntoAll() {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute into all could not be run as an Article, Tag or Comment model was already loaded. %s');
if ($skip) {
return;
$count = count($this->Task->listAll('test'));
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute into all could not be run as an Article, Tag or Comment model was already loaded.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
Expand All @@ -538,10 +541,8 @@ public function testExecuteIntoAll() {
* @return void
*/
public function testExecuteWithController() {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
if ($skip) {
return;
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
Expand Down Expand Up @@ -574,10 +575,8 @@ static function nameVariations() {
* @return void
*/
public function testExecuteWithControllerNameVariations($name) {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
if ($skip) {
return;
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
Expand All @@ -596,10 +595,8 @@ public function testExecuteWithControllerNameVariations($name) {
* @return void
*/
public function testExecuteWithPublicParam() {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
if ($skip) {
return;
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with public param requires no Article, Tag or Comment model to be defined.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
Expand All @@ -619,10 +616,8 @@ public function testExecuteWithPublicParam() {
* @return void
*/
public function testExecuteWithControllerAndBoth() {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
if ($skip) {
return;
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with controller and both requires no Article, Tag or Comment model to be defined.');
}
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
$this->Task->connection = 'test';
Expand All @@ -642,10 +637,8 @@ public function testExecuteWithControllerAndBoth() {
* @return void
*/
public function testExecuteWithControllerAndAdmin() {
$skip = $this->skipIf(!defined('ARTICLE_MODEL_CREATED'),
'Execute with scaffold param requires no Article, Tag or Comment model to be defined. %s');
if ($skip) {
return;
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with controller and admin requires no Article, Tag or Comment model to be defined.');
}
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
$this->Task->connection = 'test';
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/cases/console/libs/tasks/view.test.php
Expand Up @@ -389,7 +389,7 @@ function testBakeWithNoTemplate() {
$this->Task->controllerName = 'ViewTaskComments';
$this->Task->controllerPath = 'view_task_comments';

$this->Task->expectNever('createFile');
$this->Task->expects($this->never())->method('createFile');
$this->Task->bake('delete', true);
}

Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/all_tests.test.php
Expand Up @@ -36,6 +36,10 @@ public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('All Tests');

$path = CORE_TEST_CASES . DS . 'libs' . DS;
$console = CORE_TEST_CASES . DS . 'console' . DS;

$suite->addTestFile($console . 'all_shells.test.php');
$suite->addTestFile($console . 'libs' . DS . 'all_bake_tasks.test.php');

$suite->addTestFile($path . 'all_behaviors.test.php');
$suite->addTestFile($path . 'all_cache_engines.test.php');
Expand Down

0 comments on commit 94d738e

Please sign in to comment.