Closed
Description
Symfony version(s) affected
5.4
Description
The test case for this method basically is:
<div id="complex-element">
Parent text
<span>Child text</span>
</div>
Getting $crawler->text()
then returns Parent text Child text
and $crawler->innerText()
returns Parent text
. So far, so good.
If I don't misunderstand anything, in case of:
<div id="complex-element">
Parent text
<span>Child text</span>
More parent text
</div>
the return value of $crawler->innerText()
should be Parent text More parent text
. But it's still just Parent text
.
I'll provide a pull request to fix this in a minute.
How to reproduce
In the Tests/AbstractCrawlerTest.php
test file, adapt the HTML in the createTestCrawler()
method from:
<div id="complex-element">
Parent text
<span>Child text</span>
</div>
to
<div id="complex-element">
Parent text
<span>Child text</span>
More parent text
</div>
And the testInnerText()
method accordingly to:
public function testInnerText()
{
self::assertCount(1, $crawler = $this->createTestCrawler()->filterXPath('//*[@id="complex-element"]'));
self::assertSame('Parent text Child text More parent text', $crawler->text());
self::assertSame('Parent text More parent text', $crawler->innerText());
}
Possible Solution
Additional Context
No response