| Línea 28... |
Línea 28... |
| 28 |
|
28 |
|
| Línea 29... |
Línea 29... |
| 29 |
require_once('all_checks.php');
|
29 |
require_once('all_checks.php');
|
| 30 |
|
30 |
|
| - |
|
31 |
/**
|
| 31 |
/**
|
32 |
* Class test_css_text_has_contrast_test
|
| 32 |
* Class test_css_text_has_contrast_test
|
33 |
* @covers \tool_brickfield\local\htmlchecker\brickfield_accessibility
|
| 33 |
*/
|
34 |
*/
|
| 34 |
class css_text_has_contrast_test extends all_checks {
|
35 |
final class css_text_has_contrast_test extends all_checks {
|
| Línea 35... |
Línea 36... |
| 35 |
/** @var string The check type. */
|
36 |
/** @var string The check type. */
|
| 36 |
protected $checktype = 'css_text_has_contrast';
|
37 |
protected $checktype = 'css_text_has_contrast';
|
| Línea 224... |
Línea 225... |
| 224 |
private $largerboldpass = <<<EOD
|
225 |
private $largerboldpass = <<<EOD
|
| 225 |
<body><p style="color:#FF5C5C; background-color:white; font-size: larger; font-weight: bold;">
|
226 |
<body><p style="color:#FF5C5C; background-color:white; font-size: larger; font-weight: bold;">
|
| 226 |
This is contrasty enough.</p></body>
|
227 |
This is contrasty enough.</p></body>
|
| 227 |
EOD;
|
228 |
EOD;
|
| Línea -... |
Línea 229... |
| - |
|
229 |
|
| - |
|
230 |
/** @var string HTML with calculated size colour values. */
|
| - |
|
231 |
private $calculatedfail = <<<EOD
|
| - |
|
232 |
<body><p style="color:#EF0000; background-color:white; font-size: calc(0.90375rem + 0.045vw)">
|
| - |
|
233 |
This is not contrasty enough.</p></body>
|
| - |
|
234 |
EOD;
|
| - |
|
235 |
|
| - |
|
236 |
/** @var string HTML with calculated size colour values. */
|
| - |
|
237 |
private $calculatedpass = <<<EOD
|
| - |
|
238 |
<body><p style="color:#E60000; background-color:white; font-size: calc(0.90375rem + 0.045vw);">
|
| - |
|
239 |
This is contrasty enough.</p></body>
|
| - |
|
240 |
EOD;
|
| 228 |
|
241 |
|
| 229 |
/**
|
242 |
/**
|
| 230 |
* Test for the area assign intro
|
243 |
* Test for the area assign intro
|
| 231 |
*/
|
244 |
*/
|
| 232 |
public function test_check(): void {
|
245 |
public function test_check(): void {
|
| Línea 345... |
Línea 358... |
| 345 |
*/
|
358 |
*/
|
| 346 |
public function test_check_for_largerbold_pass(): void {
|
359 |
public function test_check_for_largerbold_pass(): void {
|
| 347 |
$results = $this->get_checker_results($this->largerboldpass);
|
360 |
$results = $this->get_checker_results($this->largerboldpass);
|
| 348 |
$this->assertEmpty($results);
|
361 |
$this->assertEmpty($results);
|
| 349 |
}
|
362 |
}
|
| - |
|
363 |
|
| - |
|
364 |
/**
|
| - |
|
365 |
* Test for rgb colors with insufficient contrast.
|
| - |
|
366 |
*/
|
| - |
|
367 |
public function test_bad_rgbcolor(): void {
|
| - |
|
368 |
$html = '<body><p style="color:rgb(255, 255, 255); background-color:rgb(204, 204, 204);">
|
| - |
|
369 |
This is not contrasty enough.</p></body>';
|
| - |
|
370 |
$results = $this->get_checker_results($html);
|
| - |
|
371 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
372 |
}
|
| - |
|
373 |
|
| - |
|
374 |
/**
|
| - |
|
375 |
* Test for rgb colors with sufficient contrast.
|
| - |
|
376 |
*/
|
| - |
|
377 |
public function test_good_rgbcolor(): void {
|
| - |
|
378 |
$html = '<body><p style="color:rgb(255, 255, 255); background-color:rgb(0, 0, 0);">
|
| - |
|
379 |
This is contrasty enough.</p></body>';
|
| - |
|
380 |
$results = $this->get_checker_results($html);
|
| - |
|
381 |
$this->assertEmpty($results);
|
| - |
|
382 |
}
|
| - |
|
383 |
|
| - |
|
384 |
/**
|
| - |
|
385 |
* Test for named colors with insufficient contrast.
|
| - |
|
386 |
*/
|
| - |
|
387 |
public function test_bad_namedcolor2(): void {
|
| - |
|
388 |
$html = '<body><p style="color:lightcyan; background-color:lavender;">
|
| - |
|
389 |
This is not contrasty enough.</p></body>';
|
| - |
|
390 |
$results = $this->get_checker_results($html);
|
| - |
|
391 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
392 |
}
|
| - |
|
393 |
|
| - |
|
394 |
/**
|
| - |
|
395 |
* Test for named colors with sufficient contrast.
|
| - |
|
396 |
*/
|
| - |
|
397 |
public function test_good_namedcolor2(): void {
|
| - |
|
398 |
$html = '<body><p style="color:linen; background-color:darkslategray;">
|
| - |
|
399 |
This is contrasty enough.</p></body>';
|
| - |
|
400 |
$results = $this->get_checker_results($html);
|
| - |
|
401 |
$this->assertEmpty($results);
|
| - |
|
402 |
}
|
| - |
|
403 |
|
| - |
|
404 |
/**
|
| - |
|
405 |
* Test for background value with insufficient contrast.
|
| - |
|
406 |
*/
|
| - |
|
407 |
public function test_bad_backgroundcss(): void {
|
| - |
|
408 |
$html = '<body><p style="color:lightcyan; background:fixed lavender center;">
|
| - |
|
409 |
This is not contrasty enough.</p></body>';
|
| - |
|
410 |
$results = $this->get_checker_results($html);
|
| - |
|
411 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
412 |
}
|
| - |
|
413 |
|
| - |
|
414 |
/**
|
| - |
|
415 |
* Test for background value with sufficient contrast.
|
| - |
|
416 |
*/
|
| - |
|
417 |
public function test_good_backgroundcss(): void {
|
| - |
|
418 |
$html = '<body><p style="color:linen; background:fixed darkslategray center;">
|
| - |
|
419 |
This is contrasty enough.</p></body>';
|
| - |
|
420 |
$results = $this->get_checker_results($html);
|
| - |
|
421 |
$this->assertEmpty($results);
|
| - |
|
422 |
}
|
| - |
|
423 |
|
| - |
|
424 |
/**
|
| - |
|
425 |
* Test for background value with rgb with insufficient contrast.
|
| - |
|
426 |
*/
|
| - |
|
427 |
public function test_bad_backgroundcssrgb(): void {
|
| - |
|
428 |
$html = '<body><p style="color:rgb(255, 255, 255); background:fixed rgb(204, 204, 204) center;">
|
| - |
|
429 |
This is not contrasty enough.</p></body>';
|
| - |
|
430 |
$results = $this->get_checker_results($html);
|
| - |
|
431 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
432 |
}
|
| - |
|
433 |
|
| - |
|
434 |
/**
|
| - |
|
435 |
* Test for background value with rgb with sufficient contrast.
|
| - |
|
436 |
*/
|
| - |
|
437 |
public function test_good_backgroundcssrgb(): void {
|
| - |
|
438 |
$html = '<body><p style="color:rgb(255, 255, 255); background:fixed rgb(0, 0, 0) center;">
|
| - |
|
439 |
This is contrasty enough.</p></body>';
|
| - |
|
440 |
$results = $this->get_checker_results($html);
|
| - |
|
441 |
$this->assertEmpty($results);
|
| - |
|
442 |
}
|
| - |
|
443 |
|
| - |
|
444 |
/**
|
| - |
|
445 |
* Test for text with insufficient contrast of 4.3.
|
| - |
|
446 |
*/
|
| - |
|
447 |
public function test_bad_contrastrounding(): void {
|
| - |
|
448 |
$html = '<body><p style="color:#F50000; background-color:white; font-size: 12px">
|
| - |
|
449 |
This is not contrasty enough.</p></body>';
|
| - |
|
450 |
$results = $this->get_checker_results($html);
|
| - |
|
451 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
452 |
}
|
| - |
|
453 |
|
| - |
|
454 |
/**
|
| - |
|
455 |
* Test for background value with rgba with insufficient contrast.
|
| - |
|
456 |
*/
|
| - |
|
457 |
public function test_bad_backgroundcssrgba(): void {
|
| - |
|
458 |
$html = '<body><p style="color:rgba(255, 255, 255, 0.5); background:fixed rgba(0, 204, 204, 0.5) center;">
|
| - |
|
459 |
This is not contrasty enough.</p></body>';
|
| - |
|
460 |
$results = $this->get_checker_results($html);
|
| - |
|
461 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
462 |
}
|
| - |
|
463 |
|
| - |
|
464 |
/**
|
| - |
|
465 |
* Test for background value with rgba with sufficient contrast.
|
| - |
|
466 |
*/
|
| - |
|
467 |
public function test_good_backgroundcssrgba(): void {
|
| - |
|
468 |
$html = '<body><p style="color:rgba(255, 255, 255, 0.75); background:fixed rgba(0, 0, 0, 0.75) center;">
|
| - |
|
469 |
This is contrasty enough.</p></body>';
|
| - |
|
470 |
$results = $this->get_checker_results($html);
|
| - |
|
471 |
$this->assertEmpty($results);
|
| - |
|
472 |
}
|
| - |
|
473 |
|
| - |
|
474 |
/**
|
| - |
|
475 |
* Test for calculated (12pt) text with insufficient contrast of 4.49.
|
| - |
|
476 |
*/
|
| - |
|
477 |
public function test_check_for_calculated_fail(): void {
|
| - |
|
478 |
$results = $this->get_checker_results($this->calculatedfail);
|
| - |
|
479 |
$this->assertTrue($results[0]->element->tagName == 'p');
|
| - |
|
480 |
}
|
| - |
|
481 |
|
| - |
|
482 |
/**
|
| - |
|
483 |
* Test for calculated (12pt) text with sufficient contrast of 4.81.
|
| - |
|
484 |
*/
|
| - |
|
485 |
public function test_check_for_calculated_pass(): void {
|
| - |
|
486 |
$results = $this->get_checker_results($this->calculatedpass);
|
| - |
|
487 |
$this->assertEmpty($results);
|
| - |
|
488 |
}
|
| 350 |
}
|
489 |
}
|