constraint = new Codeception\PHPUnit\Constraint\CrawlerNot('warcraft', '/user'); } public function testEvaluation() { $nodes = new Symfony\Component\DomCrawler\Crawler("

Bye world

Hello world

"); $this->constraint->evaluate($nodes); } public function testFailMessageResponse() { $nodes = new Symfony\Component\DomCrawler\Crawler('

Bye world

Bye warcraft

'); try { $this->constraint->evaluate($nodes->filter('p'), 'selector'); } catch (\PHPUnit\Framework\AssertionFailedError $fail) { $this->assertContains("There was 'selector' element on page /user", $fail->getMessage()); $this->assertNotContains('+

Bye world

', $fail->getMessage()); $this->assertContains('+

Bye warcraft

', $fail->getMessage()); return; } $this->fail("should have failed, but not"); } public function testFailMessageResponseWhenMoreNodes() { $html = ''; for ($i = 0; $i < 15; $i++) { $html .= "

warcraft $i

"; } $nodes = new Symfony\Component\DomCrawler\Crawler($html); try { $this->constraint->evaluate($nodes->filter('p'), 'selector'); } catch (\PHPUnit\Framework\AssertionFailedError $fail) { $this->assertContains("There was 'selector' element on page /user", $fail->getMessage()); $this->assertContains('+

warcraft 0

', $fail->getMessage()); $this->assertContains('+

warcraft 14

', $fail->getMessage()); return; } $this->fail("should have failed, but not"); } public function testFailMessageResponseWithoutUrl() { $this->constraint = new Codeception\PHPUnit\Constraint\CrawlerNot('warcraft'); $nodes = new Symfony\Component\DomCrawler\Crawler('

Bye world

Bye warcraft

'); try { $this->constraint->evaluate($nodes->filter('p'), 'selector'); } catch (\PHPUnit\Framework\AssertionFailedError $fail) { $this->assertContains("There was 'selector' element", $fail->getMessage()); $this->assertNotContains("There was 'selector' element on page /user", $fail->getMessage()); return; } $this->fail("should have failed, but not"); } }