adding test to schema, closes #4731

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7048 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-05-27 18:44:55 +00:00
parent 78e534b73b
commit a2b873d0f8
2 changed files with 20 additions and 2 deletions

View file

@ -86,6 +86,7 @@ class CakeSchema extends Object {
if (empty($options['path'])) {
$this->path = CONFIGS . 'sql';
}
$options = array_merge(get_object_vars($this), $options);
$this->_build($options);
}
@ -199,9 +200,9 @@ class CakeSchema extends Object {
if (is_array($models)) {
foreach ($models as $model) {
if (PHP5) {
$Object = ClassRegistry::init($model);
$Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection));
} else {
$Object =& ClassRegistry::init($model);
$Object =& ClassRegistry::init(array('class' => $model, 'ds' => $connection));
}
if (is_object($Object)) {

View file

@ -244,6 +244,23 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertEqual($Other->tables, $this->Schema->tables);
}
function testSchemaCreateTable() {
$db =& ConnectionManager::getDataSource('test_suite');
$db->query('CREATE TABLE ' . $db->fullTableName('testdescribes') . ' (id int(11) AUTO_INCREMENT, int_null int(10) unsigned NULL, int_not_null int(10) unsigned NOT NULL, primary key(id));');
$Schema =& new CakeSchema(array('connection' => 'test_suite'));
$read = $Schema->read(array('models' => array('Testdescribe')));
unset($read['tables']['missing']);
$Schema->tables = $read['tables'];
$sql = $db->createSchema($Schema);
$this->assertPattern('/`int_null` int\(10\) DEFAULT NULL/', $sql);
$this->assertPattern('/`int_not_null` int\(10\) NOT NULL/', $sql);
$db->query('DROP TABLE ' . $this->db->fullTableName('testdescribes'));
}
function tearDown() {
unset($this->Schema);
}