From 94d738e834d135fbe435072f2b523366bad48e76 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 20 Sep 2010 23:42:35 -0400 Subject: [PATCH] Fixing failing tests and group test situational fails in console tests. Adding console tests to all tests. --- cake/console/libs/tasks/view.php | 2 +- .../console/libs/tasks/controller.test.php | 53 ++++++++----------- .../cases/console/libs/tasks/view.test.php | 2 +- cake/tests/cases/libs/all_tests.test.php | 4 ++ 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 2e76e74fb92..e4e63449b35 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -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.')); diff --git a/cake/tests/cases/console/libs/tasks/controller.test.php b/cake/tests/cases/console/libs/tasks/controller.test.php index c0e17d149e8..ecaff46df66 100644 --- a/cake/tests/cases/console/libs/tasks/controller.test.php +++ b/cake/tests/cases/console/libs/tasks/controller.test.php @@ -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' )); @@ -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(); } @@ -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'; @@ -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/'; @@ -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/'; @@ -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/'; @@ -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/'; @@ -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'; @@ -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'; diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php index 9d538927c39..8b118e25dba 100644 --- a/cake/tests/cases/console/libs/tasks/view.test.php +++ b/cake/tests/cases/console/libs/tasks/view.test.php @@ -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); } diff --git a/cake/tests/cases/libs/all_tests.test.php b/cake/tests/cases/libs/all_tests.test.php index a0c1718ec60..bd57334e796 100644 --- a/cake/tests/cases/libs/all_tests.test.php +++ b/cake/tests/cases/libs/all_tests.test.php @@ -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');