Dont use private attributes as tables in CakeSchema. Fixes #7

This commit is contained in:
Juan Basso 2010-08-02 00:22:46 -03:00
parent 69ee014a60
commit ae2fa908c5
2 changed files with 26 additions and 0 deletions

View file

@ -116,6 +116,9 @@ class CakeSchema extends Object {
foreach ($data as $key => $val) {
if (!empty($val)) {
if (!in_array($key, array('plugin', 'name', 'path', 'file', 'connection', 'tables', '_log'))) {
if ($key[0] === '_') {
continue;
}
$this->tables[$key] = $val;
unset($this->{$key});
} elseif ($key !== 'tables') {

View file

@ -80,6 +80,14 @@ class MyAppSchema extends CakeSchema {
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
);
/**
* _foo property
*
* @var array
* @access protected
*/
protected $_foo = array('bar');
/**
* setup method
*
@ -99,6 +107,19 @@ class MyAppSchema extends CakeSchema {
*/
function teardown($version) {
}
/**
* getVar method
*
* @param string $var Name of var
* @return mixed
*/
public function getVar($var) {
if (!isset($this->$var)) {
return null;
}
return $this->$var;
}
}
/**
@ -750,6 +771,8 @@ class CakeSchemaTest extends CakeTestCase {
),
);
$this->assertEqual($expected, $compare);
$this->assertNull($New->getVar('comments'));
$this->assertEqual($New->getVar('_foo'), array('bar'));
$tables = array(
'missing' => array(