Skip to content
Permalink
Browse files

Migrating CakeSchemaTest to PHPUnit

  • Loading branch information...
lorenzo committed Jun 7, 2010
1 parent e381be7 commit bd7ce3804e6c83b61dab28721852b048ab528e13
Showing with 10 additions and 16 deletions.
  1. +8 −14 cake/libs/model/cake_schema.php
  2. +2 −2 cake/tests/cases/libs/model/cake_schema.test.php
@@ -176,7 +176,7 @@ public function &load($options = array()) {
}
if (class_exists($class)) {
$Schema =& new $class($options);
$Schema = new $class($options);
return $Schema;
}
$false = false;
@@ -204,7 +204,7 @@ public function read($options = array()) {
),
$options
));
$db =& ConnectionManager::getDataSource($connection);
$db = ConnectionManager::getDataSource($connection);
App::import('Model', 'AppModel');
if (isset($this->plugin)) {
@@ -232,11 +232,7 @@ public function read($options = array()) {
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));
}
$Object = ClassRegistry::init(array('class' => $model, 'ds' => null));
if (is_object($Object) && $Object->useTable !== false) {
$Object->setDataSource($connection);
@@ -359,11 +355,9 @@ public function write($object, $options = array()) {
}
$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 @@ function generateTable($table, $fields) {
*/
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 @@ public function __values($values) {
* @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) {
@@ -730,15 +730,15 @@ function testSchemaComparison() {
),
'posts' => array(
'add' => array(
'summary' => array('type' => 'text', 'null' => 1),
'summary' => array('type' => 'text', 'null' => true),
),
'drop' => array(
'tableParameters' => array(),
),
'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)
)
),
);

0 comments on commit bd7ce38

Please sign in to comment.
You can’t perform that action at this time.