Documentation

TestCase extends Assert
in package
implements Reorderable, SelfDescribing, Test

AbstractYes
Tags
no-named-arguments

Parameter names are not covered by the backward compatibility promise for PHPUnit

Table of Contents

Interfaces

Reorderable
SelfDescribing
Test

Constants

LOCALE_CATEGORIES  = [\LC_ALL, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY, \LC_NUMERIC, \LC_TIME]

Properties

$backupGlobals  : bool|null
$backupGlobalsExcludeList  : array<string|int, mixed>
$backupStaticProperties  : bool|null
$backupStaticPropertiesExcludeList  : array<string|int, mixed>
$count  : int
$customComparators  : array<string|int, mixed>
$data  : array<string|int, mixed>
$dataName  : int|string
$dependencies  : array<string|int, mixed>
$dependencyInput  : array<string|int, mixed>
$doesNotPerformAssertions  : bool
$expectedException  : string|null
$expectedExceptionCode  : null|int|string
$expectedExceptionMessage  : string|null
$expectedExceptionMessageRegExp  : string|null
$failureTypes  : array<string|int, mixed>
$groups  : array<string|int, mixed>
$iniSettings  : array<string|int, mixed>
$inIsolation  : bool
$locale  : array<string|int, mixed>
$mockObjects  : array<string|int, mixed>
$name  : string
$numberOfAssertionsPerformed  : int
$output  : string
$outputBufferingActive  : bool
$outputBufferingLevel  : int
$outputExpectedRegex  : string|null
$outputExpectedString  : string|null
$outputRetrievedForAssertion  : bool
$preserveGlobalState  : bool
$providedTests  : array<string|int, mixed>
$registerMockObjectsFromTestArgumentsRecursively  : bool
$runClassInSeparateProcess  : bool|null
$runTestInSeparateProcess  : bool|null
$snapshot  : Snapshot|null
$status  : TestStatus
$testResult  : mixed
$testValueObjectForEvents  : TestMethod|null
$wasPrepared  : bool

Methods

