Skip to content

Commit

Permalink
Fixing errors and failing tests with SQLite.
Browse files Browse the repository at this point in the history
Seems that MySQL is extremely permissive with NOT NULL fields.
SQLite is more strict it seems.
  • Loading branch information
markstory committed Sep 3, 2011
1 parent cc8d44f commit 2ceea79
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -153,7 +153,7 @@ class DboSource extends DataSource {
*
* @var array
*/
public $connection = null;
protected $_connection = null;

/**
* The DataSource configuration key name
Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Test/Case/Model/ModelReadTest.php
Expand Up @@ -6567,13 +6567,14 @@ public function testFindUnique() {
* @return void
*/
public function testFindCount() {
$this->loadFixtures('User', 'Article');
$this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag');

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

$this->db->getLog(false, true);
$fullDebug = $this->db->fullDebug;
$this->db->fullDebug = true;
$TestModel->order = 'User.id';
Expand Down Expand Up @@ -6631,7 +6632,7 @@ public function testFindCountDistinct() {
public function testFindCountWithDbExpressions() {
$this->skipIf($this->db instanceof Postgres, 'testFindCountWithDbExpressions is not compatible with Postgres.');

$this->loadFixtures('Project');
$this->loadFixtures('Project', 'Thread');
$db = ConnectionManager::getDataSource('test');
$TestModel = new Project();

Expand Down
19 changes: 15 additions & 4 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Expand Up @@ -3007,7 +3007,7 @@ public function testSaveAllHasManyValidation() {
public function testSaveAllManyRowsTransactionNoRollback() {
$this->loadFixtures('Post');

$this->getMock('DboSource', array(), array(), 'MockTransactionDboSource');
$this->getMock('DboSource', array('connect', 'rollback', 'describe'), array(), 'MockTransactionDboSource');
$db = ConnectionManager::create('mock_transaction', array(
'datasource' => 'MockTransactionDboSource',
));
Expand Down Expand Up @@ -3038,7 +3038,12 @@ public function testSaveAllManyRowsTransactionNoRollback() {
public function testSaveAllAssociatedTransactionNoRollback() {
$testDb = ConnectionManager::getDataSource('test');

$mock = $this->getMock('DboSource', array(), array(), 'MockTransactionAssociatedDboSource', false);
$mock = $this->getMock(
'DboSource',
array('connect', 'rollback', 'describe', 'create', 'update', 'begin'),
array(),
'MockTransactionAssociatedDboSource'
);
$db = ConnectionManager::create('mock_transaction_assoc', array(
'datasource' => 'MockTransactionAssociatedDboSource',
));
Expand Down Expand Up @@ -4313,7 +4318,7 @@ public function testSaveAssociatedHasManyValidation() {
public function testSaveManyTransactionNoRollback() {
$this->loadFixtures('Post');

$this->getMock('DboSource', array(), array(), 'MockManyTransactionDboSource');
$this->getMock('DboSource', array('connect', 'rollback', 'describe'), array(), 'MockManyTransactionDboSource');
$db = ConnectionManager::create('mock_many_transaction', array(
'datasource' => 'MockManyTransactionDboSource',
));
Expand Down Expand Up @@ -4344,7 +4349,13 @@ public function testSaveManyTransactionNoRollback() {
public function testSaveAssociatedTransactionNoRollback() {
$testDb = ConnectionManager::getDataSource('test');

$mock = $this->getMock('DboSource', array(), array(), 'MockAssociatedTransactionDboSource', false);
$mock = $this->getMock(
'DboSource',
array('connect', 'rollback', 'describe', 'create', 'begin'),
array(),
'MockAssociatedTransactionDboSource',
false
);
$db = ConnectionManager::create('mock_assoc_transaction', array(
'datasource' => 'MockAssociatedTransactionDboSource',
));
Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Test/Fixture/ArticleFixture.php
Expand Up @@ -38,8 +38,8 @@ class ArticleFixture extends CakeTestFixture {
*/
public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'user_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'string', 'null' => false),
'user_id' => array('type' => 'integer', 'null' => true),
'title' => array('type' => 'string', 'null' => true),
'body' => 'text',
'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
'created' => 'datetime',
Expand All @@ -56,4 +56,5 @@ class ArticleFixture extends CakeTestFixture {
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'),
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')
);

}
4 changes: 2 additions & 2 deletions lib/Cake/Test/Fixture/CounterCachePostFixture.php
Expand Up @@ -28,10 +28,10 @@ class CounterCachePostFixture extends CakeTestFixture {

public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'title' => array('type' => 'string', 'length' => 255, 'null' => false),
'title' => array('type' => 'string', 'length' => 255),
'user_id' => array('type' => 'integer', 'null' => true),
'user_id' => array('type' => 'integer', 'null' => true),
'published' => array('type' => 'boolean', 'null' => false)
'published' => array('type' => 'boolean', 'null' => false, 'default' => 0)
);

public $records = array(
Expand Down

0 comments on commit 2ceea79

Please sign in to comment.