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

View file

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