any()  : AnyInvokedCount
Returns a matcher that matches when the method is executed zero or more times.
anything()  : IsAnything
arrayHasKey()  : ArrayHasKey
assertArrayHasKey()  : void
Asserts that an array has a specified key.
assertArrayNotHasKey()  : void
Asserts that an array does not have a specified key.
assertContains()  : void
Asserts that a haystack contains a needle.
assertContainsEquals()  : void
assertContainsOnly()  : void
Asserts that a haystack contains only values of a given type.
assertContainsOnlyInstancesOf()  : void
Asserts that a haystack contains only instances of a given class name.
assertCount()  : void
Asserts the number of elements of an array, Countable or Traversable.
assertDirectoryDoesNotExist()  : void
Asserts that a directory does not exist.
assertDirectoryExists()  : void
Asserts that a directory exists.
assertDirectoryIsNotReadable()  : void
Asserts that a directory exists and is not readable.
assertDirectoryIsNotWritable()  : void
Asserts that a directory exists and is not writable.
assertDirectoryIsReadable()  : void
Asserts that a directory exists and is readable.
assertDirectoryIsWritable()  : void
Asserts that a directory exists and is writable.
assertDoesNotMatchRegularExpression()  : void
Asserts that a string does not match a given regular expression.
assertEmpty()  : void
Asserts that a variable is empty.
assertEquals()  : void
Asserts that two variables are equal.
assertEqualsCanonicalizing()  : void
Asserts that two variables are equal (canonicalizing).
assertEqualsIgnoringCase()  : void
Asserts that two variables are equal (ignoring case).
assertEqualsWithDelta()  : void
Asserts that two variables are equal (with delta).
assertFalse()  : void
Asserts that a condition is false.
assertFileDoesNotExist()  : void
Asserts that a file does not exist.
assertFileEquals()  : void
Asserts that the contents of one file is equal to the contents of another file.
assertFileEqualsCanonicalizing()  : void
Asserts that the contents of one file is equal to the contents of another file (canonicalizing).
assertFileEqualsIgnoringCase()  : void
Asserts that the contents of one file is equal to the contents of another file (ignoring case).
assertFileExists()  : void
Asserts that a file exists.
assertFileIsNotReadable()  : void
Asserts that a file exists and is not readable.
assertFileIsNotWritable()  : void
Asserts that a file exists and is not writable.
assertFileIsReadable()  : void
Asserts that a file exists and is readable.
assertFileIsWritable()  : void
Asserts that a file exists and is writable.
assertFileMatchesFormat()  : void
Asserts that a string matches a given format string.
assertFileMatchesFormatFile()  : void
Asserts that a string matches a given format string.
assertFileNotEquals()  : void
Asserts that the contents of one file is not equal to the contents of another file.
assertFileNotEqualsCanonicalizing()  : void
Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).
assertFileNotEqualsIgnoringCase()  : void
Asserts that the contents of one file is not equal to the contents of another file (ignoring case).
assertFinite()  : void
Asserts that a variable is finite.
assertGreaterThan()  : void
Asserts that a value is greater than another value.
assertGreaterThanOrEqual()  : void
Asserts that a value is greater than or equal to another value.
assertInfinite()  : void
Asserts that a variable is infinite.
assertInstanceOf()  : void
Asserts that a variable is of a given type.
assertIsArray()  : void
Asserts that a variable is of type array.
assertIsBool()  : void
Asserts that a variable is of type bool.
assertIsCallable()  : void
Asserts that a variable is of type callable.
assertIsClosedResource()  : void
Asserts that a variable is of type resource and is closed.
assertIsFloat()  : void
Asserts that a variable is of type float.
assertIsInt()  : void
Asserts that a variable is of type int.
assertIsIterable()  : void
Asserts that a variable is of type iterable.
assertIsList()  : void
assertIsNotArray()  : void
Asserts that a variable is not of type array.
assertIsNotBool()  : void
Asserts that a variable is not of type bool.
assertIsNotCallable()  : void
Asserts that a variable is not of type callable.
assertIsNotClosedResource()  : void
Asserts that a variable is not of type resource.
assertIsNotFloat()  : void
Asserts that a variable is not of type float.
assertIsNotInt()  : void
Asserts that a variable is not of type int.
assertIsNotIterable()  : void
Asserts that a variable is not of type iterable.
assertIsNotNumeric()  : void
Asserts that a variable is not of type numeric.
assertIsNotObject()  : void
Asserts that a variable is not of type object.
assertIsNotReadable()  : void
Asserts that a file/dir exists and is not readable.
assertIsNotResource()  : void
Asserts that a variable is not of type resource.
assertIsNotScalar()  : void
Asserts that a variable is not of type scalar.
assertIsNotString()  : void
Asserts that a variable is not of type string.
assertIsNotWritable()  : void
Asserts that a file/dir exists and is not writable.
assertIsNumeric()  : void
Asserts that a variable is of type numeric.
assertIsObject()  : void
Asserts that a variable is of type object.
assertIsReadable()  : void
Asserts that a file/dir is readable.
assertIsResource()  : void
Asserts that a variable is of type resource.
assertIsScalar()  : void
Asserts that a variable is of type scalar.
assertIsString()  : void
Asserts that a variable is of type string.
assertIsWritable()  : void
Asserts that a file/dir exists and is writable.
assertJson()  : void
Asserts that a string is a valid JSON string.
assertJsonFileEqualsJsonFile()  : void
Asserts that two JSON files are equal.
assertJsonFileNotEqualsJsonFile()  : void
Asserts that two JSON files are not equal.
assertJsonStringEqualsJsonFile()  : void
Asserts that the generated JSON encoded object and the content of the given file are equal.
assertJsonStringEqualsJsonString()  : void
Asserts that two given JSON encoded objects or arrays are equal.
assertJsonStringNotEqualsJsonFile()  : void
Asserts that the generated JSON encoded object and the content of the given file are not equal.
assertJsonStringNotEqualsJsonString()  : void
Asserts that two given JSON encoded objects or arrays are not equal.
assertLessThan()  : void
Asserts that a value is smaller than another value.
assertLessThanOrEqual()  : void
Asserts that a value is smaller than or equal to another value.
assertMatchesRegularExpression()  : void
Asserts that a string matches a given regular expression.
assertNan()  : void
Asserts that a variable is nan.
assertNotContains()  : void
Asserts that a haystack does not contain a needle.
assertNotContainsEquals()  : void
assertNotContainsOnly()  : void
Asserts that a haystack does not contain only values of a given type.
assertNotCount()  : void
Asserts the number of elements of an array, Countable or Traversable.
assertNotEmpty()  : void
Asserts that a variable is not empty.
assertNotEquals()  : void
Asserts that two variables are not equal.
assertNotEqualsCanonicalizing()  : void
Asserts that two variables are not equal (canonicalizing).
assertNotEqualsIgnoringCase()  : void
Asserts that two variables are not equal (ignoring case).
assertNotEqualsWithDelta()  : void
Asserts that two variables are not equal (with delta).
assertNotFalse()  : void
Asserts that a condition is not false.
assertNotInstanceOf()  : void
Asserts that a variable is not of a given type.
assertNotNull()  : void
Asserts that a variable is not null.
assertNotSame()  : void
Asserts that two variables do not have the same type and value.
assertNotSameSize()  : void
Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
assertNotTrue()  : void
Asserts that a condition is not true.
assertNull()  : void
Asserts that a variable is null.
assertObjectEquals()  : void
assertObjectHasProperty()  : void
Asserts that an object has a specified property.
assertObjectNotHasProperty()  : void
Asserts that an object does not have a specified property.
assertSame()  : void
Asserts that two variables have the same type and value.
assertSameSize()  : void
Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
assertStringContainsString()  : void
assertStringContainsStringIgnoringCase()  : void
assertStringContainsStringIgnoringLineEndings()  : void
assertStringEndsNotWith()  : void
Asserts that a string ends not with a given suffix.
assertStringEndsWith()  : void
Asserts that a string ends with a given suffix.
assertStringEqualsFile()  : void
Asserts that the contents of a string is equal to the contents of a file.
assertStringEqualsFileCanonicalizing()  : void
Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
assertStringEqualsFileIgnoringCase()  : void
Asserts that the contents of a string is equal to the contents of a file (ignoring case).
assertStringEqualsStringIgnoringLineEndings()  : void
Asserts that two strings are equal except for line endings.
assertStringMatchesFormat()  : void
Asserts that a string matches a given format string.
assertStringMatchesFormatFile()  : void
Asserts that a string matches a given format file.
assertStringNotContainsString()  : void
assertStringNotContainsStringIgnoringCase()  : void
assertStringNotEqualsFile()  : void
Asserts that the contents of a string is not equal to the contents of a file.
assertStringNotEqualsFileCanonicalizing()  : void
Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
assertStringNotEqualsFileIgnoringCase()  : void
Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
assertStringNotMatchesFormat()  : void
Asserts that a string does not match a given format string.
assertStringNotMatchesFormatFile()  : void
Asserts that a string does not match a given format string.
assertStringStartsNotWith()  : void
Asserts that a string starts not with a given prefix.
assertStringStartsWith()  : void
Asserts that a string starts with a given prefix.
assertThat()  : void
Evaluates a PHPUnit\Framework\Constraint matcher object.
assertTrue()  : void
Asserts that a condition is true.
assertXmlFileEqualsXmlFile()  : void
Asserts that two XML files are equal.
assertXmlFileNotEqualsXmlFile()  : void
Asserts that two XML files are not equal.
assertXmlStringEqualsXmlFile()  : void
Asserts that two XML documents are equal.
assertXmlStringEqualsXmlString()  : void
Asserts that two XML documents are equal.
assertXmlStringNotEqualsXmlFile()  : void
Asserts that two XML documents are not equal.
assertXmlStringNotEqualsXmlString()  : void
Asserts that two XML documents are not equal.
atLeast()  : InvokedAtLeastCount
Returns a matcher that matches when the method is executed at least N times.
atLeastOnce()  : InvokedAtLeastOnce
Returns a matcher that matches when the method is executed at least once.
atMost()  : InvokedAtMostCount
Returns a matcher that matches when the method is executed at most N times.
callback()  : Callback
containsEqual()  : TraversableContainsEqual
containsIdentical()  : TraversableContainsIdentical
containsOnly()  : TraversableContainsOnly
containsOnlyInstancesOf()  : TraversableContainsOnly
countOf()  : Count
directoryExists()  : DirectoryExists
equalTo()  : IsEqual
equalToCanonicalizing()  : IsEqualCanonicalizing
equalToIgnoringCase()  : IsEqualIgnoringCase
equalToWithDelta()  : IsEqualWithDelta
exactly()  : InvokedCount
Returns a matcher that matches when the method is executed exactly $count times.
expectException()  : void
expectExceptionCode()  : void
expectExceptionMessage()  : void
expectExceptionMessageMatches()  : void
expectExceptionObject()  : void
Sets up an expectation for an exception to be raised by the code under test.
expectNotToPerformAssertions()  : void
expectOutputRegex()  : void
expectOutputString()  : void
fail()  : never
Fails a test with the given message.
fileExists()  : FileExists
getActualOutputForAssertion()  : string
getCount()  : int
Return the current assertion count.
getMockBuilder()  : MockBuilder
Returns a builder object to create mock objects using a fluent interface.
greaterThan()  : GreaterThan
greaterThanOrEqual()  : LogicalOr
identicalTo()  : IsIdentical
isEmpty()  : IsEmpty
isFalse()  : IsFalse
isFinite()  : IsFinite
isInfinite()  : IsInfinite
isInstanceOf()  : IsInstanceOf
isJson()  : IsJson
isList()  : IsList
isNan()  : IsNan
isNull()  : IsNull
isReadable()  : IsReadable
isTrue()  : IsTrue
isType()  : IsType
isWritable()  : IsWritable
lessThan()  : LessThan
lessThanOrEqual()  : LogicalOr
logicalAnd()  : LogicalAnd
logicalNot()  : LogicalNot
logicalOr()  : LogicalOr
logicalXor()  : LogicalXor
markTestIncomplete()  : never
Mark the test as incomplete.
markTestSkipped()  : never
Mark the test as skipped.
matches()  : StringMatchesFormatDescription
matchesRegularExpression()  : RegularExpression
never()  : InvokedCount
Returns a matcher that matches when the method is never executed.
objectEquals()  : ObjectEquals
once()  : InvokedCount
Returns a matcher that matches when the method is executed exactly once.
onConsecutiveCalls()  : ConsecutiveCalls
resetCount()  : void
Reset the assertion counter.
returnArgument()  : ReturnArgument
returnCallback()  : ReturnCallback
returnSelf()  : ReturnSelf
returnValue()  : ReturnStub
returnValueMap()  : ReturnValueMap
setUpBeforeClass()  : void
This method is called before the first test of this test class is run.
stringContains()  : StringContains
stringEndsWith()  : StringEndsWith
stringEqualsStringIgnoringLineEndings()  : StringEqualsStringIgnoringLineEndings
stringStartsWith()  : StringStartsWith
tearDownAfterClass()  : void
This method is called after the last test of this test class is run.
throwException()  : Exception
assertPostConditions()  : void
Performs assertions shared by all tests of a test case.
assertPreConditions()  : void
Performs assertions shared by all tests of a test case.
createConfiguredMock()  : MockObject
Creates (and configures) a mock object for the specified interface or class.
createConfiguredStub()  : Stub
Creates (and configures) a test stub for the specified interface or class.
createMock()  : MockObject
Creates a mock object for the specified interface or class.
createMockForIntersectionOfInterfaces()  : MockObject
createPartialMock()  : MockObject
Creates a partial mock object for the specified interface or class.
createStub()  : Stub
Creates a test stub for the specified interface or class.
createStubForIntersectionOfInterfaces()  : Stub
createTestProxy()  : MockObject
Creates a test proxy for the specified class.
getMockForAbstractClass()  : MockObject
Creates a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default.
getMockForTrait()  : MockObject
Creates a mock object for the specified trait with all abstract methods of the trait mocked. Concrete methods to mock can be specified with the `$mockedMethods` parameter.
getMockFromWsdl()  : MockObject
Creates a mock object based on the given WSDL file.
getObjectForTrait()  : object
Creates an object that uses the specified trait.
iniSet()  : void
This method is a wrapper for the ini_set() function that automatically resets the modified php.ini setting to its original value after the test is run.
onNotSuccessfulTest()  : never
This method is called when a test method did not execute successfully.
registerComparator()  : void
registerFailureType()  : void
setLocale()  : void
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
setUp()  : void
This method is called before each test.
tearDown()  : void
This method is called after each test.
transformException()  : Throwable
checkRequirements()  : void
cleanupIniSettings()  : void
cleanupLocaleSettings()  : void
compareGlobalStateSnapshotPart()  : void
compareGlobalStateSnapshots()  : void
createGlobalStateSnapshot()  : Snapshot
expectedExceptionWasNotRaised()  : void
handleDependencies()  : bool
invokeAfterClassHookMethods()  : void
invokeAfterTestHookMethods()  : void
invokeBeforeClassHookMethods()  : void
invokeBeforeTestHookMethods()  : void
invokeHookMethods()  : void
invokePostConditionHookMethods()  : void
invokePreConditionHookMethods()  : void
isCallableTestMethod()  : bool
isNativeType()  : bool
isRegisteredFailure()  : bool
markErrorForInvalidDependency()  : void
markSkippedForMissingDependency()  : void
methodDoesNotExistOrIsDeclaredInTestCase()  : bool
performAssertionsOnOutput()  : void
registerMockObjectsFromTestArguments()  : void
restoreGlobalState()  : void
shouldExceptionExpectationsBeVerified()  : bool
shouldInvocationMockerBeReset()  : bool
shouldRunInSeparateProcess()  : bool
snapshotGlobalState()  : void
startOutputBuffering()  : void
stopOutputBuffering()  : bool
unregisterCustomComparators()  : void
verifyExceptionExpectations()  : void
verifyMockObjects()  : void

