Skip to content
Permalink
Browse files

Updating fixture task to use the OptionParser

Fixing failing tests caused by changing tasks to lazy loading.
  • Loading branch information...
markstory committed Oct 12, 2010
1 parent 1009069 commit 52c1c71e4ab8fc25503b12d32d650bfe15c81a52
@@ -59,6 +59,35 @@ public function __construct(&$dispatch, $stdout = null, $stderr = null, $stdin =
$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
* Handles dispatching to interactive, named, or all processess.
@@ -382,31 +411,4 @@ protected function _getRecordsFromTable($modelName, $useTable = null) {
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 @@ public function setUp() {
);
$this->Task->name = 'ControllerTask';
$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->Model = $this->getMock('ModelTask',
@@ -59,6 +59,7 @@ public function setUp() {
array(&$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->Template->initialize();
}
@@ -87,7 +87,7 @@ protected function _setupOtherMocks() {
$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->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->interactive = true;
@@ -226,7 +226,7 @@ public function testExecuteWithTwoArgs() {
$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('execute');
@@ -233,6 +233,7 @@ public function setUp() {
$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->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->Task->path = TMP;

0 comments on commit 52c1c71

Please sign in to comment.
You can’t perform that action at this time.