Skip to content

Commit

Permalink
cleaning up some tests, adding missing parameters in DboSource to mat…
Browse files Browse the repository at this point in the history
…ch declaration on DataSource
  • Loading branch information
lorenzo committed Nov 9, 2010
1 parent 9caba98 commit 47c6132
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/datasource.php
Expand Up @@ -263,7 +263,7 @@ public function sources($reset = false) {
* @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;
}
Expand Down Expand Up @@ -556,7 +556,7 @@ function insertQueryData($query, $data, $association, $assocData, &$model, &$lin
* @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;
}

Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -179,7 +179,7 @@ function enabled() {
*
* @return array Array of tablenames in the database
*/
function listSources() {
function listSources($data = null) {
$cache = parent::listSources();
if ($cache != null) {
return $cache;
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -362,7 +362,7 @@ function lastError(PDOStatement $query = null) {
*
* @return integer Number of affected rows
*/
function lastAffected() {
function lastAffected($source = null) {
if ($this->hasResult()) {
return $this->_result->rowCount();
}
Expand All @@ -375,7 +375,7 @@ function lastAffected() {
*
* @return integer Number of rows in resultset
*/
function lastNumRows() {
function lastNumRows($source = null) {
if ($this->hasResult()) {
$i = 0;
foreach ($this->_result as $row) {
Expand Down
12 changes: 6 additions & 6 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
Expand Up @@ -650,7 +650,7 @@ function testAlteringTwoTables() {
'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');
}
Expand Down Expand Up @@ -728,8 +728,8 @@ function testVirtualFieldSeparators() {
'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);
}
Expand Down Expand Up @@ -759,10 +759,10 @@ function testDescribeGettingFieldParameters() {
)
));
$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');
Expand Down
Expand Up @@ -807,7 +807,7 @@ function testQuoteDistinctInFunction() {
*/
function testUpdateAllWithNonQualifiedConditions() {
$this->loadFixtures('Article');
$Article =& new Article();
$Article = new Article();
$result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article'));
$this->assertTrue($result);

Expand All @@ -823,7 +823,7 @@ function testUpdateAllWithNonQualifiedConditions() {
* @return void
*/
function testAlteringTwoTables() {
$schema1 =& new CakeSchema(array(
$schema1 = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
Expand All @@ -835,7 +835,7 @@ function testAlteringTwoTables() {
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
)
));
$schema2 =& new CakeSchema(array(
$schema2 = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
Expand Down
20 changes: 10 additions & 10 deletions cake/tests/cases/libs/model/datasources/dbo_source.test.php
Expand Up @@ -992,36 +992,36 @@ function testIntrospectType() {

// 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');
Expand Down

0 comments on commit 47c6132

Please sign in to comment.