diff --git a/tests/HtmlDomParserTest.php b/tests/HtmlDomParserTest.php index 5cdc7b8..14efb1f 100644 --- a/tests/HtmlDomParserTest.php +++ b/tests/HtmlDomParserTest.php @@ -1976,4 +1976,41 @@ public function testIssue42() $d->loadHtml('

p1

'); static::assertSame('

p1

', (string) $d); } + + public function testFindClassTest() + { + $html = " +
or +
or +
+ "; + + $d = new voku\helper\HtmlDomParser(); + $d->load($html); + + $htmlResult = ''; + foreach ($d->find('.services') as $e) { + $e->setAttribute('data-foo', 'bar'); + $htmlResult .= $e->html(); + }; + + $htmlExpected = '
'; + + static::assertSame($htmlExpected, $htmlResult); + + // --- + + $d = new voku\helper\HtmlDomParser(); + $d->load($html); + + $htmlResult = ''; + foreach ($d->find('div[class~=services]') as $e) { + $e->setAttribute('data-foo', 'bar'); + $htmlResult .= $e->html(); + }; + + $htmlExpected = '
'; + + static::assertSame($htmlExpected, $htmlResult); + } }