assertXmlStringEqualsXmlString()

assertXmlStringEqualsXmlString() assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml[, string $message = '']) Reports an error identified by $message if the XML document in $actualXml is not equal to the XML document in $expectedXml. assertXmlStringNotEqualsXmlString() is the inverse of this assertion and takes the same arguments. Example A.53: Usage of assertXmlStringEqualsXmlString() <?php use PHPUnit\Framework\TestCase; class XmlStringEqualsXmlStringTest extends TestC

assertClassHasStaticAttribute()

assertClassHasStaticAttribute() assertClassHasStaticAttribute(string $attributeName, string $className[, string $message = '']) Reports an error identified by $message if $className::attributeName does not exist. assertClassNotHasStaticAttribute() is the inverse of this assertion and takes the same arguments. Example A.4: Usage of assertClassHasStaticAttribute() <?php use PHPUnit\Framework\TestCase; class ClassHasStaticAttributeTest extends TestCase { public function testFailure()

assertEmpty()

assertEmpty() assertEmpty(mixed $actual[, string $message = '']) Reports an error identified by $message if $actual is not empty. assertNotEmpty() is the inverse of this assertion and takes the same arguments. assertAttributeEmpty() and assertAttributeNotEmpty() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object. Example A.14: Usage of assertEmpty() <?php use PHPUnit\Framework\TestCase; class EmptyTest extends TestCase { publ

assertCount()

assertCount() assertCount($expectedCount, $haystack[, string $message = '']) Reports an error identified by $message if the number of elements in $haystack is not $expectedCount. assertNotCount() is the inverse of this assertion and takes the same arguments. Example A.10: Usage of assertCount() <?php use PHPUnit\Framework\TestCase; class CountTest extends TestCase { public function testFailure() { $this->assertCount(0, ['foo']); } } ?> phpunit CountTest PHPUnit 5

@expectedExceptionMessage

@expectedExceptionMessage The @expectedExceptionMessage annotation works similar to @expectedExceptionCode as it lets you make an assertion on the error message of an exception. use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @expectedException MyException * @expectedExceptionMessage Some Message */ public function testExceptionHasRightMessage() { throw new MyException('Some Message', 20); } } The expected message can be a

assertContains()

assertContains() assertContains(mixed $needle, Iterator|array $haystack[, string $message = '']) Reports an error identified by $message if $needle is not an element of $haystack. assertNotContains() is the inverse of this assertion and takes the same arguments. assertAttributeContains() and assertAttributeNotContains() are convenience wrappers that use a public, protected, or private attribute of a class or object as the haystack. Example A.5: Usage of assertContains() <?php use PHPUnit\F

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'

assertIsWritable()

assertIsWritable() assertIsWritable(string $filename[, string $message = '']) Reports an error identified by $message if the file or directory specified by $filename is not writable. assertNotIsWritable() is the inverse of this assertion and takes the same arguments. Example A.32: Usage of assertIsWritable() <?php use PHPUnit\Framework\TestCase; class IsWritableTest extends TestCase { public function testFailure() { $this->assertIsWritable('/path/to/unwritable'); }

assertInstanceOf()

assertInstanceOf() assertInstanceOf($expected, $actual[, $message = '']) Reports an error identified by $message if $actual is not an instance of $expected. assertNotInstanceOf() is the inverse of this assertion and takes the same arguments. assertAttributeInstanceOf() and assertAttributeNotInstanceOf() are convenience wrappers that can be applied to a public, protected, or private attribute of a class or object. Example A.29: Usage of assertInstanceOf() <?php use PHPUnit\Framework\TestCas

assertJsonFileEqualsJsonFile()

assertJsonFileEqualsJsonFile() assertJsonFileEqualsJsonFile(mixed $expectedFile, mixed $actualFile[, string $message = '']) Reports an error identified by $message if the value of $actualFile does not match the value of $expectedFile. Example A.33: Usage of assertJsonFileEqualsJsonFile() <?php use PHPUnit\Framework\TestCase; class JsonFileEqualsJsonFileTest extends TestCase { public function testFailure() { $this->assertJsonFileEqualsJsonFile( 'path/to/fixtu