Constants

LOCALE_CATEGORIES

private mixed LOCALE_CATEGORIES = [\LC_ALL, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY, \LC_NUMERIC, \LC_TIME]

Properties

$backupGlobals

private bool|null $backupGlobals = null

$backupGlobalsExcludeList

private array<string|int, mixed> $backupGlobalsExcludeList = []
Tags
psalm-var

list

$backupStaticProperties

private bool|null $backupStaticProperties = null

$backupStaticPropertiesExcludeList

private array<string|int, mixed> $backupStaticPropertiesExcludeList = []
Tags
psalm-var

array<string,list>

$count

private static int $count = 0

$customComparators

private array<string|int, mixed> $customComparators = []
Tags
psalm-var

list<Comparator>

$data

private array<string|int, mixed> $data = []

$dataName

private int|string $dataName = ''

$dependencies

private array<string|int, mixed> $dependencies = []
Tags
psalm-var

list<ExecutionOrderDependency>

$dependencyInput

private array<string|int, mixed> $dependencyInput = []

$doesNotPerformAssertions

private bool $doesNotPerformAssertions = false

$expectedException

private string|null $expectedException = null

$expectedExceptionCode

private null|int|string $expectedExceptionCode = null

$expectedExceptionMessage

private string|null $expectedExceptionMessage = null

$expectedExceptionMessageRegExp

private string|null $expectedExceptionMessageRegExp = null

$failureTypes

private array<string|int, mixed> $failureTypes = []
Tags
psalm-var

array<class-string, true>

$groups

private array<string|int, mixed> $groups = []
Tags
psalm-var

list

$iniSettings

private array<string|int, mixed> $iniSettings = []
Tags
psalm-var

array<string,string>

$inIsolation

private bool $inIsolation = false

$locale

private array<string|int, mixed> $locale = []

$mockObjects

private array<string|int, mixed> $mockObjects = []
Tags
psalm-var

list<MockObjectInternal>

$name

private string $name
Tags
psalm-var

non-empty-string

$numberOfAssertionsPerformed

private int $numberOfAssertionsPerformed = 0

$outputBufferingActive

private bool $outputBufferingActive = false

$outputBufferingLevel

private int $outputBufferingLevel

$outputExpectedRegex

