Making more DboSlite tests pass

This commit is contained in:
José Lorenzo Rodríguez 2010-12-03 14:41:39 -04:30
parent 7c4ab886e6
commit e167271568
4 changed files with 15 additions and 26 deletions

View file

@ -184,18 +184,15 @@ class DboSqlite extends DboSource {
'default' => $default,
'length' => $this->length($column['type'])
);
if($column['pk'] == 1) {
$fields[$column['name']] = array(
'type' => $fields[$column['name']]['type'],
'null' => false,
'default' => $default,
'key' => $this->index['PRI'],
'length' => 11
);
if ($column['pk'] == 1) {
$fields[$column['name']]['key'] = $this->index['PRI'];
$fields[$column['name']]['null'] = false;
if (empty($fields[$column['name']]['length'])) {
$fields[$column['name']]['length'] = 11;
}
}
}
$result->closeCursor();
$this->__cacheDescription($model->tablePrefix . $model->table, $fields);
return $fields;

View file

@ -550,7 +550,7 @@ class DboSource extends DataSource {
if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) {
return $cached;
}
if ($this->execute($sql, array(), $params)) {
if ($result = $this->execute($sql, array(), $params)) {
$out = array();
$first = $this->fetchRow();
@ -562,7 +562,7 @@ class DboSource extends DataSource {
$out[] = $item;
}
if ($cache) {
if (!is_bool($result) && $cache) {
$this->_writeQueryCache($sql, $out, $params);
}

View file

@ -98,6 +98,7 @@ class BakeShellTest extends CakeTestCase {
$this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.');
$this->Shell->expects($this->at(5))->method('out')->with('<success>Bake All complete</success>');
$this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.');
$this->Shell->expects($this->at(8))->method('out')->with('Bake All complete');
$this->Shell->params = array();
$this->Shell->args = array('User');

View file

@ -90,14 +90,6 @@ class DboSqliteTest extends CakeTestCase {
*/
public $Dbo = null;
/**
* Simulated DB connection used in testing
*
* @var DboSource
* @access public
*/
public $Dbo2 = null;
/**
* Sets up a Dbo class instance for testing
*
@ -108,7 +100,6 @@ class DboSqliteTest extends CakeTestCase {
if ($this->Dbo->config['driver'] !== 'sqlite') {
$this->markTestSkipped('The Sqlite extension is not available.');
}
$this->Dbo2 = new DboSqliteTestDb($this->Dbo->config, false);
}
/**
@ -117,7 +108,6 @@ class DboSqliteTest extends CakeTestCase {
*/
public function tearDown() {
Configure::write('Cache.disable', false);
unset($this->Dbo2);
}
/**
@ -127,10 +117,11 @@ class DboSqliteTest extends CakeTestCase {
public function testTableListCacheDisabling() {
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
$this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255));');
$this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255))');
$this->assertTrue(in_array('foo_test', $this->Dbo->listSources()));
$this->Dbo->query('DROP TABLE foo_test;');
$this->Dbo->cacheSources = false;
$this->Dbo->query('DROP TABLE foo_test');
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
}
@ -207,7 +198,7 @@ class DboSqliteTest extends CakeTestCase {
'null' => false,
);
$result = $this->Dbo->buildColumn($data);
$expected = '"int_field" integer(11) NOT NULL';
$expected = '"int_field" integer NOT NULL';
$this->assertEqual($result, $expected);
$data = array(
@ -251,7 +242,7 @@ class DboSqliteTest extends CakeTestCase {
'null' => false,
);
$result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL';
$expected = '"testName" integer(10) DEFAULT 10 NOT NULL';
$this->assertEqual($result, $expected);
$data = array(
@ -263,7 +254,7 @@ class DboSqliteTest extends CakeTestCase {
'collate' => 'BADVALUE'
);
$result = $this->Dbo->buildColumn($data);
$expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL';
$expected = '"testName" integer(10) DEFAULT 10 NOT NULL';
$this->assertEqual($result, $expected);
}