Adding test cases for startup()

This commit is contained in:
mark_story 2009-08-07 22:19:40 -04:00
parent 32754c4261
commit 3c46b51b7f
2 changed files with 34 additions and 4 deletions

View file

@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */
/**
* Command-line database management utility to automate programmer chores.
*
@ -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);
/**

View file

@ -52,7 +52,6 @@ Mock::generatePartial(
*/
class SchemaShellTest extends CakeTestCase {
/**
* startTest method
*
@ -75,6 +74,39 @@ class SchemaShellTest extends CakeTestCase {
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');
}
}
?>