private string|null $outputExpectedRegex = null

$outputExpectedString

private string|null $outputExpectedString = null

$outputRetrievedForAssertion

private bool $outputRetrievedForAssertion = false

$preserveGlobalState

private bool $preserveGlobalState = false

$providedTests

private array<string|int, mixed> $providedTests = []
Tags
psalm-var

list<ExecutionOrderDependency>

$registerMockObjectsFromTestArgumentsRecursively

private bool $registerMockObjectsFromTestArgumentsRecursively = false

$runClassInSeparateProcess

private bool|null $runClassInSeparateProcess = null

$runTestInSeparateProcess

private bool|null $runTestInSeparateProcess = null

$testResult

private mixed $testResult = null

$wasPrepared

private bool $wasPrepared = false

Methods

any()

Returns a matcher that matches when the method is executed zero or more times.

public final static any() : AnyInvokedCount
Return values
AnyInvokedCount

assertArrayHasKey()

Asserts that an array has a specified key.

public final static assertArrayHasKey(int|string $key, array<string|int, mixed>|ArrayAccess $array[, string $message = '' ]) : void
Parameters
$key : int|string
$array : array<string|int, mixed>|ArrayAccess
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertArrayNotHasKey()

Asserts that an array does not have a specified key.

public final static assertArrayNotHasKey(int|string $key, array<string|int, mixed>|ArrayAccess $array[, string $message = '' ]) : void
Parameters
$key : int|string
$array : array<string|int, mixed>|ArrayAccess
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertContains()

Asserts that a haystack contains a needle.

