1 |
efrain |
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 content_too_long_testcase
|
|
|
33 |
*/
|
|
|
34 |
class content_too_long_test extends all_checks {
|
|
|
35 |
/** @var string Check type */
|
|
|
36 |
protected $checktype = 'content_too_long';
|
|
|
37 |
|
|
|
38 |
/** @var string Html fail */
|
|
|
39 |
private $htmlfail = <<<EOD
|
|
|
40 |
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent accumsan, ante varius viverra aliquam, dolor risus
|
|
|
41 |
scelerisque massa, ut lacinia ipsum felis id est. Nullam convallis odio ante, in commodo elit fermentum sed. Vivamus ullamcorper
|
|
|
42 |
tincidunt sagittis. Sed et semper sapien. Quisque malesuada lacus nec libero cursus, aliquam malesuada neque ultricies. Cras sit
|
|
|
43 |
amet enim vel orci tristique porttitor a vitae urna. Suspendisse mi leo, hendrerit et eleifend a, mollis at ex. Maecenas eget
|
|
|
44 |
magna nec sem dignissim pharetra vel nec ex. Donec in porta lectus. Aenean porttitor euismod lectus, sodales eleifend ex egestas
|
|
|
45 |
in. Donec sed metus sodales, lobortis velit quis, dictum arcu.</span></p>
|
|
|
46 |
<p><span>Praesent mollis urna eget odio cursus, sit amet sollicitudin ante aliquam. Integer nec massa nec ipsum tincidunt
|
|
|
47 |
laoreet in vitae metus.
|
|
|
48 |
Integer massa lacus, elementum quis dui sed, eleifend fringilla turpis. In hac habitasse platea dictumst. Phasellus
|
|
|
49 |
efficitur quis felis non eleifend. Sed et mauris vel lorem ultrices porta. Mauris commodo condimentum felis, vel dictum ex
|
|
|
50 |
laoreet sit amet. Duis venenatis ut lacus non ultrices. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
|
|
|
51 |
inceptos himenaeos. Nam nunc magna, semper feugiat feugiat a, pellentesque vel nulla.
|
|
|
52 |
Sed lacinia nunc lobortis, vestibulum nisi dictum, pulvinar tellus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
|
|
|
53 |
sodales, mauris vitae vulputate porttitor, urna tellus tempor turpis, sed hendrerit metus turpis at est. Etiam augue purus,
|
|
|
54 |
blandit eget elit sit amet, suscipit mollis ligula. Suspendisse rutrum sem ex, eu commodo nisi aliquam sit amet. Fusce ut felis
|
|
|
55 |
justo. Sed a quam at lectus consectetur vulputate. Proin elementum dui nisi, in condimentum diam porttitor eget. Donec vehicula
|
|
|
56 |
condimentum velit vel semper. Mauris vehicula tortor lectus, quis convallis erat aliquet vel. In dictum nunc ac posuere porta.
|
|
|
57 |
Sed vel leo aliquam, volutpat ligula ac, blandit diam. Donec nec ligula lacus.</span></p>
|
|
|
58 |
<p><span>Mauris ac libero vel ex fringilla fringilla. Ut vehicula justo eu nunc imperdiet ultricies. Sed interdum ligula at nisi
|
|
|
59 |
rhoncus auctor.
|
|
|
60 |
Sed tempus tellus eget risus placerat, et viverra dolor gravida. Sed ultricies neque id ex tempor viverra. Ut imperdiet
|
|
|
61 |
pharetra magna sed tristique. Pellentesque blandit elit ac neque lacinia finibus. Lorem ipsum dolor sit amet, consectetur
|
|
|
62 |
adipiscing elit. Donec vel auctor dolor. Morbi id elit mollis ante mattis semper eu ac lectus. Integer elit turpis, facilisis
|
|
|
63 |
vel metus eget, blandit tempus arcu. Pellentesque eget magna eu ex eleifend tincidunt. Curabitur sit amet congue nisi.
|
|
|
64 |
Cras mauris risus, malesuada egestas dapibus et, pharetra in ante. Aenean sit amet augue non ligula tempor scelerisque eget ac
|
|
|
65 |
turpis. Aenean tincidunt tristique dui, pretium lacinia felis posuere vel. Donec massa ligula, luctus vitae enim nec, sagittis
|
|
|
66 |
hendrerit lorem. In consequat sodales metus vel porttitor. Aenean fringilla fringilla risus, vitae interdum turpis egestas quis.
|
|
|
67 |
Aenean volutpat arcu leo, ut dictum purus consectetur id. Cras enim ipsum, tincidunt vitae mi vel, varius convallis ex. Fusce
|
|
|
68 |
pretium porttitor tempus.</span></p>
|
|
|
69 |
<p>Morbi laoreet dapibus lectus ut efficitur. Donec at hendrerit nunc. Vivamus venenatis augue non nulla finibus vestibulum. Nam
|
|
|
70 |
nunc magna, hendrerit a ipsum nec, pulvinar imperdiet augue. Fusce vel metus maximus, mattis magna at, egestas enim. Suspendisse
|
|
|
71 |
et nisl at enim mollis scelerisque. Duis ut ipsum vel turpis eleifend aliquet a a ante. Nam lacinia purus vulputate purus
|
|
|
72 |
tincidunt, aliquet sagittis nisi sagittis. Pellentesque efficitur massa non ex sodales pretium. Cras convallis vitae ex et
|
|
|
73 |
dignissim. Nunc suscipit bibendum aliquam. Maecenas interdum tellus varius, laoreet velit sed, ornare arcu. Nunc pulvinar
|
|
|
74 |
elementum sem eget scelerisque. Duis volutpat tellus ut risus finibus, nec molestie erat fermentum
|
|
|
75 |
</p>
|
|
|
76 |
EOD;
|
|
|
77 |
|
|
|
78 |
/** @var string Multibyte html falure */
|
|
|
79 |
private $htmlfail2 = <<<EOD
|
|
|
80 |
<p><span>ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
81 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
82 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
83 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
84 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
85 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
86 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
87 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
88 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
89 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
90 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
91 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
92 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
93 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
94 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
95 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
96 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
97 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
98 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
99 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
100 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
101 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
102 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
103 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
104 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
105 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
106 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
107 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
108 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
109 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
110 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
111 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
112 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
113 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
114 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
115 |
ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル ブルース カンベッル
|
|
|
116 |
</span></p>
|
|
|
117 |
EOD;
|
|
|
118 |
|
|
|
119 |
/** @var string Html pass */
|
|
|
120 |
private $htmlpass = <<<EOD
|
|
|
121 |
<p>Nice and short text</p>
|
|
|
122 |
EOD;
|
|
|
123 |
|
|
|
124 |
/**
|
|
|
125 |
* Test for checking the length of the content
|
|
|
126 |
*/
|
11 |
efrain |
127 |
public function test_check(): void {
|
1 |
efrain |
128 |
$results = $this->get_checker_results($this->htmlfail);
|
|
|
129 |
$this->assertTrue($results[0]->message == '<p id=\'wc\'>Word Count: 578</p>');
|
|
|
130 |
|
|
|
131 |
$results = $this->get_checker_results($this->htmlfail2);
|
|
|
132 |
$this->assertTrue($results[0]->message == '<p id=\'wc\'>Word Count: 504</p>');
|
|
|
133 |
|
|
|
134 |
$results = $this->get_checker_results($this->htmlpass);
|
|
|
135 |
$this->assertEmpty($results);
|
|
|
136 |
}
|
|
|
137 |
}
|