diff --git a/src/testing/MD_STD_HTML_TEST.php b/src/testing/MD_STD_HTML_TEST.php new file mode 100644 index 0000000..5b29bab --- /dev/null +++ b/src/testing/MD_STD_HTML_TEST.php @@ -0,0 +1,36 @@ + + */ +declare(strict_types = 1); + +use PHPUnit\Framework\TestCase; + + +/** + * Tests for the manifest. + */ +abstract class MD_STD_HTML_TEST extends TestCase { + /** + * Validates HTML strings. + * + * @param string $input Input string to validate. + * + * @return void + */ + protected static function validateHtmlString(string $input):void { + + self::assertNotEmpty($input); + + libxml_use_internal_errors(true); + $xml = simplexml_load_string('' . trim(strtr($input, [' async' => ' ', ' defer' => ' '])) . ''); + if (!empty($errors = libxml_get_errors())) { + throw new Exception("Invalid HTML code detected: " . var_export($errors, true) . PHP_EOL . PHP_EOL . $input); + } + + self::assertNotEquals(null, $xml); + + } +}