Skip to content
Permalink
Browse files

cleaning up some tests, adding missing parameters in DboSource to mat…

…ch declaration on DataSource
  • Loading branch information...
lorenzo committed Nov 9, 2010
1 parent 9caba98 commit 47c6132b245fdb5318b9af9d81e5dbeeec8e3e30
@@ -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;
}
@@ -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;
}
@@ -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;
@@ -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();
}
@@ -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) {
@@ -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');
}

@@ -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);
}
@@ -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');
@@ -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);
@@ -823,7 +823,7 @@ function testUpdateAllWithNonQualifiedConditions() {
* @return void
*/
function testAlteringTwoTables() {
$schema1 =& new CakeSchema(array(
$schema1 = new CakeSchema(array(
'name' => 'AlterTest1',
'connection' => 'test',
'altertest' => array(
@@ -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(
@@ -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');

0 comments on commit 47c6132

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