use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestFailure;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler\Test\Constraint\CrawlerAnySelectorTextContains;
class CrawlerAnySelectorTextContainsTest extends TestCase
{ public function testConstraint() { $constraint =
new CrawlerAnySelectorTextContains('ul li', 'Foo'
);
self::
assertTrue($constraint->
evaluate(new Crawler('<ul><li>Foo</li>'
), '', true
));
self::
assertTrue($constraint->
evaluate(new Crawler('<ul><li>Bar</li><li>Foo'
), '', true
));
self::
assertTrue($constraint->
evaluate(new Crawler('<ul><li>Bar</li><li>Foo Bar Baz'
), '', true
));
self::
assertFalse($constraint->
evaluate(new Crawler('<ul><li>Bar</li><li>Baz'
), '', true
));
try { $constraint->
evaluate(new Crawler('<ul><li>Bar</li><li>Baz'
));
self::
fail();
} catch (ExpectationFailedException
$e) {