How can I safely check is node empty or not? (Symfony 2 Crawler)
Have you tried something like this?
$text = null;
if (!empty($body = $crawler->filter('.PropertyBody'))) {
if (!empty($node = $body->eq(2))) {
$text = $node->text();
}
}
$this->assertContains('yourText', $text);
$marks = $crawler->filter('.PropertyBody')->count()
? $crawler->filter('.PropertyBody')->eq(2)->text()
: '';