I want to test this very simple page generated by my PHP/Symfony project
<div>Simple ! Tranquille ! Excellent !</div>
(It's in French, so it needs the
hard spaces in front of the exclamation points.)
I thought an equally simple test such as
$this->assertSelectorTextContains('div', 'Simple ! Tranquille ! Excellent !');
would do the trick, but I get a failure.
Further inquiry shows that
$texte = $crawler->filter("div")->first();
$this->assertEquals($texte->text(), "Simple ! Tranquille ! Excellent !");
returns
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Simple ! Tranquille ! Excellent !'
+'Simple ! Tranquille ! Excellent !'
So, how do I help assertSelectorTextContains()
(and more generally, PHPUnit) understand that both strings are actually the same? (Or at least equivalent?)
Changing my search criteria yielded the answer,
html_entity_decode()
:does the job.