assertStringStartsWith()

assertStringStartsWith() assertStringStartsWith(string $prefix, string $string[, string $message = '']) Reports an error identified by $message if the $string does not start with $prefix. assertStringStartsNotWith() is the inverse of this assertion and takes the same arguments. Example A.48: Usage of assertStringStartsWith() <?php use PHPUnit\Framework\TestCase; class StringStartsWithTest extends TestCase { public function testFailure() { $this->assertStringStartsWith('

assertStringMatchesFormatFile()

assertStringMatchesFormatFile() assertStringMatchesFormatFile(string $formatFile, string $string[, string $message = '']) Reports an error identified by $message if the $string does not match the contents of the $formatFile. assertStringNotMatchesFormatFile() is the inverse of this assertion and takes the same arguments. Example A.43: Usage of assertStringMatchesFormatFile() <?php use PHPUnit\Framework\TestCase; class StringMatchesFormatFileTest extends TestCase { public function test

assertStringMatchesFormat()

assertStringMatchesFormat() assertStringMatchesFormat(string $format, string $string[, string $message = '']) Reports an error identified by $message if the $string does not match the $format string. assertStringNotMatchesFormat() is the inverse of this assertion and takes the same arguments. Example A.42: Usage of assertStringMatchesFormat() <?php use PHPUnit\Framework\TestCase; class StringMatchesFormatTest extends TestCase { public function testFailure() { $this->ass

assertStringEqualsFile()

assertStringEqualsFile() assertStringEqualsFile(string $expectedFile, string $actualString[, string $message = '']) Reports an error identified by $message if the file specified by $expectedFile does not have $actualString as its contents. assertStringNotEqualsFile() is the inverse of this assertion and takes the same arguments. Example A.47: Usage of assertStringEqualsFile() <?php use PHPUnit\Framework\TestCase; class StringEqualsFileTest extends TestCase { public function testFailur

assertStringEndsWith()

assertStringEndsWith() assertStringEndsWith(string $suffix, string $string[, string $message = '']) Reports an error identified by $message if the $string does not end with $suffix. assertStringEndsNotWith() is the inverse of this assertion and takes the same arguments. Example A.46: Usage of assertStringEndsWith() <?php use PHPUnit\Framework\TestCase; class StringEndsWithTest extends TestCase { public function testFailure() { $this->assertStringEndsWith('suffix', 'foo'

assertSame()

assertSame() assertSame(mixed $expected, mixed $actual[, string $message = '']) Reports an error identified by $message if the two variables $expected and $actual do not have the same type and value. assertNotSame() is the inverse of this assertion and takes the same arguments. assertAttributeSame() and assertAttributeNotSame() are convenience wrappers that use a public, protected, or private attribute of a class or object as the actual value. Example A.44: Usage of assertSame() <?php use

assertRegExp()

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 RegExp

assertObjectHasAttribute()

assertObjectHasAttribute() assertObjectHasAttribute(string $attributeName, object $object[, string $message = '']) Reports an error identified by $message if $object->attributeName does not exist. assertObjectNotHasAttribute() is the inverse of this assertion and takes the same arguments. Example A.40: Usage of assertObjectHasAttribute() <?php use PHPUnit\Framework\TestCase; class ObjectHasAttributeTest extends TestCase { public function testFailure() { $this->assert

assertNull()

assertNull() assertNull(mixed $variable[, string $message = '']) Reports an error identified by $message if $variable is not null. assertNotNull() is the inverse of this assertion and takes the same arguments. Example A.39: Usage of assertNull() <?php use PHPUnit\Framework\TestCase; class NullTest extends TestCase { public function testFailure() { $this->assertNull('foo'); } } ?> phpunit NotNullTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time:

assertNan()

assertNan() assertNan(mixed $variable[, string $message = '']) Reports an error identified by $message if $variable is not NAN. Example A.38: Usage of assertNan() <?php use PHPUnit\Framework\TestCase; class NanTest extends TestCase { public function testFailure() { $this->assertNan(1); } } ?> phpunit NanTest PHPUnit 5.6.0 by Sebastian Bergmann and contributors. F Time: 0 seconds, Memory: 5.00Mb There was 1 failure: 1) NanTest::testFailure Failed asserting tha