浏览代码

Add a deprecation warning helper.

This will make adding framework deprecation warnings we plan to add in
3.6.x simpler as they will be easier to write.
Mark Story 8 年之前
父节点
当前提交
8840b115f3
共有 2 个文件被更改,包括 22 次插入0 次删除
  1. 13 0
      src/Core/functions.php
  2. 9 0
      tests/TestCase/Core/FunctionsTest.php

+ 13 - 0
src/Core/functions.php

@@ -248,3 +248,16 @@ if (!function_exists('env')) {
     }
 
 }
+
+if (!function_exists('deprecationWarning')) {
+    /**
+     * Helper method for outputting deprecation warnings
+     *
+     * @param string $message The message to output as a deprecation warning.
+     * @return void
+     */
+    function deprecationWarning($message)
+    {
+        trigger_error($message, E_USER_DEPRECATED);
+    }
+}

+ 9 - 0
tests/TestCase/Core/FunctionsTest.php

@@ -42,4 +42,13 @@ class FunctionsTest extends TestCase
         $this->assertEquals('0', env('ZERO'));
         $this->assertEquals('0', env('ZERO', '1'));
     }
+
+    /**
+     * @expectedException PHPUnit\Framework\Error\Deprecated
+     * @expectedExceptionMessage This is going away
+     */
+    public function testDeprecationWarning()
+    {
+        deprecationWarning('This is going away');
+    }
 }