Migrating CakeSchemaTest to PHPUnit

This commit is contained in:
José Lorenzo Rodríguez 2010-06-07 00:05:40 -04:30
parent e381be7a85
commit bd7ce3804e
2 changed files with 10 additions and 16 deletions

View file

@ -176,7 +176,7 @@ class CakeSchema extends Object {
}
if (class_exists($class)) {
$Schema =& new $class($options);
$Schema = new $class($options);
return $Schema;
}
$false = false;
@ -204,7 +204,7 @@ class CakeSchema extends Object {
),
$options
));
$db =& ConnectionManager::getDataSource($connection);
$db = ConnectionManager::getDataSource($connection);
App::import('Model', 'AppModel');
if (isset($this->plugin)) {
@ -232,11 +232,7 @@ class CakeSchema extends Object {
if (isset($this->plugin)) {
$model = $this->plugin . '.' . $model;
}
if (PHP5) {
$Object = ClassRegistry::init(array('class' => $model, 'ds' => null));
} else {
$Object =& ClassRegistry::init(array('class' => $model, 'ds' => null));
}
if (is_object($Object) && $Object->useTable !== false) {
$Object->setDataSource($connection);
@ -359,11 +355,9 @@ class CakeSchema extends Object {
}
$out .= "}\n";
$File =& new File($path . DS . $file, true);
$header = '$Id';
$content = "<?php \n/* SVN FILE: {$header}$ */\n/* {$name} schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
$content = $File->prepare($content);
if ($File->write($content)) {
$file = new SplFileObject($path . DS . $file, 'w+');
$content = "<?php \n/* {$name} schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
if ($file->fwrite($content)) {
return $content;
}
return false;
@ -424,7 +418,7 @@ class CakeSchema extends Object {
*/
public function compare($old, $new = null) {
if (empty($new)) {
$new =& $this;
$new = $this;
}
if (is_array($new)) {
if (isset($new['tables'])) {
@ -529,7 +523,7 @@ class CakeSchema extends Object {
* @return array Formatted columns
*/
public function __columns(&$Obj) {
$db =& ConnectionManager::getDataSource($Obj->useDbConfig);
$db = ConnectionManager::getDataSource($Obj->useDbConfig);
$fields = $Obj->schema(true);
$columns = $props = array();
foreach ($fields as $name => $value) {

View file

@ -730,7 +730,7 @@ class CakeSchemaTest extends CakeTestCase {
),
'posts' => array(
'add' => array(
'summary' => array('type' => 'text', 'null' => 1),
'summary' => array('type' => 'text', 'null' => true),
),
'drop' => array(
'tableParameters' => array(),
@ -738,7 +738,7 @@ class CakeSchemaTest extends CakeTestCase {
'change' => array(
'author_id' => array('type' => 'integer', 'null' => true, 'default' => ''),
'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'),
'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => '1')
'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1)
)
),
);