1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * tool_brickfield check test. 19 * 20 * @package tool_brickfield 21 * @copyright 2020 onward: Brickfield Education Labs, https://www.brickfield.ie 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace tool_brickfield\local\htmlchecker\common\checks; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 require_once ('all_checks.php'); 30 31 /** 32 * Class header_h3_testcase 33 */ 34 class header_h3_test extends all_checks { 35 /** @var string Check type */ 36 protected $checktype = 'header_h3'; 37 38 /** @var string Html fail 1 */ 39 private $htmlfail1 = <<<EOD 40 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 41 <html lang="en"> 42 <head> 43 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 44 </head> 45 <body> 46 <h3>This is h3</h3> 47 <h5>This is h5</h5> 48 </body> 49 </html> 50 EOD; 51 52 /** @var string Html fail 2 */ 53 private $htmlfail2 = <<<EOD 54 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 55 <html lang="en"> 56 <head> 57 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 58 </head> 59 <body> 60 <h3>This is h3</h3> 61 <h6>This is h6</h6> 62 </body> 63 </html> 64 EOD; 65 66 /** @var string Html pass 1 */ 67 private $htmlpass1 = <<<EOD 68 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 69 <html lang="en"> 70 <head> 71 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 72 </head> 73 <body> 74 <h3>This is h3</h3> 75 <h1>This is h1</h1> 76 </body> 77 </html> 78 EOD; 79 80 /** @var string Html pass 2 */ 81 private $htmlpass2 = <<<EOD 82 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 83 <html lang="en"> 84 <head> 85 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 86 </head> 87 <body> 88 <h3>This is h3</h3> 89 <h2>This is h2</h2> 90 </body> 91 </html> 92 EOD; 93 94 /** @var string Html pass 3 */ 95 private $htmlpass3 = <<<EOD 96 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 97 <html lang="en"> 98 <head> 99 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 100 </head> 101 <body> 102 <h3>This is h3</h3> 103 <h3>This is h3</h3> 104 </body> 105 </html> 106 EOD; 107 108 /** @var string Html pass 4 */ 109 private $htmlpass4 = <<<EOD 110 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd"> 111 <html lang="en"> 112 <head> 113 <title>The header following an h3 must be h1, h2, h3 or h4.</title> 114 </head> 115 <body> 116 <h3>This is h3</h3> 117 <h4>This is h4</h4> 118 </body> 119 </html> 120 EOD; 121 122 /** 123 * Test the header following an h3 must be h1, h2, h3 or h4. 124 */ 125 public function test_check() { 126 $results = $this->get_checker_results($this->htmlfail1); 127 $this->assertTrue($results[0]->element->tagName == 'h5'); 128 129 $results = $this->get_checker_results($this->htmlfail2); 130 $this->assertTrue($results[0]->element->tagName == 'h6'); 131 132 $results = $this->get_checker_results($this->htmlpass1); 133 $this->assertEmpty($results); 134 135 $results = $this->get_checker_results($this->htmlpass3); 136 $this->assertEmpty($results); 137 138 $results = $this->get_checker_results($this->htmlpass3); 139 $this->assertEmpty($results); 140 141 $results = $this->get_checker_results($this->htmlpass4); 142 $this->assertEmpty($results); 143 } 144 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body