From cd6fd74caf02c3702f4b00034cea1339f28a3323 Mon Sep 17 00:00:00 2001 From: ceeram Date: Tue, 17 Nov 2009 00:04:33 +0100 Subject: [PATCH] Added -empty flag for ProjectTask to bake with empty dir files, tests included Signed-off-by: Mark Story --- cake/console/libs/tasks/project.php | 3 ++ .../cases/console/libs/tasks/project.test.php | 47 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index 70f254bc38a..03cc23d65d9 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -149,6 +149,9 @@ function bake($path, $skel = null, $skip = array('empty')) { $verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n'); $Folder = new Folder($skel); + if (!empty($this->params['empty'])) { + $skip = array(); + } if ($Folder->copy(array('to' => $path, 'skip' => $skip))) { $this->hr(); $this->out(sprintf(__("Created: %s in %s", true), $app, $path)); diff --git a/cake/tests/cases/console/libs/tasks/project.test.php b/cake/tests/cases/console/libs/tasks/project.test.php index 08f33778b49..ce91e262bbe 100644 --- a/cake/tests/cases/console/libs/tasks/project.test.php +++ b/cake/tests/cases/console/libs/tasks/project.test.php @@ -115,6 +115,51 @@ function testBake() { $this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s'); } +/** + * test bake() method with -empty flag, directory creation and empty files. + * + * @return void + * @access public + */ + function testBakeEmptyFlag() { + $this->Task->params['empty'] = true; + $this->_setupTestProject(); + $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'); + + $this->assertTrue(is_file($path . DS . 'controllers' . DS .'components' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'locale' . DS . 'eng' . DS . 'LC_MESSAGES' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'plugins' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'vendors' . DS . 'css' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'vendors' . DS . 'img' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'vendors' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'views' . DS . 'scaffolds' . DS . 'empty'), 'No empty file in dir %s'); + $this->assertTrue(is_file($path . DS . 'webroot' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s'); + } + /** * test generation of Security.salt * @@ -141,7 +186,7 @@ function testSecuritySaltGeneration() { */ function testIndexPhpGeneration() { $this->_setupTestProject(); - + $path = $this->Task->path . 'bake_test_app' . DS; $this->Task->corePath($path);