From 4a636b93a86a4a98192fbaca5c3f9b53e995fef6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 14 Jan 2009 04:12:46 +0000 Subject: [PATCH] Fixing showQuery() when there is $error = false. Tests from 'zackenbarsch' added. Fixes #5983 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7978 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo_source.php | 2 +- .../model/datasources/dbo_source.test.php | 31 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 543c00441..6019b7da1 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -508,7 +508,7 @@ class DboSource extends DataSource { if (strlen($sql) > 200 && !$this->fullDebug && Configure::read() > 1) { $sql = substr($sql, 0, 200) . '[...]'; } - if ($error && Configure::read() > 0) { + if (Configure::read() > 0) { $out = null; if ($error) { trigger_error("SQL Error: {$this->error}", E_USER_WARNING); diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 6a56f2851..584f8006a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -3719,12 +3719,6 @@ class DboSourceTest extends CakeTestCase { $oldDebug = Configure::read('debug'); Configure::write('debug', 2); - $this->testDb->error = false; - ob_start(); - $this->testDb->showQuery('Query 3'); - $contents = ob_get_clean(); - $this->assertNoPattern('/Query 3/s', $contents); - $this->testDb->error = true; $this->expectError(); ob_start(); @@ -3736,6 +3730,31 @@ class DboSourceTest extends CakeTestCase { $this->testDb->error = $oldError; Configure::write('debug', $oldDebug); } +/** + * test ShowQuery generation of regular and error messages + * + * @return void + **/ + function testShowQuery() { + $this->testDb->error = false; + ob_start(); + $this->testDb->showQuery('Some Query'); + $contents = ob_get_clean(); + $this->assertPattern('/Some Query/s', $contents); + $this->assertPattern('/Aff:/s', $contents); + $this->assertPattern('/Num:/s', $contents); + $this->assertPattern('/Took:/s', $contents); + + $this->expectError(); + $this->testDb->error = true; + ob_start(); + $this->testDb->showQuery('Another Query'); + $contents = ob_get_clean(); + $this->assertPattern('/Another Query/s', $contents); + $this->assertNoPattern('/Aff:/s', $contents); + $this->assertNoPattern('/Num:/s', $contents); + $this->assertNoPattern('/Took:/s', $contents); + } } ?> \ No newline at end of file