Skip to content

Commit 2ceea79

Browse files
committed
Fixing errors and failing tests with SQLite.
Seems that MySQL is extremely permissive with NOT NULL fields. SQLite is more strict it seems.
1 parent cc8d44f commit 2ceea79

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

lib/Cake/Model/Datasource/DboSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class DboSource extends DataSource {
153153
*
154154
* @var array
155155
*/
156-
public $connection = null;
156+
protected $_connection = null;
157157

158158
/**
159159
* The DataSource configuration key name

lib/Cake/Test/Case/Model/ModelReadTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6567,13 +6567,14 @@ public function testFindUnique() {
65676567
* @return void
65686568
*/
65696569
public function testFindCount() {
6570-
$this->loadFixtures('User', 'Article');
6570+
$this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag');
65716571

65726572
$TestModel = new User();
65736573
$this->db->getLog(false, true);
65746574
$result = $TestModel->find('count');
65756575
$this->assertEqual($result, 4);
65766576

6577+
$this->db->getLog(false, true);
65776578
$fullDebug = $this->db->fullDebug;
65786579
$this->db->fullDebug = true;
65796580
$TestModel->order = 'User.id';
@@ -6631,7 +6632,7 @@ public function testFindCountDistinct() {
66316632
public function testFindCountWithDbExpressions() {
66326633
$this->skipIf($this->db instanceof Postgres, 'testFindCountWithDbExpressions is not compatible with Postgres.');
66336634

6634-
$this->loadFixtures('Project');
6635+
$this->loadFixtures('Project', 'Thread');
66356636
$db = ConnectionManager::getDataSource('test');
66366637
$TestModel = new Project();
66376638

lib/Cake/Test/Case/Model/ModelWriteTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,7 @@ public function testSaveAllHasManyValidation() {
30073007
public function testSaveAllManyRowsTransactionNoRollback() {
30083008
$this->loadFixtures('Post');
30093009

3010-
$this->getMock('DboSource', array(), array(), 'MockTransactionDboSource');
3010+
$this->getMock('DboSource', array('connect', 'rollback', 'describe'), array(), 'MockTransactionDboSource');
30113011
$db = ConnectionManager::create('mock_transaction', array(
30123012
'datasource' => 'MockTransactionDboSource',
30133013
));
@@ -3038,7 +3038,12 @@ public function testSaveAllManyRowsTransactionNoRollback() {
30383038
public function testSaveAllAssociatedTransactionNoRollback() {
30393039
$testDb = ConnectionManager::getDataSource('test');
30403040

3041-
$mock = $this->getMock('DboSource', array(), array(), 'MockTransactionAssociatedDboSource', false);
3041+
$mock = $this->getMock(
3042+
'DboSource',
3043+
array('connect', 'rollback', 'describe', 'create', 'update', 'begin'),
3044+
array(),
3045+
'MockTransactionAssociatedDboSource'
3046+
);
30423047
$db = ConnectionManager::create('mock_transaction_assoc', array(
30433048
'datasource' => 'MockTransactionAssociatedDboSource',
30443049
));
@@ -4313,7 +4318,7 @@ public function testSaveAssociatedHasManyValidation() {
43134318
public function testSaveManyTransactionNoRollback() {
43144319
$this->loadFixtures('Post');
43154320

4316-
$this->getMock('DboSource', array(), array(), 'MockManyTransactionDboSource');
4321+
$this->getMock('DboSource', array('connect', 'rollback', 'describe'), array(), 'MockManyTransactionDboSource');
43174322
$db = ConnectionManager::create('mock_many_transaction', array(
43184323
'datasource' => 'MockManyTransactionDboSource',
43194324
));
@@ -4344,7 +4349,13 @@ public function testSaveManyTransactionNoRollback() {
43444349
public function testSaveAssociatedTransactionNoRollback() {
43454350
$testDb = ConnectionManager::getDataSource('test');
43464351

4347-
$mock = $this->getMock('DboSource', array(), array(), 'MockAssociatedTransactionDboSource', false);
4352+
$mock = $this->getMock(
4353+
'DboSource',
4354+
array('connect', 'rollback', 'describe', 'create', 'begin'),
4355+
array(),
4356+
'MockAssociatedTransactionDboSource',
4357+
false
4358+
);
43484359
$db = ConnectionManager::create('mock_assoc_transaction', array(
43494360
'datasource' => 'MockAssociatedTransactionDboSource',
43504361
));

lib/Cake/Test/Fixture/ArticleFixture.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class ArticleFixture extends CakeTestFixture {
3838
*/
3939
public $fields = array(
4040
'id' => array('type' => 'integer', 'key' => 'primary'),
41-
'user_id' => array('type' => 'integer', 'null' => false),
42-
'title' => array('type' => 'string', 'null' => false),
41+
'user_id' => array('type' => 'integer', 'null' => true),
42+
'title' => array('type' => 'string', 'null' => true),
4343
'body' => 'text',
4444
'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
4545
'created' => 'datetime',
@@ -56,4 +56,5 @@ class ArticleFixture extends CakeTestFixture {
5656
array('user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),
5757
array('user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31')
5858
);
59+
5960
}

lib/Cake/Test/Fixture/CounterCachePostFixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class CounterCachePostFixture extends CakeTestFixture {
2828

2929
public $fields = array(
3030
'id' => array('type' => 'integer', 'key' => 'primary'),
31-
'title' => array('type' => 'string', 'length' => 255, 'null' => false),
31+
'title' => array('type' => 'string', 'length' => 255),
3232
'user_id' => array('type' => 'integer', 'null' => true),
3333
'user_id' => array('type' => 'integer', 'null' => true),
34-
'published' => array('type' => 'boolean', 'null' => false)
34+
'published' => array('type' => 'boolean', 'null' => false, 'default' => 0)
3535
);
3636

3737
public $records = array(

0 commit comments

Comments
 (0)