File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ private function parseHtml( $html ) {
9595 * @throws Exception
9696 */
9797 private function getRootNode ( DOMDocument $ document ) {
98+ if ( $ document ->documentElement === null ) {
99+ throw new Exception ( 'Empty document ' );
100+ }
101+
98102 $ rootNodes = $ document ->documentElement ->childNodes ->item ( 0 )->childNodes ;
99103
100104 if ( $ rootNodes ->length > 1 ) {
Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ public function testJustASingleEmptyHtmlElement() {
1717 $ this ->assertSame ( '<div></div> ' , $ result );
1818 }
1919
20+ public function testTemplateHasNoRootNodes_ThrowsAnException (): void {
21+ $ this ->expectException ( Exception::class );
22+ $ this ->createAndRender ( '' , [] );
23+ }
24+
2025 public function testTemplateHasTwoRootNodes_ThrowsAnException () {
2126 $ this ->expectException ( Exception::class );
2227 $ this ->createAndRender ( '<p></p><p></p> ' , [] );
You can’t perform that action at this time.
0 commit comments