public final static assertContains(mixed $needle, iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$needle : mixed
$haystack : iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertContainsEquals()

public final static assertContainsEquals(mixed $needle, iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$needle : mixed
$haystack : iterable<string|int, mixed>
$message : string = ''
Tags
throws
ExpectationFailedException

assertContainsOnly()

Asserts that a haystack contains only values of a given type.

public final static assertContainsOnly(string $type, iterable<string|int, mixed> $haystack[, bool|null $isNativeType = null ][, string $message = '' ]) : void
Parameters
$type : string
$haystack : iterable<string|int, mixed>
$isNativeType : bool|null = null
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertContainsOnlyInstancesOf()

Asserts that a haystack contains only instances of a given class name.

public final static assertContainsOnlyInstancesOf(string $className, iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$className : string
$haystack : iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertCount()

Asserts the number of elements of an array, Countable or Traversable.

public final static assertCount(int $expectedCount, Countable|iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$expectedCount : int
$haystack : Countable|iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
GeneratorNotSupportedException

assertDirectoryDoesNotExist()

Asserts that a directory does not exist.

public final static assertDirectoryDoesNotExist(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDirectoryExists()

Asserts that a directory exists.

public final static assertDirectoryExists(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDirectoryIsNotReadable()

Asserts that a directory exists and is not readable.

public final static assertDirectoryIsNotReadable(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDirectoryIsNotWritable()

Asserts that a directory exists and is not writable.

public final static assertDirectoryIsNotWritable(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDirectoryIsReadable()

Asserts that a directory exists and is readable.

public final static assertDirectoryIsReadable(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDirectoryIsWritable()

Asserts that a directory exists and is writable.

public final static assertDirectoryIsWritable(string $directory[, string $message = '' ]) : void
Parameters
$directory : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertDoesNotMatchRegularExpression()

Asserts that a string does not match a given regular expression.

public final static assertDoesNotMatchRegularExpression(string $pattern, string $string[, string $message = '' ]) : void
Parameters
$pattern : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertEmpty()

Asserts that a variable is empty.

public final static assertEmpty(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
throws
GeneratorNotSupportedException
psalm-assert

empty $actual

assertEquals()

Asserts that two variables are equal.

public final static assertEquals(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertEqualsCanonicalizing()

Asserts that two variables are equal (canonicalizing).

public final static assertEqualsCanonicalizing(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertEqualsIgnoringCase()

Asserts that two variables are equal (ignoring case).

public final static assertEqualsIgnoringCase(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertEqualsWithDelta()

Asserts that two variables are equal (with delta).

public final static assertEqualsWithDelta(mixed $expected, mixed $actual, float $delta[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$delta : float
$message : string = ''
Tags
throws
ExpectationFailedException

assertFalse()

Asserts that a condition is false.

public final static assertFalse(mixed $condition[, string $message = '' ]) : void
Parameters
$condition : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

false $condition

assertFileDoesNotExist()

Asserts that a file does not exist.

public final static assertFileDoesNotExist(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileEquals()

Asserts that the contents of one file is equal to the contents of another file.

public final static assertFileEquals(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileEqualsCanonicalizing()

Asserts that the contents of one file is equal to the contents of another file (canonicalizing).

public final static assertFileEqualsCanonicalizing(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileEqualsIgnoringCase()

Asserts that the contents of one file is equal to the contents of another file (ignoring case).

public final static assertFileEqualsIgnoringCase(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileExists()

Asserts that a file exists.

public final static assertFileExists(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileIsNotReadable()

Asserts that a file exists and is not readable.

public final static assertFileIsNotReadable(string $file[, string $message = '' ]) : void
Parameters
$file : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileIsNotWritable()

Asserts that a file exists and is not writable.

public final static assertFileIsNotWritable(string $file[, string $message = '' ]) : void
Parameters
$file : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileIsReadable()

Asserts that a file exists and is readable.

public final static assertFileIsReadable(string $file[, string $message = '' ]) : void
Parameters
$file : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileIsWritable()

Asserts that a file exists and is writable.

public final static assertFileIsWritable(string $file[, string $message = '' ]) : void
Parameters
$file : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileMatchesFormat()

Asserts that a string matches a given format string.

public final static assertFileMatchesFormat(string $format, string $actualFile[, string $message = '' ]) : void
Parameters
$format : string
$actualFile : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileMatchesFormatFile()

Asserts that a string matches a given format string.

public final static assertFileMatchesFormatFile(string $formatFile, string $actualFile[, string $message = '' ]) : void
Parameters
$formatFile : string
$actualFile : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileNotEquals()

Asserts that the contents of one file is not equal to the contents of another file.

public final static assertFileNotEquals(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileNotEqualsCanonicalizing()

Asserts that the contents of one file is not equal to the contents of another file (canonicalizing).

public final static assertFileNotEqualsCanonicalizing(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFileNotEqualsIgnoringCase()

Asserts that the contents of one file is not equal to the contents of another file (ignoring case).

public final static assertFileNotEqualsIgnoringCase(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertFinite()

Asserts that a variable is finite.

public final static assertFinite(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertGreaterThan()

Asserts that a value is greater than another value.

public final static assertGreaterThan(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertGreaterThanOrEqual()

Asserts that a value is greater than or equal to another value.

public final static assertGreaterThanOrEqual(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertInfinite()

Asserts that a variable is infinite.

public final static assertInfinite(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertInstanceOf()

Asserts that a variable is of a given type.

public final static assertInstanceOf(string $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
UnknownClassOrInterfaceException
psalm-template

ExpectedType of object

psalm-param

class-string<ExpectedType> $expected

psalm-assert

=ExpectedType $actual

assertIsArray()

Asserts that a variable is of type array.

public final static assertIsArray(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

array $actual

assertIsBool()

Asserts that a variable is of type bool.

public final static assertIsBool(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

bool $actual

assertIsCallable()

Asserts that a variable is of type callable.

public final static assertIsCallable(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

callable $actual

assertIsClosedResource()

Asserts that a variable is of type resource and is closed.

public final static assertIsClosedResource(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

resource $actual

assertIsFloat()

Asserts that a variable is of type float.

public final static assertIsFloat(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

float $actual

assertIsInt()

Asserts that a variable is of type int.

public final static assertIsInt(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

int $actual

assertIsIterable()

Asserts that a variable is of type iterable.

public final static assertIsIterable(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

iterable $actual

assertIsList()

public final static assertIsList(mixed $array[, string $message = '' ]) : void
Parameters
$array : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertIsNotArray()

Asserts that a variable is not of type array.

public final static assertIsNotArray(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!array $actual

assertIsNotBool()

Asserts that a variable is not of type bool.

public final static assertIsNotBool(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!bool $actual

assertIsNotCallable()

Asserts that a variable is not of type callable.

public final static assertIsNotCallable(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!callable $actual

assertIsNotClosedResource()

Asserts that a variable is not of type resource.

public final static assertIsNotClosedResource(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!resource $actual

assertIsNotFloat()

Asserts that a variable is not of type float.

public final static assertIsNotFloat(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!float $actual

assertIsNotInt()

Asserts that a variable is not of type int.

public final static assertIsNotInt(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!int $actual

assertIsNotIterable()

Asserts that a variable is not of type iterable.

public final static assertIsNotIterable(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!iterable $actual

assertIsNotNumeric()

Asserts that a variable is not of type numeric.

public final static assertIsNotNumeric(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!numeric $actual

assertIsNotObject()

Asserts that a variable is not of type object.

public final static assertIsNotObject(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!object $actual

assertIsNotReadable()

Asserts that a file/dir exists and is not readable.

public final static assertIsNotReadable(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertIsNotResource()

Asserts that a variable is not of type resource.

public final static assertIsNotResource(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!resource $actual

assertIsNotScalar()

Asserts that a variable is not of type scalar.

public final static assertIsNotScalar(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!scalar $actual

assertIsNotString()

Asserts that a variable is not of type string.

public final static assertIsNotString(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

!string $actual

assertIsNotWritable()

Asserts that a file/dir exists and is not writable.

public final static assertIsNotWritable(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertIsNumeric()

Asserts that a variable is of type numeric.

public final static assertIsNumeric(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

numeric $actual

assertIsObject()

Asserts that a variable is of type object.

public final static assertIsObject(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

object $actual

assertIsReadable()

Asserts that a file/dir is readable.

public final static assertIsReadable(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertIsResource()

Asserts that a variable is of type resource.

public final static assertIsResource(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

resource $actual

assertIsScalar()

Asserts that a variable is of type scalar.

public final static assertIsScalar(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

scalar $actual

assertIsString()

Asserts that a variable is of type string.

public final static assertIsString(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-assert

string $actual

assertIsWritable()

Asserts that a file/dir exists and is writable.

public final static assertIsWritable(string $filename[, string $message = '' ]) : void
Parameters
$filename : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJson()

Asserts that a string is a valid JSON string.

public final static assertJson(string $actual[, string $message = '' ]) : void
Parameters
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonFileEqualsJsonFile()

Asserts that two JSON files are equal.

public final static assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualFile : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonFileNotEqualsJsonFile()

Asserts that two JSON files are not equal.

public final static assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualFile : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonStringEqualsJsonFile()

Asserts that the generated JSON encoded object and the content of the given file are equal.

public final static assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualJson : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonStringEqualsJsonString()

Asserts that two given JSON encoded objects or arrays are equal.

public final static assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson[, string $message = '' ]) : void
Parameters
$expectedJson : string
$actualJson : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonStringNotEqualsJsonFile()

Asserts that the generated JSON encoded object and the content of the given file are not equal.

public final static assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualJson : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertJsonStringNotEqualsJsonString()

Asserts that two given JSON encoded objects or arrays are not equal.

public final static assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson[, string $message = '' ]) : void
Parameters
$expectedJson : string
$actualJson : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertLessThan()

Asserts that a value is smaller than another value.

public final static assertLessThan(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertLessThanOrEqual()

Asserts that a value is smaller than or equal to another value.

public final static assertLessThanOrEqual(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertMatchesRegularExpression()

Asserts that a string matches a given regular expression.

public final static assertMatchesRegularExpression(string $pattern, string $string[, string $message = '' ]) : void
Parameters
$pattern : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertNan()

Asserts that a variable is nan.

public final static assertNan(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotContains()

Asserts that a haystack does not contain a needle.

public final static assertNotContains(mixed $needle, iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$needle : mixed
$haystack : iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertNotContainsEquals()

public final static assertNotContainsEquals(mixed $needle, iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$needle : mixed
$haystack : iterable<string|int, mixed>
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotContainsOnly()

Asserts that a haystack does not contain only values of a given type.

public final static assertNotContainsOnly(string $type, iterable<string|int, mixed> $haystack[, bool|null $isNativeType = null ][, string $message = '' ]) : void
Parameters
$type : string
$haystack : iterable<string|int, mixed>
$isNativeType : bool|null = null
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertNotCount()

Asserts the number of elements of an array, Countable or Traversable.

public final static assertNotCount(int $expectedCount, Countable|iterable<string|int, mixed> $haystack[, string $message = '' ]) : void
Parameters
$expectedCount : int
$haystack : Countable|iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
GeneratorNotSupportedException

assertNotEmpty()

Asserts that a variable is not empty.

public final static assertNotEmpty(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
throws
GeneratorNotSupportedException
psalm-assert

!empty $actual

assertNotEquals()

Asserts that two variables are not equal.

public final static assertNotEquals(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotEqualsCanonicalizing()

Asserts that two variables are not equal (canonicalizing).

public final static assertNotEqualsCanonicalizing(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotEqualsIgnoringCase()

Asserts that two variables are not equal (ignoring case).

public final static assertNotEqualsIgnoringCase(mixed $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotEqualsWithDelta()

Asserts that two variables are not equal (with delta).

public final static assertNotEqualsWithDelta(mixed $expected, mixed $actual, float $delta[, string $message = '' ]) : void
Parameters
$expected : mixed
$actual : mixed
$delta : float
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotFalse()

Asserts that a condition is not false.

public final static assertNotFalse(mixed $condition[, string $message = '' ]) : void
Parameters
$condition : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

!false $condition

assertNotInstanceOf()

Asserts that a variable is not of a given type.

public final static assertNotInstanceOf(string $expected, mixed $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : mixed
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
psalm-template

ExpectedType of object

psalm-param

class-string<ExpectedType> $expected

psalm-assert

!ExpectedType $actual

assertNotNull()

Asserts that a variable is not null.

public final static assertNotNull(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

!null $actual

assertNotSame()

Asserts that two variables do not have the same type and value.

public final static assertNotSame(mixed $expected, mixed $actual[, string $message = '' ]) : void

Used on objects, it asserts that two variables do not reference the same object.

Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException

assertNotSameSize()

Assert that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.

public final static assertNotSameSize(Countable|iterable<string|int, mixed> $expected, Countable|iterable<string|int, mixed> $actual[, string $message = '' ]) : void
Parameters
$expected : Countable|iterable<string|int, mixed>
$actual : Countable|iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
GeneratorNotSupportedException

assertNotTrue()

Asserts that a condition is not true.

public final static assertNotTrue(mixed $condition[, string $message = '' ]) : void
Parameters
$condition : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

!true $condition

assertNull()

Asserts that a variable is null.

public final static assertNull(mixed $actual[, string $message = '' ]) : void
Parameters
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

null $actual

assertObjectEquals()

public final static assertObjectEquals(object $expected, object $actual[, string $method = 'equals' ][, string $message = '' ]) : void
Parameters
$expected : object
$actual : object
$method : string = 'equals'
$message : string = ''
Tags
throws
ExpectationFailedException

assertObjectHasProperty()

Asserts that an object has a specified property.

public final static assertObjectHasProperty(string $propertyName, object $object[, string $message = '' ]) : void
Parameters
$propertyName : string
$object : object
$message : string = ''
Tags
throws
ExpectationFailedException

assertObjectNotHasProperty()

Asserts that an object does not have a specified property.

public final static assertObjectNotHasProperty(string $propertyName, object $object[, string $message = '' ]) : void
Parameters
$propertyName : string
$object : object
$message : string = ''
Tags
throws
ExpectationFailedException

assertSame()

Asserts that two variables have the same type and value.

public final static assertSame(mixed $expected, mixed $actual[, string $message = '' ]) : void

Used on objects, it asserts that two variables reference the same object.

Parameters
$expected : mixed
$actual : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-template

ExpectedType

psalm-param

ExpectedType $expected

psalm-assert

=ExpectedType $actual

assertSameSize()

Assert that the size of two arrays (or `Countable` or `Traversable` objects) is the same.

public final static assertSameSize(Countable|iterable<string|int, mixed> $expected, Countable|iterable<string|int, mixed> $actual[, string $message = '' ]) : void
Parameters
$expected : Countable|iterable<string|int, mixed>
$actual : Countable|iterable<string|int, mixed>
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
GeneratorNotSupportedException

assertStringContainsString()

public final static assertStringContainsString(string $needle, string $haystack[, string $message = '' ]) : void
Parameters
$needle : string
$haystack : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringContainsStringIgnoringCase()

public final static assertStringContainsStringIgnoringCase(string $needle, string $haystack[, string $message = '' ]) : void
Parameters
$needle : string
$haystack : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringContainsStringIgnoringLineEndings()

public final static assertStringContainsStringIgnoringLineEndings(string $needle, string $haystack[, string $message = '' ]) : void
Parameters
$needle : string
$haystack : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringEndsNotWith()

Asserts that a string ends not with a given suffix.

public final static assertStringEndsNotWith(string $suffix, string $string[, string $message = '' ]) : void
Parameters
$suffix : string
$string : string
$message : string = ''
Tags
psalm-param

non-empty-string $suffix

throws
ExpectationFailedException
throws
InvalidArgumentException

assertStringEndsWith()

Asserts that a string ends with a given suffix.

public final static assertStringEndsWith(string $suffix, string $string[, string $message = '' ]) : void
Parameters
$suffix : string
$string : string
$message : string = ''
Tags
psalm-param

non-empty-string $suffix

throws
ExpectationFailedException
throws
InvalidArgumentException

assertStringEqualsFile()

Asserts that the contents of a string is equal to the contents of a file.

public final static assertStringEqualsFile(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringEqualsFileCanonicalizing()

Asserts that the contents of a string is equal to the contents of a file (canonicalizing).

public final static assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringEqualsFileIgnoringCase()

Asserts that the contents of a string is equal to the contents of a file (ignoring case).

public final static assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringEqualsStringIgnoringLineEndings()

Asserts that two strings are equal except for line endings.

public final static assertStringEqualsStringIgnoringLineEndings(string $expected, string $actual[, string $message = '' ]) : void
Parameters
$expected : string
$actual : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringMatchesFormat()

Asserts that a string matches a given format string.

public final static assertStringMatchesFormat(string $format, string $string[, string $message = '' ]) : void
Parameters
$format : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringMatchesFormatFile()

Asserts that a string matches a given format file.

public final static assertStringMatchesFormatFile(string $formatFile, string $string[, string $message = '' ]) : void
Parameters
$formatFile : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotContainsString()

public final static assertStringNotContainsString(string $needle, string $haystack[, string $message = '' ]) : void
Parameters
$needle : string
$haystack : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotContainsStringIgnoringCase()

public final static assertStringNotContainsStringIgnoringCase(string $needle, string $haystack[, string $message = '' ]) : void
Parameters
$needle : string
$haystack : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotEqualsFile()

Asserts that the contents of a string is not equal to the contents of a file.

public final static assertStringNotEqualsFile(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotEqualsFileCanonicalizing()

Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).

public final static assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotEqualsFileIgnoringCase()

Asserts that the contents of a string is not equal to the contents of a file (ignoring case).

public final static assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualString : string
$message : string = ''
Tags
throws
ExpectationFailedException

assertStringNotMatchesFormat()

Asserts that a string does not match a given format string.

public final static assertStringNotMatchesFormat(string $format, string $string[, string $message = '' ]) : void
Parameters
$format : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException
deprecated

https://github.com/sebastianbergmann/phpunit/issues/5472

assertStringNotMatchesFormatFile()

Asserts that a string does not match a given format string.

public final static assertStringNotMatchesFormatFile(string $formatFile, string $string[, string $message = '' ]) : void
Parameters
$formatFile : string
$string : string
$message : string = ''
Tags
throws
ExpectationFailedException
deprecated

https://github.com/sebastianbergmann/phpunit/issues/5472

assertStringStartsNotWith()

Asserts that a string starts not with a given prefix.

public final static assertStringStartsNotWith(string $prefix, string $string[, string $message = '' ]) : void
Parameters
$prefix : string
$string : string
$message : string = ''
Tags
psalm-param

non-empty-string $prefix

throws
ExpectationFailedException
throws
InvalidArgumentException

assertStringStartsWith()

Asserts that a string starts with a given prefix.

public final static assertStringStartsWith(string $prefix, string $string[, string $message = '' ]) : void
Parameters
$prefix : string
$string : string
$message : string = ''
Tags
psalm-param

non-empty-string $prefix

throws
ExpectationFailedException
throws
InvalidArgumentException

assertThat()

Evaluates a PHPUnit\Framework\Constraint matcher object.

public final static assertThat(mixed $value, Constraint $constraint[, string $message = '' ]) : void
Parameters
$value : mixed
$constraint : Constraint
$message : string = ''
Tags
throws
ExpectationFailedException

assertTrue()

Asserts that a condition is true.

public final static assertTrue(mixed $condition[, string $message = '' ]) : void
Parameters
$condition : mixed
$message : string = ''
Tags
throws
ExpectationFailedException
psalm-assert

true $condition

assertXmlFileEqualsXmlFile()

Asserts that two XML files are equal.

public final static assertXmlFileEqualsXmlFile(string $expectedFile, string $actualFile[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualFile : string
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException
throws
XmlException

assertXmlFileNotEqualsXmlFile()

Asserts that two XML files are not equal.

public final static assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualFile : string
$message : string = ''
Tags
throws
Exception
throws
ExpectationFailedException

assertXmlStringEqualsXmlFile()

Asserts that two XML documents are equal.

public final static assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualXml : string
$message : string = ''
Tags
throws
ExpectationFailedException
throws
XmlException

assertXmlStringEqualsXmlString()

Asserts that two XML documents are equal.

public final static assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml[, string $message = '' ]) : void
Parameters
$expectedXml : string
$actualXml : string
$message : string = ''
Tags
throws
ExpectationFailedException
throws
XmlException

assertXmlStringNotEqualsXmlFile()

Asserts that two XML documents are not equal.

public final static assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml[, string $message = '' ]) : void
Parameters
$expectedFile : string
$actualXml : string
$message : string = ''
Tags
throws
ExpectationFailedException
throws
XmlException

assertXmlStringNotEqualsXmlString()

Asserts that two XML documents are not equal.

public final static assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml[, string $message = '' ]) : void
Parameters
$expectedXml : string
$actualXml : string
$message : string = ''
Tags
throws
ExpectationFailedException
throws
XmlException

atLeast()

Returns a matcher that matches when the method is executed at least N times.

public final static atLeast(int $requiredInvocations) : InvokedAtLeastCount
Parameters
$requiredInvocations : int
Return values
InvokedAtLeastCount

atLeastOnce()

Returns a matcher that matches when the method is executed at least once.

public final static atLeastOnce() : InvokedAtLeastOnce
Return values
InvokedAtLeastOnce

atMost()

Returns a matcher that matches when the method is executed at most N times.

public final static atMost(int $allowedInvocations) : InvokedAtMostCount
Parameters
$allowedInvocations : int
Return values
InvokedAtMostCount

callback()

public final static callback(callable $callback) : Callback
Parameters
$callback : callable
Tags
psalm-template

CallbackInput of mixed

psalm-param

callable(CallbackInput $callback): bool $callback

psalm-return

Callback<CallbackInput>

Return values
Callback

countOf()

public final static countOf(int $count) : Count
Parameters
$count : int
Return values
Count

equalTo()

public final static equalTo(mixed $value) : IsEqual
Parameters
$value : mixed
Return values
IsEqual

exactly()

Returns a matcher that matches when the method is executed exactly $count times.

public final static exactly(int $count) : InvokedCount
Parameters
$count : int
Return values
InvokedCount

expectException()

public final expectException(string $exception) : void
Parameters
$exception : string
Tags
psalm-param

class-string<Throwable> $exception

expectExceptionCode()

public final expectExceptionCode(int|string $code) : void
Parameters
$code : int|string

expectExceptionMessage()

public final expectExceptionMessage(string $message) : void
Parameters
$message : string

expectExceptionMessageMatches()

public final expectExceptionMessageMatches(string $regularExpression) : void
Parameters
$regularExpression : string

expectExceptionObject()

Sets up an expectation for an exception to be raised by the code under test.

public final expectExceptionObject(Exception $exception) : void

Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.

Parameters
$exception : Exception

expectNotToPerformAssertions()

public final expectNotToPerformAssertions() : void

expectOutputRegex()

public final expectOutputRegex(string $expectedRegex) : void
Parameters
$expectedRegex : string

expectOutputString()

public final expectOutputString(string $expectedString) : void
Parameters
$expectedString : string

fail()

Fails a test with the given message.

public final static fail([string $message = '' ]) : never
Parameters
$message : string = ''
Tags
throws
AssertionFailedError
Return values
never

getActualOutputForAssertion()

public final getActualOutputForAssertion() : string
Return values
string

getCount()

Return the current assertion count.

public final static getCount() : int
Return values
int

getMockBuilder()

Returns a builder object to create mock objects using a fluent interface.

public final getMockBuilder(string $className) : MockBuilder
Parameters
$className : string
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $className

psalm-return

MockBuilder<RealInstanceType>

Return values
MockBuilder

greaterThanOrEqual()

public final static greaterThanOrEqual(mixed $value) : LogicalOr
Parameters
$value : mixed
Return values
LogicalOr

isInstanceOf()

public final static isInstanceOf(string $className) : IsInstanceOf
Parameters
$className : string
Tags
throws
UnknownClassOrInterfaceException
Return values
IsInstanceOf

isType()

public final static isType(string $type) : IsType
Parameters
$type : string
Tags
psalm-param

'array'|'boolean'|'bool'|'double'|'float'|'integer'|'int'|'null'|'numeric'|'object'|'real'|'resource'|'resource (closed)'|'string'|'scalar'|'callable'|'iterable' $type

throws
Exception
Return values
IsType

lessThan()

public final static lessThan(mixed $value) : LessThan
Parameters
$value : mixed
Return values
LessThan

lessThanOrEqual()

public final static lessThanOrEqual(mixed $value) : LogicalOr
Parameters
$value : mixed
Return values
LogicalOr

logicalAnd()

public final static logicalAnd(mixed ...$constraints) : LogicalAnd
Parameters
$constraints : mixed
Tags
throws
Exception
Return values
LogicalAnd

logicalOr()

public final static logicalOr(mixed ...$constraints) : LogicalOr
Parameters
$constraints : mixed
Return values
LogicalOr

logicalXor()

public final static logicalXor(mixed ...$constraints) : LogicalXor
Parameters
$constraints : mixed
Return values
LogicalXor

markTestIncomplete()

Mark the test as incomplete.

public final static markTestIncomplete([string $message = '' ]) : never
Parameters
$message : string = ''
Tags
throws
IncompleteTestError
Return values
never

markTestSkipped()

Mark the test as skipped.

public final static markTestSkipped([string $message = '' ]) : never
Parameters
$message : string = ''
Tags
throws
SkippedWithMessageException
Return values
never

never()

Returns a matcher that matches when the method is never executed.

public final static never() : InvokedCount
Return values
InvokedCount

objectEquals()

public final static objectEquals(object $object[, string $method = 'equals' ]) : ObjectEquals
Parameters
$object : object
$method : string = 'equals'
Return values
ObjectEquals

once()

Returns a matcher that matches when the method is executed exactly once.

public final static once() : InvokedCount
Return values
InvokedCount

resetCount()

Reset the assertion counter.

public final static resetCount() : void

returnArgument()

public final static returnArgument(int $argumentIndex) : ReturnArgument
Parameters
$argumentIndex : int
Tags
deprecated

Use $double->willReturnArgument() instead of $double->will($this->returnArgument())

see
https://github.com/sebastianbergmann/phpunit/issues/5423
codeCoverageIgnore
Return values
ReturnArgument

returnCallback()

public final static returnCallback(callable $callback) : ReturnCallback
Parameters
$callback : callable
Tags
deprecated

Use $double->willReturnCallback() instead of $double->will($this->returnCallback())

see
https://github.com/sebastianbergmann/phpunit/issues/5423
codeCoverageIgnore
Return values
ReturnCallback

returnValueMap()

public final static returnValueMap(array<string|int, mixed> $valueMap) : ReturnValueMap
Parameters
$valueMap : array<string|int, mixed>
Tags
deprecated

Use $double->willReturnMap() instead of $double->will($this->returnValueMap())

see
https://github.com/sebastianbergmann/phpunit/issues/5423
codeCoverageIgnore
Return values
ReturnValueMap

setUpBeforeClass()

This method is called before the first test of this test class is run.

public static setUpBeforeClass() : void
Tags
codeCoverageIgnore

stringContains()

public final static stringContains(string $string[, bool $case = true ]) : StringContains
Parameters
$string : string
$case : bool = true
Return values
StringContains

stringEndsWith()

public final static stringEndsWith(string $suffix) : StringEndsWith
Parameters
$suffix : string
Tags
psalm-param

non-empty-string $suffix

throws
InvalidArgumentException
Return values
StringEndsWith

stringStartsWith()

public final static stringStartsWith(string $prefix) : StringStartsWith
Parameters
$prefix : string
Tags
psalm-param

non-empty-string $prefix

throws
InvalidArgumentException
Return values
StringStartsWith

tearDownAfterClass()

This method is called after the last test of this test class is run.

public static tearDownAfterClass() : void
Tags
codeCoverageIgnore

throwException()

public final static throwException(Throwable $exception) : Exception
Parameters
$exception : Throwable
Return values
Exception

assertPostConditions()

Performs assertions shared by all tests of a test case.

protected assertPostConditions() : void

This method is called between test and tearDown().

Tags
codeCoverageIgnore

assertPreConditions()

Performs assertions shared by all tests of a test case.

protected assertPreConditions() : void

This method is called between setUp() and test.

Tags
codeCoverageIgnore

createConfiguredMock()

Creates (and configures) a mock object for the specified interface or class.

protected createConfiguredMock(string $originalClassName, array<string|int, mixed> $configuration) : MockObject
Parameters
$originalClassName : string
$configuration : array<string|int, mixed>
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-return

MockObject&RealInstanceType

throws
InvalidArgumentException
throws
Exception
throws
NoPreviousThrowableException
Return values
MockObject

createConfiguredStub()

Creates (and configures) a test stub for the specified interface or class.

protected final static createConfiguredStub(string $originalClassName, array<string|int, mixed> $configuration) : Stub
Parameters
$originalClassName : string
$configuration : array<string|int, mixed>
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-return

Stub&RealInstanceType

throws
InvalidArgumentException
throws
Exception
throws
NoPreviousThrowableException
Return values
Stub

createMock()

Creates a mock object for the specified interface or class.

protected createMock(string $originalClassName) : MockObject
Parameters
$originalClassName : string
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-return

MockObject&RealInstanceType

throws
InvalidArgumentException
throws
Exception
throws
NoPreviousThrowableException
Return values
MockObject

createMockForIntersectionOfInterfaces()

protected createMockForIntersectionOfInterfaces(array<string|int, mixed> $interfaces) : MockObject
Parameters
$interfaces : array<string|int, mixed>
Tags
psalm-param

list $interfaces

throws
Exception
Return values
MockObject

createPartialMock()

Creates a partial mock object for the specified interface or class.

protected createPartialMock(string $originalClassName, array<string|int, mixed> $methods) : MockObject
Parameters
$originalClassName : string
$methods : array<string|int, mixed>
Tags
psalm-param

list $methods

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-template

RealInstanceType of object

psalm-return

MockObject&RealInstanceType

throws
InvalidArgumentException
throws
Exception
Return values
MockObject

createStub()

Creates a test stub for the specified interface or class.

protected static createStub(string $originalClassName) : Stub
Parameters
$originalClassName : string
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-return

Stub&RealInstanceType

throws
InvalidArgumentException
throws
Exception
throws
NoPreviousThrowableException
Return values
Stub

createStubForIntersectionOfInterfaces()

protected static createStubForIntersectionOfInterfaces(array<string|int, mixed> $interfaces) : Stub
Parameters
$interfaces : array<string|int, mixed>
Tags
psalm-param

list $interfaces

throws
Exception
Return values
Stub

createTestProxy()

Creates a test proxy for the specified class.

protected createTestProxy(string $originalClassName[, array<string|int, mixed> $constructorArguments = [] ]) : MockObject
Parameters
$originalClassName : string
$constructorArguments : array<string|int, mixed> = []
Tags
psalm-template

RealInstanceType of object

psalm-param

class-string<RealInstanceType> $originalClassName

psalm-return

MockObject&RealInstanceType

throws
InvalidArgumentException
throws
Exception
deprecated

https://github.com/sebastianbergmann/phpunit/issues/5240

Return values
MockObject

getMockForAbstractClass()

Creates a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default.

protected getMockForAbstractClass(string $originalClassName[, array<string|int, mixed> $arguments = [] ][, string $mockClassName = '' ][, bool $callOriginalConstructor = true ][, bool $callOriginalClone = true ][, bool $callAutoload = true ][, array<string|int, mixed> $mockedMethods = [] ][, bool $cloneArguments = false ]) : MockObject

To mock concrete methods, use the 7th parameter ($mockedMethods).

Parameters
$originalClassName : string