1--TEST--
2Dom\HTMLDocument test values for encoding field
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\HTMLDocument::createEmpty();
9var_dump($dom->charset);
10$dom->inputEncoding = "CSeuckr";
11var_dump($dom->characterSet);
12try {
13    $dom->charset = "nope";
14} catch (ValueError $e) {
15    echo $e->getMessage(), "\n";
16}
17var_dump($dom->charset);
18$dom->inputEncoding = "Windows-1251";
19var_dump($dom->characterSet);
20try {
21    $dom->charset = "";
22} catch (ValueError $e) {
23    echo $e->getMessage(), "\n";
24}
25var_dump($dom->inputEncoding);
26echo $dom->saveHtml();
27
28try {
29    $dom = Dom\HTMLDocument::createEmpty("bogus");
30} catch (ValueError $e) {
31    echo $e->getMessage(), "\n";
32}
33
34?>
35--EXPECT--
36string(5) "UTF-8"
37string(6) "EUC-KR"
38Invalid document encoding
39string(6) "EUC-KR"
40string(12) "windows-1251"
41Invalid document encoding
42string(12) "windows-1251"
43Dom\HTMLDocument::createEmpty(): Argument #1 ($encoding) must be a valid document encoding
44