mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Modifying dbo_source to refer to $this->fullDebug rather than Configure::read() to determine whether or not to log
queries modifying fixture loading to not log create, drop, truncate statements correcting model tests that change fullDebug to reset to the value before the test ran git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7421 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f131b2e441
commit
53dcefff53
4 changed files with 28 additions and 10 deletions
|
@ -192,7 +192,7 @@ class DboSource extends DataSource {
|
||||||
$this->error = $this->lastError();
|
$this->error = $this->lastError();
|
||||||
$this->numRows = $this->lastNumRows();
|
$this->numRows = $this->lastNumRows();
|
||||||
|
|
||||||
if (Configure::read() > 1) {
|
if ($this->fullDebug) {
|
||||||
$this->logQuery($sql);
|
$this->logQuery($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -886,6 +886,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$this->loadFixtures('CategoryThread');
|
$this->loadFixtures('CategoryThread');
|
||||||
$TestModel =& new CategoryThread();
|
$TestModel =& new CategoryThread();
|
||||||
|
|
||||||
|
$fullDebug = $db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->recursive = 6;
|
$TestModel->recursive = 6;
|
||||||
$TestModel->id = 7;
|
$TestModel->id = 7;
|
||||||
|
@ -898,6 +899,7 @@ class ModelTest extends CakeTestCase {
|
||||||
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')))))));
|
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')))))));
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -910,6 +912,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$this->loadFixtures('CategoryThread');
|
$this->loadFixtures('CategoryThread');
|
||||||
$TestModel =& new CategoryThread();
|
$TestModel =& new CategoryThread();
|
||||||
|
|
||||||
|
$fullDebug = $db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->recursive = 6;
|
$TestModel->recursive = 6;
|
||||||
$result = $TestModel->find(array('CategoryThread.id' => 7));
|
$result = $TestModel->find(array('CategoryThread.id' => 7));
|
||||||
|
@ -922,6 +925,7 @@ class ModelTest extends CakeTestCase {
|
||||||
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')))))));
|
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31')))))));
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -934,6 +938,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$this->loadFixtures('CategoryThread');
|
$this->loadFixtures('CategoryThread');
|
||||||
$TestModel =& new CategoryThread();
|
$TestModel =& new CategoryThread();
|
||||||
|
|
||||||
|
$fullDebug = $db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->recursive = 6;
|
$TestModel->recursive = 6;
|
||||||
$result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
|
$result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
|
||||||
|
@ -972,6 +977,7 @@ class ModelTest extends CakeTestCase {
|
||||||
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
'ParentCategory' => array('id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31',
|
||||||
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'))))))));
|
'ParentCategory' => array('id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31'))))))));
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1470,6 +1476,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$result = $TestModel->findCount();
|
$result = $TestModel->findCount();
|
||||||
$this->assertEqual($result, 4);
|
$this->assertEqual($result, 4);
|
||||||
|
|
||||||
|
$fullDebug = $db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->order = 'User.id';
|
$TestModel->order = 'User.id';
|
||||||
$this->db->_queriesLog = array();
|
$this->db->_queriesLog = array();
|
||||||
|
@ -1480,7 +1487,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$this->assertNoPattern('/ORDER\s+BY/', $this->db->_queriesLog[0]['query']);
|
$this->assertNoPattern('/ORDER\s+BY/', $this->db->_queriesLog[0]['query']);
|
||||||
|
|
||||||
$this->db->_queriesLog = array();
|
$this->db->_queriesLog = array();
|
||||||
$this->db->fullDebug = false;
|
$db->fullDebug = $fullDebug;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testFindMagic method
|
* testFindMagic method
|
||||||
|
|
|
@ -653,7 +653,6 @@ class CakeTestCase extends UnitTestCase {
|
||||||
// Get db connection
|
// Get db connection
|
||||||
$this->db =& ConnectionManager::getDataSource('test_suite');
|
$this->db =& ConnectionManager::getDataSource('test_suite');
|
||||||
$this->db->cacheSources = false;
|
$this->db->cacheSources = false;
|
||||||
$this->db->fullDebug = false;
|
|
||||||
|
|
||||||
ClassRegistry::config(array('ds' => 'test_suite'));
|
ClassRegistry::config(array('ds' => 'test_suite'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,11 @@ class CakeTestFixture extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Schema->_build(array($this->table => $this->fields));
|
$this->Schema->_build(array($this->table => $this->fields));
|
||||||
return ($db->execute($db->createSchema($this->Schema)) !== false);
|
$fullDebug = $db->fullDebug;
|
||||||
|
$db->fullDebug = false;
|
||||||
|
$return = ($db->execute($db->createSchema($this->Schema)) !== false);
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Run after all tests executed, should return SQL statement to drop table for this fixture.
|
* Run after all tests executed, should return SQL statement to drop table for this fixture.
|
||||||
|
@ -154,7 +158,11 @@ class CakeTestFixture extends Object {
|
||||||
*/
|
*/
|
||||||
function drop(&$db) {
|
function drop(&$db) {
|
||||||
$this->Schema->_build(array($this->table => $this->fields));
|
$this->Schema->_build(array($this->table => $this->fields));
|
||||||
return ($db->execute($db->dropSchema($this->Schema)) !== false);
|
$fullDebug = $db->fullDebug;
|
||||||
|
$db->fullDebug = false;
|
||||||
|
$return = ($db->execute($db->dropSchema($this->Schema)) !== false);
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Run before each tests is executed, should return a set of SQL statements to insert records for the table
|
* Run before each tests is executed, should return a set of SQL statements to insert records for the table
|
||||||
|
@ -187,7 +195,11 @@ class CakeTestFixture extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function truncate(&$db) {
|
function truncate(&$db) {
|
||||||
return $db->truncate($this->table);
|
$fullDebug = $db->fullDebug;
|
||||||
|
$db->fullDebug = false;
|
||||||
|
$return = $db->truncate($this->table);
|
||||||
|
$db->fullDebug = $fullDebug;
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue