Browse Source

change stackFrame default in deprecationWarning()

saeid 8 years ago
parent
commit
7332e0a410
2 changed files with 5 additions and 5 deletions
  1. 2 2
      src/Core/functions.php
  2. 3 3
      tests/TestCase/Core/FunctionsTest.php

+ 2 - 2
src/Core/functions.php

@@ -279,11 +279,11 @@ if (!function_exists('deprecationWarning')) {
      * Helper method for outputting deprecation warnings
      *
      * @param string $message The message to output as a deprecation warning.
-     * @param int $stackFrame The stack frame to include in the error. Defaults to 2
+     * @param int $stackFrame The stack frame to include in the error. Defaults to 1
      *   as that should point to application/plugin code.
      * @return void
      */
-    function deprecationWarning($message, $stackFrame = 2)
+    function deprecationWarning($message, $stackFrame = 1)
     {
         if (!(error_reporting() & E_USER_DEPRECATED)) {
             return;

+ 3 - 3
tests/TestCase/Core/FunctionsTest.php

@@ -47,12 +47,12 @@ class FunctionsTest extends TestCase
      * Test error messages coming out when debug is on, manually setting the stack frame
      *
      * @expectedException PHPUnit\Framework\Error\Deprecated
-     * @expectedExceptionMessageRegExp /This is going away - (.*?)[\/\\]TestCase.php, line\: \d+/
+     * @expectedExceptionMessageRegExp /This is going away - (.*?)[\/\\]FunctionsTest.php, line\: \d+/
      */
     public function testDeprecationWarningEnabled()
     {
         $this->withErrorReporting(E_ALL, function () {
-            deprecationWarning('This is going away', 1);
+            deprecationWarning('This is going away', 2);
         });
     }
 
@@ -60,7 +60,7 @@ class FunctionsTest extends TestCase
      * Test error messages coming out when debug is on, not setting the stack frame manually
      *
      * @expectedException PHPUnit\Framework\Error\Deprecated
-     * @expectedExceptionMessageRegExp /This is going away - (.*?)[\/\\]FunctionsTest.php, line\: \d+/
+     * @expectedExceptionMessageRegExp /This is going away - (.*?)[\/\\]TestCase.php, line\: \d+/
      */
     public function testDeprecationWarningEnabledDefaultFrame()
     {