Fixing errors and failing tests with SQLite.

Seems that MySQL is extremely permissive with NOT NULL fields.
SQLite is more strict it seems.
This commit is contained in:
mark_story 2011-09-03 18:37:29 +01:00
parent cc8d44f21f
commit 2ceea79862
5 changed files with 24 additions and 11 deletions

View file

@ -153,7 +153,7 @@ class DboSource extends DataSource {
* *
* @var array * @var array
*/ */
public $connection = null; protected $_connection = null;
/** /**
* The DataSource configuration key name * The DataSource configuration key name

View file

@ -6567,13 +6567,14 @@ class ModelReadTest extends BaseModelTest {
* @return void * @return void
*/ */
public function testFindCount() { public function testFindCount() {
$this->loadFixtures('User', 'Article'); $this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag');
$TestModel = new User(); $TestModel = new User();
$this->db->getLog(false, true); $this->db->getLog(false, true);
$result = $TestModel->find('count'); $result = $TestModel->find('count');
$this->assertEqual($result, 4); $this->assertEqual($result, 4);
$this->db->getLog(false, true);
$fullDebug = $this->db->fullDebug; $fullDebug = $this->db->fullDebug;
$this->db->fullDebug = true; $this->db->fullDebug = true;
$TestModel->order = 'User.id'; $TestModel->order = 'User.id';
@ -6631,7 +6632,7 @@ class ModelReadTest extends BaseModelTest {
public function testFindCountWithDbExpressions() { public function testFindCountWithDbExpressions() {
$this->skipIf($this->db instanceof Postgres, 'testFindCountWithDbExpressions is not compatible with Postgres.'); $this->skipIf($this->db instanceof Postgres, 'testFindCountWithDbExpressions is not compatible with Postgres.');
$this->loadFixtures('Project'); $this->loadFixtures('Project', 'Thread');
$db = ConnectionManager::getDataSource('test'); $db = ConnectionManager::getDataSource('test');
$TestModel = new Project(); $TestModel = new Project();

View file

@ -3007,7 +3007,7 @@ class ModelWriteTest extends BaseModelTest {
public function testSaveAllManyRowsTransactionNoRollback() { public function testSaveAllManyRowsTransactionNoRollback() {
$this->loadFixtures('Post'); $this->loadFixtures('Post');
$this->getMock('DboSource', array(), array(), 'MockTransactionDboSource'); $this->getMock('DboSource', array('connect', 'rollback', 'describe'), array(), 'MockTransactionDboSource');
$db = ConnectionManager::create('mock_transaction', array( $db = ConnectionManager::create('mock_transaction', array(
'datasource' => 'MockTransactionDboSource', 'datasource' => 'MockTransactionDboSource',
)); ));
@ -3038,7 +3038,12 @@ class ModelWriteTest extends BaseModelTest {
public function testSaveAllAssociatedTransactionNoRollback() { public function testSaveAllAssociatedTransactionNoRollback() {
$testDb = ConnectionManager::getDataSource('test'); $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( $db = ConnectionManager::create('mock_transaction_assoc', array(
'datasource' => 'MockTransactionAssociatedDboSource', 'datasource' => 'MockTransactionAssociatedDboSource',
)); ));
@ -4313,7 +4318,7 @@ class ModelWriteTest extends BaseModelTest {
public function testSaveManyTransactionNoRollback() { public function testSaveManyTransactionNoRollback() {
$this->loadFixtures('Post'); $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( $db = ConnectionManager::create('mock_many_transaction', array(
'datasource' => 'MockManyTransactionDboSource', 'datasource' => 'MockManyTransactionDboSource',
)); ));
@ -4344,7 +4349,13 @@ class ModelWriteTest extends BaseModelTest {
public function testSaveAssociatedTransactionNoRollback() { public function testSaveAssociatedTransactionNoRollback() {
$testDb = ConnectionManager::getDataSource('test'); $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( $db = ConnectionManager::create('mock_assoc_transaction', array(
'datasource' => 'MockAssociatedTransactionDboSource', 'datasource' => 'MockAssociatedTransactionDboSource',
)); ));

View file

@ -38,8 +38,8 @@ class ArticleFixture extends CakeTestFixture {
*/ */
public $fields = array( public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'), 'id' => array('type' => 'integer', 'key' => 'primary'),
'user_id' => array('type' => 'integer', 'null' => false), 'user_id' => array('type' => 'integer', 'null' => true),
'title' => array('type' => 'string', 'null' => false), 'title' => array('type' => 'string', 'null' => true),
'body' => 'text', 'body' => 'text',
'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
'created' => 'datetime', 'created' => 'datetime',
@ -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' => 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') 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')
); );
} }

View file

@ -28,10 +28,10 @@ class CounterCachePostFixture extends CakeTestFixture {
public $fields = array( public $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'), '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),
'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( public $records = array(