cleaning up some tests, adding missing parameters in DboSource to match declaration on DataSource

This commit is contained in:
José Lorenzo Rodríguez 2010-11-09 01:25:05 -04:30
parent 9caba98780
commit 47c6132b24
6 changed files with 24 additions and 24 deletions

View file

@ -263,7 +263,7 @@ class DataSource extends Object {
* @param Model $model * @param Model $model
* @return array Array of Metadata for the $model * @return array Array of Metadata for the $model
*/ */
public function describe(&$model) { public function describe($model) {
if ($this->cacheSources === false) { if ($this->cacheSources === false) {
return null; return null;
} }
@ -556,7 +556,7 @@ class DataSource extends Object {
* @param string $key Key name to make * @param string $key Key name to make
* @return string Key name for model. * @return string Key name for model.
*/ */
public function resolveKey(&$model, $key) { public function resolveKey($model, $key) {
return $model->alias . $key; return $model->alias . $key;
} }

View file

@ -179,7 +179,7 @@ class DboMysql extends DboSource {
* *
* @return array Array of tablenames in the database * @return array Array of tablenames in the database
*/ */
function listSources() { function listSources($data = null) {
$cache = parent::listSources(); $cache = parent::listSources();
if ($cache != null) { if ($cache != null) {
return $cache; return $cache;

View file

@ -362,7 +362,7 @@ class DboSource extends DataSource {
* *
* @return integer Number of affected rows * @return integer Number of affected rows
*/ */
function lastAffected() { function lastAffected($source = null) {
if ($this->hasResult()) { if ($this->hasResult()) {
return $this->_result->rowCount(); return $this->_result->rowCount();
} }
@ -375,7 +375,7 @@ class DboSource extends DataSource {
* *
* @return integer Number of rows in resultset * @return integer Number of rows in resultset
*/ */
function lastNumRows() { function lastNumRows($source = null) {
if ($this->hasResult()) { if ($this->hasResult()) {
$i = 0; $i = 0;
foreach ($this->_result as $row) { foreach ($this->_result as $row) {

View file

@ -650,7 +650,7 @@ class DboMysqlTest extends CakeTestCase {
'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50),
) )
)); ));
$result = $this->db->alterSchema($schema2->compare($schema1)); $result = $this->Dbo->alterSchema($schema2->compare($schema1));
$this->assertEqual(2, substr_count($result, 'field_two'), 'Too many fields'); $this->assertEqual(2, substr_count($result, 'field_two'), 'Too many fields');
} }
@ -728,8 +728,8 @@ class DboMysqlTest extends CakeTestCase {
'other__field' => 'SUM(id)' 'other__field' => 'SUM(id)'
); );
$this->db->virtualFieldSeparator = '_$_'; $this->Dbo->virtualFieldSeparator = '_$_';
$result = $this->db->fields($model, null, array('data', 'other__field')); $result = $this->Dbo->fields($model, null, array('data', 'other__field'));
$expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`');
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
@ -759,10 +759,10 @@ class DboMysqlTest extends CakeTestCase {
) )
)); ));
$this->db->execute($this->db->createSchema($schema)); $this->Dbo->execute($this->Dbo->createSchema($schema));
$model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes'));
$result = $this->db->describe($model); $result = $this->Dbo->describe($model);
$this->db->execute($this->db->dropSchema($schema)); $this->Dbo->execute($this->Dbo->dropSchema($schema));
$this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci');
$this->assertEqual($result['stringy']['charset'], 'cp1250'); $this->assertEqual($result['stringy']['charset'], 'cp1250');

View file

@ -807,7 +807,7 @@ class DboPostgresTest extends CakeTestCase {
*/ */
function testUpdateAllWithNonQualifiedConditions() { function testUpdateAllWithNonQualifiedConditions() {
$this->loadFixtures('Article'); $this->loadFixtures('Article');
$Article =& new Article(); $Article = new Article();
$result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article')); $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article'));
$this->assertTrue($result); $this->assertTrue($result);
@ -823,7 +823,7 @@ class DboPostgresTest extends CakeTestCase {
* @return void * @return void
*/ */
function testAlteringTwoTables() { function testAlteringTwoTables() {
$schema1 =& new CakeSchema(array( $schema1 = new CakeSchema(array(
'name' => 'AlterTest1', 'name' => 'AlterTest1',
'connection' => 'test', 'connection' => 'test',
'altertest' => array( 'altertest' => array(
@ -835,7 +835,7 @@ class DboPostgresTest extends CakeTestCase {
'name' => array('type' => 'string', 'null' => false, 'length' => 50), 'name' => array('type' => 'string', 'null' => false, 'length' => 50),
) )
)); ));
$schema2 =& new CakeSchema(array( $schema2 = new CakeSchema(array(
'name' => 'AlterTest1', 'name' => 'AlterTest1',
'connection' => 'test', 'connection' => 'test',
'altertest' => array( 'altertest' => array(

View file

@ -992,36 +992,36 @@ class DboSourceTest extends CakeTestCase {
// EMPTY STRING // EMPTY STRING
$result = $this->testDb->value('', 'boolean'); $result = $this->testDb->value('', 'boolean');
$this->assertEqual($result, 0); $this->assertEqual($result, "'0'");
// BOOLEAN // BOOLEAN
$result = $this->testDb->value('true', 'boolean'); $result = $this->testDb->value('true', 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value('false', 'boolean'); $result = $this->testDb->value('false', 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value(true, 'boolean'); $result = $this->testDb->value(true, 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value(false, 'boolean'); $result = $this->testDb->value(false, 'boolean');
$this->assertEqual($result, 0); $this->assertEqual($result, "'0'");
$result = $this->testDb->value(1, 'boolean'); $result = $this->testDb->value(1, 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value(0, 'boolean'); $result = $this->testDb->value(0, 'boolean');
$this->assertEqual($result, 0); $this->assertEqual($result, "'0'");
$result = $this->testDb->value('abc', 'boolean'); $result = $this->testDb->value('abc', 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value(1.234, 'boolean'); $result = $this->testDb->value(1.234, 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
$result = $this->testDb->value('1.234e05', 'boolean'); $result = $this->testDb->value('1.234e05', 'boolean');
$this->assertEqual($result, 1); $this->assertEqual($result, "'1'");
// NUMBERS // NUMBERS
$result = $this->testDb->value(123, 'integer'); $result = $this->testDb->value(123, 'integer');