Skip to content

Commit

Permalink
Adding test cases for run create in Schema shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 11, 2009
1 parent dd1075a commit 74448e4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/console/libs/schema.php
Expand Up @@ -122,7 +122,7 @@ function view() {
* @access public
*/
function generate() {
$this->out('Generating Schema...');
$this->out(__('Generating Schema...', true));
$options = array();
if (isset($this->params['f'])) {
$options = array('models' => false);
Expand Down Expand Up @@ -280,7 +280,7 @@ function run() {
break;
default:
$this->err(__('Command not found', true));
$this->_stop();
$this->_stop();
}
}

Expand Down
45 changes: 45 additions & 0 deletions cake/tests/cases/console/libs/schema.test.php
Expand Up @@ -234,5 +234,50 @@ function testGenerateOverwrite() {
$this->Shell->generate();
unlink(TMP . 'schema.php');
}

/**
* Test schema run create with no table args.
*
* @return void
**/
function testRunCreateNoArgs() {
$this->Shell->params = array(
'connection' => 'test_suite',
'name' => 'i18n',
'path' => APP . 'config' . DS . 'schema'
);
$this->Shell->args = array('create');
$this->Shell->startup();
$this->Shell->setReturnValue('in', 'y');
$this->Shell->run();

$db =& ConnectionManager::getDataSource('test_suite');
$sources = $db->listSources();
$this->assertTrue(in_array('i18n', $sources));
}

/**
* Test schema run create with no table args.
*
* @return void
**/
function testRunCreateWithTableArgs() {
$this->Shell->params = array(
'connection' => 'test_suite',
'name' => 'DbAcl',
'path' => APP . 'config' . DS . 'schema'
);
$this->Shell->args = array('create', 'acos');
$this->Shell->startup();
$this->Shell->setReturnValue('in', 'y');
$this->Shell->run();

$db =& ConnectionManager::getDataSource('test_suite');
$sources = $db->listSources();
$this->assertTrue(in_array('acos', $sources));
$this->assertFalse(in_array('aros', $sources));
$this->assertFalse(in_array('aros_acos', $sources));
}

}
?>

0 comments on commit 74448e4

Please sign in to comment.