Skip to content
Permalink
Browse files

Adding test cases to FixtureTask.

Removing useless param.
  • Loading branch information...
markstory committed May 5, 2009
1 parent e21cc3d commit f4dc4bc1ede057ce55dec929f8e1f7f464f08225
Showing with 59 additions and 2 deletions.
  1. +1 −1 cake/console/libs/tasks/fixture.php
  2. +58 −1 cake/tests/cases/console/libs/tasks/fixture.test.php
@@ -110,7 +110,7 @@ function all() {
*
* @access private
*/
function __interactive($modelName = false) {
function __interactive() {
$this->interactive = true;
$this->hr();
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path));
@@ -50,6 +50,11 @@
'FixtureTask', 'MockFixtureTask',
array('in', 'out', 'err', 'createFile', '_stop')
);
Mock::generatePartial(
'Shell', 'MockFixtureModelTask',
array('in', 'out', 'err', 'createFile', '_stop', 'getName', 'getTable', 'listAll')
);
/**
* FixtureTaskTest class
*
@@ -71,7 +76,8 @@ class FixtureTaskTest extends CakeTestCase {
*/
function startTest() {
$this->Dispatcher =& new TestFixtureTaskMockShellDispatcher();
$this->Task =& new MockFixtureTask($this->Dispatcher);
$this->Task =& new MockFixtureTask();
$this->Task->Model =& new MockFixtureModelTask();
$this->Task->Dispatch = new $this->Dispatcher;
}
/**
@@ -116,6 +122,57 @@ function testImportOptions() {
$expected = array();
$this->assertEqual($result, $expected);
}
/**
* test that execute passes runs bake depending with named model.
*
* @return void
**/
function testExecuteWithNamedModel() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('article');
$filename = '/my/path/article_fixture.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
/**
* test that execute runs all() when args[0] = all
*
* @return void
**/
function testExecuteIntoAll() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->Model->setReturnValue('listAll', array('articles', 'comments'));
$filename = '/my/path/article_fixture.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
$filename = '/my/path/comment_fixture.php';
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class CommentFixture/')));
$this->Task->execute();
}
/**
* test interactive mode of execute
*
* @return void
**/
function testExecuteInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->setReturnValue('in', 'y');
$this->Task->Model->setReturnValue('getName', 'Article');
$this->Task->Model->setReturnValue('getTable', 'articles', array('Article'));
$filename = '/my/path/article_fixture.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticleFixture/')));
$this->Task->execute();
}
/**
* Test that bake works
*

0 comments on commit f4dc4bc

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