Included validation to skip AppModel on CakeSchema->readSchema because it tries to find 'app_models' table. Added testSchemaReadWithAppModel test

This commit is contained in:
Alejandro Ibarra 2011-07-15 15:18:38 -04:30
parent a025cb2e01
commit e4c1f28d84
2 changed files with 44 additions and 3 deletions

View file

@ -229,6 +229,11 @@ class CakeSchema extends Object {
foreach ($models as $model) {
$importModel = $model;
$plugin = null;
if ($model == 'AppModel') {
continue;
}
if (isset($this->plugin)) {
if ($model == $this->plugin . 'AppModel') {
continue;
@ -324,6 +329,7 @@ class CakeSchema extends Object {
ksort($tables);
return compact('name', 'tables');
}
/**

View file

@ -603,6 +603,41 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing');
}
/**
* testSchemaReadWithAppModel method
*
* @access public
* @return void
*/
public function testSchemaReadWithAppModel() {
$connections = ConnectionManager::enumConnectionObjects();
if (!empty($connections['default'])) {
$backup = $connections['default'];
ConnectionManager::drop('default');
}
ConnectionManager::create('default', $connections['test']);
try {
$read = $this->Schema->read(array(
'connection' => 'default',
'name' => 'TestApp',
'models' => array('AppModel')
));
unset($read['tables']['missing']);
$this->assertTrue(empty($read['tables']));
if (!empty($backup)) {
ConnectionManager::drop('default');
ConnectionManager::create('default', $backup);
}
} catch(MissingTableException $mte) {
if (!empty($backup)) {
ConnectionManager::drop('default');
ConnectionManager::create('default', $backup);
}
$this->fail($mte->getMessage());
}
}
/**
* testSchemaReadWithOddTablePrefix method
*