' . "\n" . 'TestPage
' . "\n"; $doc = $json->toDOM( $API, $pageContent ); $response = $doc->saveHTML(); $this->assertSame( $expected, $response ); // Test complex nested JSON object using string matching $pageContent = '{"array":[{"foo":"bar","key":["string1",null,false,true,0,1,123,456.789]}]}'; $expected = '' . "\n" . 'TestPage
array
foobar
key
string1
null
false
true
0
1
123
456.789
' . "\n"; $doc = $json->toDOM( $API, $pageContent ); $response = $doc->saveHTML(); $this->assertSame( $expected, $response ); } /** * Create a DOM document using HTML and convert that to JSON and verify correctness * @covers \Wikimedia\Parsoid\Ext\JSON\JSON::fromDOM */ public function testFromDOM() { $opts = []; $env = new MockEnv( $opts ); $API = new ParsoidExtensionAPI( $env ); $json = new JSON(); $html = '' . "\n" . '
' . 'array
' . '' . '' . '' . '
foobar
key' . '' . '' . '' . '' . '' . '' . '' . '
string1
null
false
true
0
1
123
456.789
' . "\n"; $expected = '{"array":[{"foo":"bar","key":["string1",null,false,true,0,1,123,456.789]}]}'; $doc = new DOMDocument(); $doc->loadHTML( $html ); $response = $json->fromDOM( $API, $doc ); $this->assertSame( $expected, $response ); } }