Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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 table_td_should_not_merge_test
  33   */
  34  class table_td_should_not_merge_test extends all_checks {
  35      /** @var string Check type */
  36      public $checktype = 'table_td_should_not_merge';
  37  
  38      /** @var string Html fail 1 */
  39      private $htmlfail1 = <<<EOD
  40  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  41  <html>
  42      <head>
  43          <title>Rowspan exists - fail</title>
  44      </head>
  45      <body>
  46          <table>
  47              <thead>
  48                  <tr>
  49                      <th>1</th>
  50                  </tr>
  51              </thead>
  52              <tbody>
  53                  <tr>
  54                      <td>2</td>
  55                      <td rowspan="2">3</td>
  56                  </tr>
  57                  <tr>
  58                      <td>4</td>
  59                      <td>5</td>
  60                  </tr>
  61              </tbody>
  62          </table>
  63      </body>
  64  </html>
  65  EOD;
  66  
  67      /** @var string Html fail 2 */
  68      private $htmlfail2 = <<<EOD
  69  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  70  <html>
  71      <head>
  72          <title>Colspan exists - fail</title>
  73      </head>
  74      <body>
  75          <table>
  76              <thead>
  77                  <tr>
  78                      <th>1</th>
  79                  </tr>
  80              </thead>
  81              <tbody>
  82                  <tr>
  83                      <td>2</td>
  84                      <td colspan="2">3</td>
  85                  </tr>
  86                  <tr>
  87                      <td>4</td>
  88                      <td>5</td>
  89                  </tr>
  90              </tbody>
  91          </table>
  92      </body>
  93  </html>
  94  EOD;
  95  
  96      /** @var string Html pass */
  97      private $htmlpass = <<<EOD
  98  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  99  <html>
 100      <head>
 101          <title>colspan or rowspan do not exist - pass</title>
 102      </head>
 103      <body>
 104          <table>
 105              <thead>
 106                  <tr>
 107                      <th>1</th>
 108                  </tr>
 109              </thead>
 110              <tbody>
 111                  <tr>
 112                      <td>2</td>
 113                      <td>3</td>
 114                  </tr>
 115                  <tr>
 116                      <td>4</td>
 117                      <td>5</td>
 118                  </tr>
 119              </tbody>
 120          </table>
 121      </body>
 122  </html>
 123  EOD;
 124  
 125      /**
 126       * Test for rowspan and colspan
 127       */
 128      public function test_check_fail() {
 129          $results = $this->get_checker_results($this->htmlfail1);
 130          $this->assertNotEmpty($results);
 131  
 132          $results = $this->get_checker_results($this->htmlfail2);
 133          $this->assertNotEmpty($results);
 134      }
 135  
 136      /**
 137       * Test for rowspan and colspan
 138       */
 139      public function test_check_pass() {
 140          $results = $this->get_checker_results($this->htmlpass);
 141          $this->assertEmpty($results);
 142      }
 143  }