mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making more DboSlite tests pass
This commit is contained in:
parent
7c4ab886e6
commit
e167271568
4 changed files with 15 additions and 26 deletions
|
@ -184,18 +184,15 @@ class DboSqlite extends DboSource {
|
||||||
'default' => $default,
|
'default' => $default,
|
||||||
'length' => $this->length($column['type'])
|
'length' => $this->length($column['type'])
|
||||||
);
|
);
|
||||||
if($column['pk'] == 1) {
|
if ($column['pk'] == 1) {
|
||||||
$fields[$column['name']] = array(
|
$fields[$column['name']]['key'] = $this->index['PRI'];
|
||||||
'type' => $fields[$column['name']]['type'],
|
$fields[$column['name']]['null'] = false;
|
||||||
'null' => false,
|
if (empty($fields[$column['name']]['length'])) {
|
||||||
'default' => $default,
|
$fields[$column['name']]['length'] = 11;
|
||||||
'key' => $this->index['PRI'],
|
}
|
||||||
'length' => 11
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
$this->__cacheDescription($model->tablePrefix . $model->table, $fields);
|
$this->__cacheDescription($model->tablePrefix . $model->table, $fields);
|
||||||
return $fields;
|
return $fields;
|
||||||
|
|
|
@ -550,7 +550,7 @@ class DboSource extends DataSource {
|
||||||
if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) {
|
if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) {
|
||||||
return $cached;
|
return $cached;
|
||||||
}
|
}
|
||||||
if ($this->execute($sql, array(), $params)) {
|
if ($result = $this->execute($sql, array(), $params)) {
|
||||||
$out = array();
|
$out = array();
|
||||||
|
|
||||||
$first = $this->fetchRow();
|
$first = $this->fetchRow();
|
||||||
|
@ -562,7 +562,7 @@ class DboSource extends DataSource {
|
||||||
$out[] = $item;
|
$out[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cache) {
|
if (!is_bool($result) && $cache) {
|
||||||
$this->_writeQueryCache($sql, $out, $params);
|
$this->_writeQueryCache($sql, $out, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(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(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(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->params = array();
|
||||||
$this->Shell->args = array('User');
|
$this->Shell->args = array('User');
|
||||||
|
|
|
@ -90,14 +90,6 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public $Dbo = null;
|
public $Dbo = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simulated DB connection used in testing
|
|
||||||
*
|
|
||||||
* @var DboSource
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public $Dbo2 = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up a Dbo class instance for testing
|
* Sets up a Dbo class instance for testing
|
||||||
*
|
*
|
||||||
|
@ -108,7 +100,6 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
if ($this->Dbo->config['driver'] !== 'sqlite') {
|
if ($this->Dbo->config['driver'] !== 'sqlite') {
|
||||||
$this->markTestSkipped('The Sqlite extension is not available.');
|
$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() {
|
public function tearDown() {
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
unset($this->Dbo2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,10 +117,11 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
public function testTableListCacheDisabling() {
|
public function testTableListCacheDisabling() {
|
||||||
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
|
$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->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()));
|
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +198,7 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
'null' => false,
|
'null' => false,
|
||||||
);
|
);
|
||||||
$result = $this->Dbo->buildColumn($data);
|
$result = $this->Dbo->buildColumn($data);
|
||||||
$expected = '"int_field" integer(11) NOT NULL';
|
$expected = '"int_field" integer NOT NULL';
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -251,7 +242,7 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
'null' => false,
|
'null' => false,
|
||||||
);
|
);
|
||||||
$result = $this->Dbo->buildColumn($data);
|
$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);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -263,7 +254,7 @@ class DboSqliteTest extends CakeTestCase {
|
||||||
'collate' => 'BADVALUE'
|
'collate' => 'BADVALUE'
|
||||||
);
|
);
|
||||||
$result = $this->Dbo->buildColumn($data);
|
$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);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue