From 53dcefff53e7f29a8197691ba7b5fc67e5c36c4e Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 2 Aug 2008 19:41:53 +0000 Subject: [PATCH] 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 --- cake/libs/model/datasources/dbo_source.php | 4 ++-- cake/tests/cases/libs/model/model.test.php | 11 +++++++++-- cake/tests/lib/cake_test_case.php | 3 +-- cake/tests/lib/cake_test_fixture.php | 20 ++++++++++++++++---- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 60dd37b51..a9452ae51 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -192,7 +192,7 @@ class DboSource extends DataSource { $this->error = $this->lastError(); $this->numRows = $this->lastNumRows(); - if (Configure::read() > 1) { + if ($this->fullDebug) { $this->logQuery($sql); } @@ -2412,4 +2412,4 @@ class DboSource extends DataSource { } } -?> \ No newline at end of file +?> diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 4bdba41de..c227db019 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -886,6 +886,7 @@ class ModelTest extends CakeTestCase { $this->loadFixtures('CategoryThread'); $TestModel =& new CategoryThread(); + $fullDebug = $db->fullDebug; $this->db->fullDebug = true; $TestModel->recursive = 6; $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' => 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'))))))); + $db->fullDebug = $fullDebug; $this->assertEqual($result, $expected); } /** @@ -910,6 +912,7 @@ class ModelTest extends CakeTestCase { $this->loadFixtures('CategoryThread'); $TestModel =& new CategoryThread(); + $fullDebug = $db->fullDebug; $this->db->fullDebug = true; $TestModel->recursive = 6; $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' => 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'))))))); + $db->fullDebug = $fullDebug; $this->assertEqual($result, $expected); } /** @@ -934,6 +938,7 @@ class ModelTest extends CakeTestCase { $this->loadFixtures('CategoryThread'); $TestModel =& new CategoryThread(); + $fullDebug = $db->fullDebug; $this->db->fullDebug = true; $TestModel->recursive = 6; $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' => 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')))))))); + $db->fullDebug = $fullDebug; $this->assertEqual($result, $expected); } /** @@ -1470,6 +1476,7 @@ class ModelTest extends CakeTestCase { $result = $TestModel->findCount(); $this->assertEqual($result, 4); + $fullDebug = $db->fullDebug; $this->db->fullDebug = true; $TestModel->order = 'User.id'; $this->db->_queriesLog = array(); @@ -1480,7 +1487,7 @@ class ModelTest extends CakeTestCase { $this->assertNoPattern('/ORDER\s+BY/', $this->db->_queriesLog[0]['query']); $this->db->_queriesLog = array(); - $this->db->fullDebug = false; + $db->fullDebug = $fullDebug; } /** * testFindMagic method @@ -5550,4 +5557,4 @@ class ModelTest extends CakeTestCase { } } -?> \ No newline at end of file +?> diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 81b978bad..186fce9a1 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -653,7 +653,6 @@ class CakeTestCase extends UnitTestCase { // Get db connection $this->db =& ConnectionManager::getDataSource('test_suite'); $this->db->cacheSources = false; - $this->db->fullDebug = false; ClassRegistry::config(array('ds' => 'test_suite')); } @@ -731,4 +730,4 @@ class CakeTestCase extends UnitTestCase { } } } -?> \ No newline at end of file +?> diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 34b41f845..104b08d03 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -143,7 +143,11 @@ class CakeTestFixture extends Object { } $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. @@ -154,7 +158,11 @@ class CakeTestFixture extends Object { */ function drop(&$db) { $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 @@ -187,7 +195,11 @@ class CakeTestFixture extends Object { * @access public */ function truncate(&$db) { - return $db->truncate($this->table); + $fullDebug = $db->fullDebug; + $db->fullDebug = false; + $return = $db->truncate($this->table); + $db->fullDebug = $fullDebug; + return $return; } } -?> \ No newline at end of file +?>