Skip to content

Commit

Permalink
Additional Test for ModelTask
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 30, 2009
1 parent aad2bd7 commit 8028722
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cake/console/libs/tasks/model.php
Expand Up @@ -53,6 +53,12 @@ class ModelTask extends Shell {
* @access public
*/
var $tasks = array('DbConfig', 'Fixture');
/**
* Holds tables found on connection.
*
* @var array
**/
var $__tables = array();
/**
* Execution method always used for tasks
*
Expand Down
23 changes: 20 additions & 3 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -100,7 +100,6 @@ function testListAll() {
function testGetName() {
$this->Task->setReturnValue('in', 1);

//test quit.
$this->Task->setReturnValueAt(0, 'in', 'q');
$this->Task->expectOnce('_stop');
$this->Task->getName('test_suite');
Expand All @@ -109,15 +108,33 @@ function testGetName() {
$result = $this->Task->getName('test_suite');
$expected = 'Article';
$this->assertEqual($result, $expected);

$this->Task->setReturnValueAt(2, 'in', 2);
$result = $this->Task->getName('test_suite');
$expected = 'Comment';
$this->assertEqual($result, $expected);

$this->Task->setReturnValueAt(3, 'in', 10);
$result = $this->Task->getName('test_suite');
$this->Task->expectOnce('err');
}

/**
* Test table name interactions
*
* @return void
**/
function testGetTableName() {
$this->Task->setReturnValueAt(0, 'in', 'y');
$result = $this->Task->getTable('Article', 'test_suite');
$expected = 'articles';
$this->assertEqual($result, $expected);

$this->Task->setReturnValueAt(1, 'in', 'n');
$this->Task->setReturnValueAt(2, 'in', 'my_table');
$result = $this->Task->getTable('Article', 'test_suite');
$expected = 'my_table';
$this->assertEqual($result, $expected);
}
}
?>

0 comments on commit 8028722

Please sign in to comment.