mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding test case for PluginTask::bake()
This commit is contained in:
parent
2f5711c095
commit
5eae9fcba5
2 changed files with 23 additions and 7 deletions
|
@ -123,18 +123,16 @@ class PluginTask extends Shell {
|
|||
* @return bool
|
||||
*/
|
||||
function bake($plugin) {
|
||||
|
||||
$pluginPath = Inflector::underscore($plugin);
|
||||
|
||||
$this->hr();
|
||||
$this->out("Plugin Name: $plugin");
|
||||
$this->out("Plugin Directory: {$this->path}{$pluginPath}");
|
||||
$this->out(__("Plugin Name: ", true) . $plugin);
|
||||
$this->out(__("Plugin Directory: ", true) . $this->path . $pluginPath);
|
||||
$this->hr();
|
||||
|
||||
|
||||
$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($this->path . $pluginPath);
|
||||
|
@ -144,7 +142,7 @@ class PluginTask extends Shell {
|
|||
$Folder->create($this->path . $pluginPath . DS . $directory);
|
||||
}
|
||||
|
||||
if (low($verbose) == 'y') {
|
||||
if (strtolower($verbose) == 'y') {
|
||||
foreach ($Folder->messages() as $message) {
|
||||
$this->out($message);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,8 +89,25 @@ class PluginTaskTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
**/
|
||||
function testBake() {
|
||||
function testBakeFoldersAndFiles() {
|
||||
$this->Task->setReturnValueAt(0, 'in', 'y');
|
||||
$this->Task->bake('BakeTestPlugin');
|
||||
|
||||
$path = TMP . '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');
|
||||
$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');
|
||||
|
||||
$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');
|
||||
|
||||
@rmdir(TMP . 'bake_test_plugin');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue