assertRegExp()
assertRegExp(string $pattern, string $string[, string $message = ''])
Reports an error identified by $message
if $string
does not match the regular expression $pattern
.
assertNotRegExp()
is the inverse of this assertion and takes the same arguments.
Example A.41: Usage of assertRegExp()
<?php use PHPUnit\Framework\TestCase; class RegExpTest extends TestCase { public function testFailure() { $this->assertRegExp('/foo/', 'bar'); } } ?>
phpunit RegExpTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 5.00Mb There was 1 failure: 1) RegExpTest::testFailure Failed asserting that 'bar' matches PCRE pattern "/foo/". /home/sb/RegExpTest.php:6 FAILURES! Tests: 1, Assertions: 1, Failures: 1.
Please login to continue.