Browse Source

Merge pull request #13921 from cakephp/3.next-doctype

Mark HtmlHelper::docType() as deprecated.
othercorey 6 years ago
parent
commit
4519191e6e
2 changed files with 12 additions and 7 deletions
  1. 3 0
      src/View/Helper/HtmlHelper.php
  2. 9 7
      tests/TestCase/View/Helper/HtmlHelperTest.php

+ 3 - 0
src/View/Helper/HtmlHelper.php

@@ -185,9 +185,12 @@ class HtmlHelper extends Helper
      * @param string $type Doctype to use.
      * @return string|null Doctype string
      * @link https://book.cakephp.org/3/en/views/helpers/html.html#creating-doctype-tags
+     * @deprecated 3.9.0 This method will be removed in 4.0.0.
      */
     public function docType($type = 'html5')
     {
+        deprecationWarning('HtmlHelper::docType() is deprecated and will be removed in 4.0.0');
+
         if (isset($this->_docTypes[$type])) {
             return $this->_docTypes[$type];
         }

+ 9 - 7
tests/TestCase/View/Helper/HtmlHelperTest.php

@@ -98,15 +98,17 @@ class HtmlHelperTest extends TestCase
      */
     public function testDocType()
     {
-        $result = $this->Html->docType();
-        $expected = '<!DOCTYPE html>';
-        $this->assertEquals($expected, $result);
+        $this->deprecated(function () {
+            $result = $this->Html->docType();
+            $expected = '<!DOCTYPE html>';
+            $this->assertEquals($expected, $result);
 
-        $result = $this->Html->docType('html4-strict');
-        $expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
-        $this->assertEquals($expected, $result);
+            $result = $this->Html->docType('html4-strict');
+            $expected = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
+            $this->assertEquals($expected, $result);
 
-        $this->assertNull($this->Html->docType('non-existing-doctype'));
+            $this->assertNull($this->Html->docType('non-existing-doctype'));
+        });
     }
 
     /**