mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
Merge branch 'MDL-75724-master_toolbrickfield_tableheadercheck' of https://github.com/brickfield/moodle
This commit is contained in:
commit
70a1139c4e
2 changed files with 127 additions and 2 deletions
|
@ -46,7 +46,7 @@ class table_data_should_have_th extends brickfield_accessibility_table_test {
|
||||||
foreach ($tr->childNodes as $th) {
|
foreach ($tr->childNodes as $th) {
|
||||||
if ($this->property_is_equal($th, 'tagName', 'th')) {
|
if ($this->property_is_equal($th, 'tagName', 'th')) {
|
||||||
break 3;
|
break 3;
|
||||||
} else {
|
} else if ($th->nodeName !== '#text') {
|
||||||
$this->add_report($table);
|
$this->add_report($table);
|
||||||
break 3;
|
break 3;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class table_data_should_have_th extends brickfield_accessibility_table_test {
|
||||||
foreach ($child->childNodes as $th) {
|
foreach ($child->childNodes as $th) {
|
||||||
if ($this->property_is_equal($th, 'tagName', 'th')) {
|
if ($this->property_is_equal($th, 'tagName', 'th')) {
|
||||||
break 2;
|
break 2;
|
||||||
} else {
|
} else if ($th->nodeName !== '#text') {
|
||||||
$this->add_report($table);
|
$this->add_report($table);
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ require_once('all_checks.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class table_data_should_have_th_test
|
* Class table_data_should_have_th_test
|
||||||
|
*
|
||||||
|
* @covers \tool_brickfield\local\htmlchecker\common\checks\table_data_should_have_th
|
||||||
*/
|
*/
|
||||||
class table_data_should_have_th_test extends all_checks {
|
class table_data_should_have_th_test extends all_checks {
|
||||||
/** @var string Check type */
|
/** @var string Check type */
|
||||||
|
@ -113,6 +115,117 @@ EOD;
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
/** @var string HTML that should not get flagged. */
|
||||||
|
private $htmlpass3 = <<<EOD
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Table should have at least one th - pass</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
This is table heading
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
This is a tables data
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
/** @var string HTML that should not get flagged. */
|
||||||
|
private $htmlpass4 = <<<EOD
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Table should have at least one th - pass</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
This is table heading
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
This is a tables data
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
/** @var string HTML that should not get flagged. */
|
||||||
|
private $htmlpass5 = <<<EOD
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Table should have at least one th - pass</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
This is table heading
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
This is a table heading in table data
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
This is a tables data
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
/** @var string HTML that should not get flagged. */
|
||||||
|
private $htmlpass6 = <<<EOD
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Table should have at least one th - pass</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
This is a table heading in table data
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
This is a tables data
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
EOD;
|
EOD;
|
||||||
/**
|
/**
|
||||||
* Test that th does not exist
|
* Test that th does not exist
|
||||||
|
@ -134,5 +247,17 @@ EOD;
|
||||||
|
|
||||||
$results = $this->get_checker_results($this->htmlpass2);
|
$results = $this->get_checker_results($this->htmlpass2);
|
||||||
$this->assertEmpty($results);
|
$this->assertEmpty($results);
|
||||||
|
|
||||||
|
$results = $this->get_checker_results($this->htmlpass3);
|
||||||
|
$this->assertEmpty($results);
|
||||||
|
|
||||||
|
$results = $this->get_checker_results($this->htmlpass4);
|
||||||
|
$this->assertEmpty($results);
|
||||||
|
|
||||||
|
$results = $this->get_checker_results($this->htmlpass5);
|
||||||
|
$this->assertEmpty($results);
|
||||||
|
|
||||||
|
$results = $this->get_checker_results($this->htmlpass6);
|
||||||
|
$this->assertEmpty($results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue