mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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
This commit is contained in:
parent
628a79aba6
commit
4a636b93a8
2 changed files with 26 additions and 7 deletions
|
@ -508,7 +508,7 @@ class DboSource extends DataSource {
|
||||||
if (strlen($sql) > 200 && !$this->fullDebug && Configure::read() > 1) {
|
if (strlen($sql) > 200 && !$this->fullDebug && Configure::read() > 1) {
|
||||||
$sql = substr($sql, 0, 200) . '[...]';
|
$sql = substr($sql, 0, 200) . '[...]';
|
||||||
}
|
}
|
||||||
if ($error && Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
$out = null;
|
$out = null;
|
||||||
if ($error) {
|
if ($error) {
|
||||||
trigger_error("<span style = \"color:Red;text-align:left\"><b>SQL Error:</b> {$this->error}</span>", E_USER_WARNING);
|
trigger_error("<span style = \"color:Red;text-align:left\"><b>SQL Error:</b> {$this->error}</span>", E_USER_WARNING);
|
||||||
|
|
|
@ -3719,12 +3719,6 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$oldDebug = Configure::read('debug');
|
$oldDebug = Configure::read('debug');
|
||||||
Configure::write('debug', 2);
|
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->testDb->error = true;
|
||||||
$this->expectError();
|
$this->expectError();
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -3736,6 +3730,31 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->testDb->error = $oldError;
|
$this->testDb->error = $oldError;
|
||||||
Configure::write('debug', $oldDebug);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue