Skip to content

Commit 7f84298

Browse files
committed
ensure pass $this->dom->documentElement on dom->saveHTML()
1 parent e93e164 commit 7f84298

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

system/Test/DOMParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct()
7676
*/
7777
public function getBody(): string
7878
{
79-
return $this->dom->saveHTML();
79+
return $this->dom->saveHTML($this->dom->documentElement);
8080
}
8181

8282
/**
@@ -142,8 +142,8 @@ public function see(string $search = null, string $element = null): bool
142142
// If Element is null, we're just scanning for text
143143
if (is_null($element))
144144
{
145-
$content = $this->dom->saveHTML();
146-
return mb_strpos($content, $search) !== false;
145+
$content = $this->dom->saveHTML($this->dom->documentElement);
146+
return strpos($content, $search) !== false;
147147
}
148148

149149
$result = $this->doXPath($search, $element);

tests/system/Test/DOMParserTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,25 @@ public function testParseSelectorWithAttribute()
6666
$this->assertEquals(['href' => 'http://example.com'], $selector['attr']);
6767
}
6868

69-
public function testSeeText()
69+
public function provideText()
70+
{
71+
return [
72+
['Hello World'],
73+
['Hellö Wörld'],
74+
];
75+
}
76+
77+
/**
78+
* @dataProvider provideText
79+
*/
80+
public function testSeeText($text)
7081
{
7182
$dom = new DOMParser();
7283

73-
$html = '<html><body><h1>Hello World</h1></body></html>';
84+
$html = '<html><body><h1>' . $text . '</h1></body></html>';
7485
$dom->withString($html);
7586

76-
$this->assertTrue($dom->see('Hello World'));
87+
$this->assertTrue($dom->see($text));
7788
}
7889

7990
public function testSeeHTML()

0 commit comments

Comments
 (0)