Permalink
Browse files

Pointing test directory creation to TMP/tests/

Adding tests for ProjectTask::bake()
  • Loading branch information...
markstory committed Jun 17, 2009
1 parent bf7fcdf commit 8c2a027842167509f2683d723c4d9e3d05a4b3c6
@@ -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 @@ function bake($path, $skel = null, $skip = array('empty')) {
$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 @@ function bake($path, $skel = null, $skip = array('empty')) {
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);
@@ -69,7 +69,7 @@ function startTest() {
$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 @@ function startTest() {
**/
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 @@ function testBakeFoldersAndFiles() {
$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 @@ function testBakeFoldersAndFiles() {
$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,15 +145,15 @@ function testExecuteWithOneArg() {
$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');
$file = $path . DS . 'bake_test_plugin_app_model.php';
$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 @@ function testExecuteWithTwoArgs() {
$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;
@@ -1,5 +1,4 @@
<?php
-/* SVN FILE: $Id$ */
/**
* ProjectTask Test file
*
@@ -34,7 +33,7 @@
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 @@ function startTest() {
$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 @@ function endTest() {
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();
+ }
}
?>

0 comments on commit 8c2a027

Please sign in to comment.