diff --git a/src/Core/functions.php b/src/Core/functions.php index b0b8a46a495..ac05d261f92 100644 --- a/src/Core/functions.php +++ b/src/Core/functions.php @@ -260,7 +260,7 @@ function env($key, $default = null) */ function deprecationWarning($message, $stackFrame = 2) { - if (!Configure::read('debug')) { + if (!(error_reporting() & E_USER_DEPRECATED)) { return; } $trace = debug_backtrace(); diff --git a/tests/TestCase/Core/FunctionsTest.php b/tests/TestCase/Core/FunctionsTest.php index 575e03283f6..b880f42ff25 100644 --- a/tests/TestCase/Core/FunctionsTest.php +++ b/tests/TestCase/Core/FunctionsTest.php @@ -14,7 +14,6 @@ */ namespace Cake\Test\TestCase\Core; -use Cake\Core\Configure; use Cake\TestSuite\TestCase; /** @@ -50,9 +49,8 @@ public function testEnv() * @expectedException PHPUnit\Framework\Error\Deprecated * @expectedExceptionMessage This is going away - [internal], line: ?? */ - public function testDeprecationWarningDebugEnabled() + public function testDeprecationWarningEnabled() { - Configure::write('debug', true); error_reporting(E_ALL); deprecationWarning('This is going away', 1); } @@ -63,9 +61,8 @@ public function testDeprecationWarningDebugEnabled() * @expectedException PHPUnit\Framework\Error\Deprecated * @expectedExceptionMessageRegExp /This is going away - (.*?)\/TestCase.php, line\: \d+/ */ - public function testDeprecationWarningDebugEnabledDefaultFrame() + public function testDeprecationWarningEnabledDefaultFrame() { - Configure::write('debug', true); error_reporting(E_ALL); deprecationWarning('This is going away'); } @@ -75,10 +72,9 @@ public function testDeprecationWarningDebugEnabledDefaultFrame() * * @return void */ - public function testDeprecationWarningDebugDisabled() + public function testDeprecationWarningLevelDisabled() { - Configure::write('debug', false); - error_reporting(E_ALL); + error_reporting(E_ALL ^ E_USER_DEPRECATED); $this->assertNull(deprecationWarning('This is going away')); } }