Browse Source

Add deprecation warnings to Error package.

Mark Story 8 years ago
parent
commit
c5570704be
2 changed files with 29 additions and 8 deletions
  1. 3 0
      src/Error/Debugger.php
  2. 26 8
      tests/TestCase/Error/DebuggerTest.php

+ 3 - 0
src/Error/Debugger.php

@@ -688,6 +688,9 @@ class Debugger
      */
     public static function outputAs($format = null)
     {
+        deprecationWarning(
+            'Debugger::outputAs() is deprecated. Use Debugger::getOutputFormat()/setOutputFormat() instead.'
+        );
         $self = Debugger::getInstance();
         if ($format === null) {
             return $self->_outputFormat;

+ 26 - 8
tests/TestCase/Error/DebuggerTest.php

@@ -141,23 +141,41 @@ class DebuggerTest extends TestCase
     /**
      * Test that outputAs works.
      *
+     * @group deprecated
      * @return void
      */
     public function testOutputAs()
     {
-        Debugger::outputAs('html');
-        $this->assertEquals('html', Debugger::outputAs());
+        $this->deprecated(function() {
+            Debugger::outputAs('html');
+            $this->assertEquals('html', Debugger::outputAs());
+        });
+    }
+
+    /**
+     * Test that setOutputFormat works.
+     *
+     * @group deprecated
+     * @return void
+     */
+    public function testSetOutputFormat()
+    {
+        Debugger::setOutputFormat('html');
+        $this->assertEquals('html', Debugger::getOutputFormat());
     }
 
     /**
      * Test that choosing a non-existent format causes an exception
      *
+     * @group deprecated
      * @expectedException \InvalidArgumentException
      * @return void
      */
     public function testOutputAsException()
     {
-        Debugger::outputAs('Invalid junk');
+        $this->deprecated(function() {
+            Debugger::outputAs('Invalid junk');
+        });
     }
 
     /**
@@ -189,7 +207,7 @@ class DebuggerTest extends TestCase
      */
     public function testOutputErrorDescriptionEncoding()
     {
-        Debugger::outputAs('html');
+        Debugger::setOutputFormat('html');
 
         ob_start();
         $debugger = Debugger::getInstance();
@@ -213,7 +231,7 @@ class DebuggerTest extends TestCase
      */
     public function testOutputErrorLineHighlight()
     {
-        Debugger::outputAs('js');
+        Debugger::setOutputFormat('js');
 
         ob_start();
         $debugger = Debugger::getInstance();
@@ -242,7 +260,7 @@ class DebuggerTest extends TestCase
             'traceLine' => '{:reference} - <a href="txmt://open?url=file://{:file}' .
                 '&line={:line}">{:path}</a>, line {:line}'
         ]);
-        Debugger::outputAs('js');
+        Debugger::setOutputFormat('js');
 
         $result = Debugger::trace();
         $this->assertRegExp('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result);
@@ -251,7 +269,7 @@ class DebuggerTest extends TestCase
             'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' .
                 '{:description}</error>',
         ]);
-        Debugger::outputAs('xml');
+        Debugger::setOutputFormat('xml');
 
         ob_start();
         $debugger = Debugger::getInstance();
@@ -283,7 +301,7 @@ class DebuggerTest extends TestCase
     public function testAddFormatCallback()
     {
         Debugger::addFormat('callback', ['callback' => [$this, 'customFormat']]);
-        Debugger::outputAs('callback');
+        Debugger::setOutputFormat('callback');
 
         ob_start();
         $debugger = Debugger::getInstance();