Skip to content

Commit

Permalink
Adding test cases for startup()
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 8, 2009
1 parent 32754c4 commit 3c46b51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 1 addition & 3 deletions cake/console/libs/schema.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */

/**
* Command-line database management utility to automate programmer chores.
*
Expand All @@ -26,7 +24,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('File');
App::import('Core', 'File', false);
App::import('Model', 'CakeSchema', false);

/**
Expand Down
34 changes: 33 additions & 1 deletion cake/tests/cases/console/libs/schema.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
*/
class SchemaShellTest extends CakeTestCase {


/**
* startTest method
*
Expand All @@ -75,6 +74,39 @@ function endTest() {
ClassRegistry::flush();
}

/**
* test startup method
*
* @return void
**/
function testStartup() {
$this->Task->startup();
$this->assertTrue(isset($this->Task->Schema));
$this->assertTrue(is_a($this->Task->Schema, 'CakeSchema'));
$this->assertEqual($this->Task->Schema->name, 'App');
$this->assertEqual($this->Task->Schema->file, 'schema.php');

unset($this->Task->Schema);
$this->Task->params = array(
'name' => 'TestSchema'
);
$this->Task->startup();
$this->assertEqual($this->Task->Schema->name, 'TestSchema');
$this->assertEqual($this->Task->Schema->file, 'test_schema.php');
$this->assertEqual($this->Task->Schema->connection, 'default');
$this->assertEqual($this->Task->Schema->path, APP . 'config' . DS . 'schema');

unset($this->Task->Schema);
$this->Task->params = array(
'file' => 'other_file.php',
'connection' => 'test_suite',
'path' => '/test/path'
);
$this->Task->startup();
$this->assertEqual($this->Task->Schema->name, 'App');
$this->assertEqual($this->Task->Schema->file, 'other_file.php');
$this->assertEqual($this->Task->Schema->connection, 'test_suite');
$this->assertEqual($this->Task->Schema->path, '/test/path');
}
}
?>

0 comments on commit 3c46b51

Please sign in to comment.