Pointing test directory creation to TMP/tests/

Adding tests for ProjectTask::bake()
This commit is contained in:
mark_story 2009-06-16 23:05:48 -04:00
parent bf7fcdfd37
commit 8c2a027842
3 changed files with 41 additions and 21 deletions

View file

@ -1,27 +1,22 @@
<?php
/* SVN FILE: $Id$ */
/**
* The Project Task handles creating the base application
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.scripts.bake
* @subpackage cake.cake.console.bake
* @since CakePHP(tm) v 1.2
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
@ -142,7 +137,7 @@ class ProjectTask extends Shell {
$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');
if (low($looksGood) == 'y') {
if (strtolower($looksGood) == 'y') {
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
$Folder = new Folder($skel);
@ -155,14 +150,14 @@ class ProjectTask extends Shell {
return false;
}
if (low($verbose) == 'y') {
if (strtolower($verbose) == 'y') {
foreach ($Folder->messages() as $message) {
$this->out($message);
}
}
return true;
} elseif (low($looksGood) == 'q') {
} elseif (strtolower($looksGood) == 'q') {
$this->out('Bake Aborted.');
} else {
$this->execute(false);

View file

@ -69,7 +69,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Dispatcher->shellPaths = Configure::read('shellPaths');
$this->Task =& new MockPluginTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->path = TMP;
$this->Task->path = TMP . 'tests' . DS;
}
/**
@ -79,7 +79,7 @@ class PluginTaskTest extends CakeTestCase {
**/
function startCase() {
$this->_paths = $paths = Configure::read('pluginPaths');
$this->_testPath = array_push($paths, TMP);
$this->_testPath = array_push($paths, TMP . 'tests' . DS);
Configure::write('pluginPaths', $paths);
}
@ -112,7 +112,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->bake('BakeTestPlugin');
$path = TMP . 'bake_test_plugin';
$path = $this->Task->path . 'bake_test_plugin';
$this->assertTrue(is_dir($path), 'No plugin dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
@ -130,7 +130,7 @@ class PluginTaskTest extends CakeTestCase {
$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');
$Folder =& new Folder(TMP . 'bake_test_plugin');
$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
}
@ -145,7 +145,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->Dispatch->args = array('BakeTestPlugin');
$this->Task->args =& $this->Task->Dispatch->args;
$path = TMP . 'bake_test_plugin';
$path = $this->Task->path . 'bake_test_plugin';
$file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');
@ -153,7 +153,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');
$this->Task->execute();
$Folder =& new Folder(TMP . 'bake_test_plugin');
$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
}
@ -167,7 +167,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->setReturnValueAt(0, 'in', $this->_testPath);
$this->Task->setReturnValueAt(1, 'in', 'y');
$Folder =& new Folder(TMP . 'bake_test_plugin', true);
$Folder =& new Folder($this->Task->path . 'bake_test_plugin', true);
$this->Task->Dispatch->args = array('BakeTestPlugin', 'model');
$this->Task->args =& $this->Task->Dispatch->args;

View file

@ -1,5 +1,4 @@
<?php
/* SVN FILE: $Id$ */
/**
* ProjectTask Test file
*
@ -34,7 +33,7 @@ if (!class_exists('ShellDispatcher')) {
ob_end_clean();
}
if (!class_exists('PluginTask')) {
if (!class_exists('ProjectTask')) {
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
}
@ -66,7 +65,7 @@ class ProjectTaskTest extends CakeTestCase {
$this->Dispatcher->shellPaths = Configure::read('shellPaths');
$this->Task =& new MockProjectTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
$this->Task->path = TMP;
$this->Task->path = TMP . 'tests' . DS;
}
/**
@ -79,6 +78,32 @@ class ProjectTaskTest extends CakeTestCase {
ClassRegistry::flush();
}
/**
* test bake() method and directory creation.
*
* @return void
**/
function testBake() {
$skel = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS . 'templates' . DS . 'skel';
$this->Task->setReturnValueAt(0, 'in', 'y');
$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
$path = $this->Task->path . 'bake_test_app';
$this->assertTrue(is_dir($path), 'No project dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
$Folder =& new Folder($this->Task->path . 'bake_test_app');
$Folder->delete();
}
}
?>