Skip to content

Commit

Permalink
Making more DboSlite tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 3, 2010
1 parent 7c4ab88 commit e167271
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
15 changes: 6 additions & 9 deletions cake/libs/model/datasources/dbo/dbo_sqlite.php
Expand Up @@ -184,18 +184,15 @@ function describe(&$model) {
'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;
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -550,7 +550,7 @@ public function fetchAll($sql, $params = array(), $options = array()) {
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();
Expand All @@ -562,7 +562,7 @@ public function fetchAll($sql, $params = array(), $options = array()) {
$out[] = $item;
}

if ($cache) {
if (!is_bool($result) && $cache) {
$this->_writeQueryCache($sql, $out, $params);
}

Expand Down
1 change: 1 addition & 0 deletions cake/tests/cases/console/shells/bake.test.php
Expand Up @@ -98,6 +98,7 @@ public function testAllWithModelName() {
$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');
Expand Down
21 changes: 6 additions & 15 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
Expand Up @@ -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
*
Expand All @@ -108,7 +100,6 @@ public function setUp() {
if ($this->Dbo->config['driver'] !== 'sqlite') {
$this->markTestSkipped('The Sqlite extension is not available.');
}
$this->Dbo2 = new DboSqliteTestDb($this->Dbo->config, false);
}

/**
Expand All @@ -117,7 +108,6 @@ public function setUp() {
*/
public function tearDown() {
Configure::write('Cache.disable', false);
unset($this->Dbo2);
}

/**
Expand All @@ -127,10 +117,11 @@ public function tearDown() {
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()));
}

Expand Down Expand Up @@ -207,7 +198,7 @@ function testBuildColumn() {
'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(
Expand Down Expand Up @@ -251,7 +242,7 @@ function testBuildColumn() {
'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(
Expand All @@ -263,7 +254,7 @@ function testBuildColumn() {
'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);
}

Expand Down

0 comments on commit e167271

Please sign in to comment.