mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
cc8d44f21f
commit
2ceea79862
5 changed files with 24 additions and 11 deletions
|
@ -153,7 +153,7 @@ class DboSource extends DataSource {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $connection = null;
|
||||
protected $_connection = null;
|
||||
|
||||
/**
|
||||
* The DataSource configuration key name
|
||||
|
|
|
@ -6567,13 +6567,14 @@ class ModelReadTest extends BaseModelTest {
|
|||
* @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';
|
||||
|
@ -6631,7 +6632,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
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();
|
||||
|
||||
|
|
|
@ -3007,7 +3007,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
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',
|
||||
));
|
||||
|
@ -3038,7 +3038,12 @@ class ModelWriteTest extends BaseModelTest {
|
|||
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',
|
||||
));
|
||||
|
@ -4313,7 +4318,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
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',
|
||||
));
|
||||
|
@ -4344,7 +4349,13 @@ class ModelWriteTest extends BaseModelTest {
|
|||
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',
|
||||
));
|
||||
|
|
|
@ -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',
|
||||
|
@ -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')
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue