From 47c6132b245fdb5318b9af9d81e5dbeeec8e3e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 9 Nov 2010 01:25:05 -0430 Subject: [PATCH] cleaning up some tests, adding missing parameters in DboSource to match declaration on DataSource --- cake/libs/model/datasources/datasource.php | 4 ++-- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- cake/libs/model/datasources/dbo_source.php | 4 ++-- .../model/datasources/dbo/dbo_mysql.test.php | 12 +++++------ .../datasources/dbo/dbo_postgres.test.php | 6 +++--- .../model/datasources/dbo_source.test.php | 20 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 85c0b1f59..391e1bf65 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -263,7 +263,7 @@ class DataSource extends Object { * @param Model $model * @return array Array of Metadata for the $model */ - public function describe(&$model) { + public function describe($model) { if ($this->cacheSources === false) { return null; } @@ -556,7 +556,7 @@ class DataSource extends Object { * @param string $key Key name to make * @return string Key name for model. */ - public function resolveKey(&$model, $key) { + public function resolveKey($model, $key) { return $model->alias . $key; } diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 7e8eef21b..102e4890f 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -179,7 +179,7 @@ class DboMysql extends DboSource { * * @return array Array of tablenames in the database */ - function listSources() { + function listSources($data = null) { $cache = parent::listSources(); if ($cache != null) { return $cache; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index afd42a5c0..e9f14e522 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -362,7 +362,7 @@ class DboSource extends DataSource { * * @return integer Number of affected rows */ - function lastAffected() { + function lastAffected($source = null) { if ($this->hasResult()) { return $this->_result->rowCount(); } @@ -375,7 +375,7 @@ class DboSource extends DataSource { * * @return integer Number of rows in resultset */ - function lastNumRows() { + function lastNumRows($source = null) { if ($this->hasResult()) { $i = 0; foreach ($this->_result as $row) { diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 835176bc8..e8b3a7d08 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -650,7 +650,7 @@ class DboMysqlTest extends CakeTestCase { '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'); } @@ -728,8 +728,8 @@ class DboMysqlTest extends CakeTestCase { 'other__field' => 'SUM(id)' ); - $this->db->virtualFieldSeparator = '_$_'; - $result = $this->db->fields($model, null, array('data', 'other__field')); + $this->Dbo->virtualFieldSeparator = '_$_'; + $result = $this->Dbo->fields($model, null, array('data', 'other__field')); $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); $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')); - $result = $this->db->describe($model); - $this->db->execute($this->db->dropSchema($schema)); + $result = $this->Dbo->describe($model); + $this->Dbo->execute($this->Dbo->dropSchema($schema)); $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); $this->assertEqual($result['stringy']['charset'], 'cp1250'); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index 3cbd18f68..b44d50104 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -807,7 +807,7 @@ class DboPostgresTest extends CakeTestCase { */ function testUpdateAllWithNonQualifiedConditions() { $this->loadFixtures('Article'); - $Article =& new Article(); + $Article = new Article(); $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article')); $this->assertTrue($result); @@ -823,7 +823,7 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testAlteringTwoTables() { - $schema1 =& new CakeSchema(array( + $schema1 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( @@ -835,7 +835,7 @@ class DboPostgresTest extends CakeTestCase { 'name' => array('type' => 'string', 'null' => false, 'length' => 50), ) )); - $schema2 =& new CakeSchema(array( + $schema2 = new CakeSchema(array( 'name' => 'AlterTest1', 'connection' => 'test', 'altertest' => array( diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index f095f2ad1..93301e31f 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -992,36 +992,36 @@ class DboSourceTest extends CakeTestCase { // EMPTY STRING $result = $this->testDb->value('', 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); // BOOLEAN $result = $this->testDb->value('true', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value('false', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(true, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(false, 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); $result = $this->testDb->value(1, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(0, 'boolean'); - $this->assertEqual($result, 0); + $this->assertEqual($result, "'0'"); $result = $this->testDb->value('abc', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value(1.234, 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); $result = $this->testDb->value('1.234e05', 'boolean'); - $this->assertEqual($result, 1); + $this->assertEqual($result, "'1'"); // NUMBERS $result = $this->testDb->value(123, 'integer');