mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating fixture task to use the OptionParser
Fixing failing tests caused by changing tasks to lazy loading.
This commit is contained in:
parent
10090696a0
commit
52c1c71e4a
6 changed files with 34 additions and 30 deletions
|
@ -59,6 +59,35 @@ class FixtureTask extends BakeTask {
|
||||||
$this->path = $this->Dispatch->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
$this->path = $this->Dispatch->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the option parser.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getOptionParser() {
|
||||||
|
$parser = parent::getOptionParser();
|
||||||
|
return $parser->description(
|
||||||
|
__('Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.')
|
||||||
|
)->addArgument('name', array(
|
||||||
|
'help' => __('Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.')
|
||||||
|
))->addOption('count', array(
|
||||||
|
'help' => __('When using generated data, the number of records to include in the fixture(s).'),
|
||||||
|
'short' => 'n',
|
||||||
|
'default' => 10
|
||||||
|
))->addOption('connection', array(
|
||||||
|
'help' => __('Which database configuration to use for baking.'),
|
||||||
|
'short' => 'c',
|
||||||
|
'default' => 'default'
|
||||||
|
))->addOption('plugin', array(
|
||||||
|
'help' => __('CamelCased name of the plugin to bake fixtures for.'),
|
||||||
|
'short' => 'p',
|
||||||
|
))->addOption('records', array(
|
||||||
|
'help' => 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10',
|
||||||
|
'short' => 'r',
|
||||||
|
'boolean' => true
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
* Handles dispatching to interactive, named, or all processess.
|
* Handles dispatching to interactive, named, or all processess.
|
||||||
|
@ -382,31 +411,4 @@ class FixtureTask extends BakeTask {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays help contents
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function help() {
|
|
||||||
$this->hr();
|
|
||||||
$this->out("Usage: cake bake fixture <arg1> <params>");
|
|
||||||
$this->hr();
|
|
||||||
$this->out('Arguments:');
|
|
||||||
$this->out();
|
|
||||||
$this->out("<name>");
|
|
||||||
$this->out("\tName of the fixture to bake. Can use Plugin.name");
|
|
||||||
$this->out("\tas a shortcut for plugin baking.");
|
|
||||||
$this->out();
|
|
||||||
$this->out('Commands:');
|
|
||||||
$this->out("\nfixture <name>\n\tbakes fixture with specified name.");
|
|
||||||
$this->out("\nfixture all\n\tbakes all fixtures.");
|
|
||||||
$this->out();
|
|
||||||
$this->out('Parameters:');
|
|
||||||
$this->out("\t-count When using generated data, the number of records to include in the fixture(s).");
|
|
||||||
$this->out("\t-connection Which database configuration to use for baking.");
|
|
||||||
$this->out("\t-plugin CamelCased name of plugin to bake fixtures for.");
|
|
||||||
$this->out("\t-records Used with -count and <name>/all commands to pull [n] records from the live tables");
|
|
||||||
$this->out("\t Where [n] is either -count or the default of 10.");
|
|
||||||
$this->out();
|
|
||||||
$this->_stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class ControllerTaskTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->Task->name = 'ControllerTask';
|
$this->Task->name = 'ControllerTask';
|
||||||
$this->Task->Dispatch->shellPaths = App::path('shells');
|
$this->Task->Dispatch->shellPaths = App::path('shells');
|
||||||
$this->Task->Template =& new TemplateTask($this->Task->Dispatch);
|
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||||
$this->Task->Template->params['theme'] = 'default';
|
$this->Task->Template->params['theme'] = 'default';
|
||||||
|
|
||||||
$this->Task->Model = $this->getMock('ModelTask',
|
$this->Task->Model = $this->getMock('ModelTask',
|
||||||
|
|
|
@ -59,6 +59,7 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
array(&$this->Dispatcher, $out, $out, $in)
|
array(&$this->Dispatcher, $out, $out, $in)
|
||||||
);
|
);
|
||||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||||
|
$this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
$this->Task->Dispatch->shellPaths = App::path('shells');
|
$this->Task->Dispatch->shellPaths = App::path('shells');
|
||||||
$this->Task->Template->initialize();
|
$this->Task->Template->initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Task->Fixture = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
$this->Task->Fixture = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
$this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
$this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
$this->Task->Template =& new TemplateTask($this->Task->Dispatch, $out, $out, $in);
|
$this->Task->Template = new TemplateTask($this->Task->Dispatch, $out, $out, $in);
|
||||||
|
|
||||||
$this->Task->name = 'ModelTask';
|
$this->Task->name = 'ModelTask';
|
||||||
$this->Task->interactive = true;
|
$this->Task->interactive = true;
|
||||||
|
|
|
@ -226,7 +226,7 @@ class PluginTaskTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
|
|
||||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
$this->Task->expects($this->once())->method('in')->will($this->returnValue($this->_testPath));
|
||||||
|
|
||||||
$this->Task->Model->expects($this->once())->method('loadTasks');
|
$this->Task->Model->expects($this->once())->method('loadTasks');
|
||||||
$this->Task->Model->expects($this->once())->method('execute');
|
$this->Task->Model->expects($this->once())->method('execute');
|
||||||
|
|
|
@ -233,6 +233,7 @@ class ViewTaskTest extends CakeTestCase {
|
||||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||||
$this->Task->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
$this->Task->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
$this->Task->Project = $this->getMock('ProjectTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
$this->Task->Project = $this->getMock('ProjectTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
|
$this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||||
|
|
||||||
$this->Dispatcher->shellPaths = App::path('shells');
|
$this->Dispatcher->shellPaths = App::path('shells');
|
||||||
$this->Task->path = TMP;
|
$this->Task->path = TMP;
|
||||||
|
|
Loading…
Reference in a new issue