php-src/ext/tidy/tests/tidy_error1.phpt
Gina Peter Banyard 0a130caf58 ext/tidy: refactor php_tidy_set_tidy_opt()
Bring closer to unique call site and return value of it
2025-07-18 13:21:56 +01:00

57 lines
1.5 KiB
PHP

--TEST--
Notice triggered by invalid configuration options
--CREDITS--
Christian Wenz <wenz@php.net>
--EXTENSIONS--
tidy
--FILE--
<?php
$buffer = '<html></html>';
$config = ['bogus' => 'willnotwork'];
$tidy = new tidy();
try {
$tidy->parseString($buffer, $config);
} catch (\ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
$config = ['neither'];
try {
$tidy->parseString($buffer, $config);
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
$config = ['doctype-mode' => 'customtag'];
try {
var_dump($tidy->parseString($buffer, $config));
} catch (\ValueError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
$config = ['doctype' => 'php'];
try {
var_dump($tidy->parseString($buffer, $config));
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
$config = ['doctype' => 'auto', 0 => 'value2'];
try {
var_dump($tidy->parseString($buffer, $config));
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: tidy::parseString(): Argument #2 ($config) Unknown Tidy configuration option "bogus"
TypeError: tidy::parseString(): Argument #2 ($config) must be of type array with keys as string
ValueError: tidy::parseString(): Argument #2 ($config) Attempting to set read-only option "doctype-mode"
TypeError: tidy::parseString(): Argument #2 ($config) option "doctype" does not accept "php" as a value
TypeError: tidy::parseString(): Argument #2 ($config) must be of type array with keys as string