TestCase

extends PHPUnit\Framework\Assert implements Countable , PHPUnit\Framework\SelfDescribing , PHPUnit\Framework\Test

Known subclasses

Sunrise\Collection\Tests\CollectionTest, Sunrise\Slugger\Tests\SluggerTest, Sunrise\Stream\Tests\StreamTest, Sunrise\Uri\Tests\UriTest, Sunrise\Vin\Tests\VinTest
Abstract
Open source code
Methods Summary
public static
# any( )
Returns a matcher that matches when the method is executed zero or more times.
public static
# never( )
Returns a matcher that matches when the method is never executed.
public static
# atLeast( int $requiredInvocations )
Returns a matcher that matches when the method is executed at least N times.
public static
# atLeastOnce( )
Returns a matcher that matches when the method is executed at least once.
public static
# once( )
Returns a matcher that matches when the method is executed exactly once.
public static
# exactly( int $count )
Returns a matcher that matches when the method is executed exactly $count times.
public static
# atMost( int $allowedInvocations )
Returns a matcher that matches when the method is executed at most N times.
public static
# at( int $index )
Returns a matcher that matches when the method is executed at the given index.
public static
# returnValue( $value )
public static
# returnValueMap( array $valueMap )
public static
# returnArgument( int $argumentIndex )
public static
# returnCallback( $callback )
public static
# returnSelf( )
Returns the current object. This method is useful when mocking a fluent interface.
public static
# throwException( Throwable $exception )
public static
# onConsecutiveCalls( $args ,… )
public
# __construct( string $name = NULL, array $data = array ( ), $dataName = '' )
public static
# setUpBeforeClass( )
This method is called before the first test of this test class is run.
public static
# tearDownAfterClass( )
This method is called after the last test of this test class is run.
protected
# setUp( )
This method is called before each test.
protected
# tearDown( )
This method is called after each test.
public
# toString( )
Returns a string representation of the test case.

Implementation of

public
# count( )

Implementation of

public
public
# setGroups( array $groups )
public
public
# getName( bool $withDataSet = true )
public
# getSize( )
Returns the size of the test.
public
# hasSize( )
public
# isSmall( )
public
# isMedium( )
public
# isLarge( )
public
public
public
public
# expectOutputRegex( string $expectedRegex )
public
# expectOutputString( string $expectedString )
public
public
public
public
public
public
# expectException( string $exception )
public
# expectExceptionCode( int|string $code )
public
# expectExceptionMessage( string $message )
public
# expectExceptionMessageRegExp( string $messageRegExp )
public
# expectExceptionObject( Exception $exception )
Sets up an expectation for an exception to be raised by the code under test. Information for expected exception class, expected exception message, and expected exception code are retrieved from a given Exception object.
public
public
public
# setUseErrorHandler( bool $useErrorHandler )
public
public
public
public
public
# run( PHPUnit\Framework\TestResult $result = NULL )
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.

Implementation of

public
# runBare( )
public
# setName( string $name )
public
# setDependencies( array $dependencies )
public
public
public
# setDependencyInput( array $dependencyInput )
public
# setBeStrictAboutChangesToGlobalState( bool $beStrictAboutChangesToGlobalState )
public
# setBackupGlobals( bool $backupGlobals )
public
# setBackupStaticAttributes( bool $backupStaticAttributes )
public
# setRunTestInSeparateProcess( bool $runTestInSeparateProcess )
public
# setRunClassInSeparateProcess( bool $runClassInSeparateProcess )
public
# setPreserveGlobalState( bool $preserveGlobalState )
public
# setInIsolation( bool $inIsolation )
public
public
public
# setResult( $result )
public
# setOutputCallback( callable $callback )
public
public
# setTestResultObject( PHPUnit\Framework\TestResult $result )
public
# registerMockObject( PHPUnit\Framework\MockObject\MockObject $mockObject )
public
# getMockBuilder( string|string[] $className )
Returns a builder object to create mock objects using a fluent interface.
public
# addToAssertionCount( int $count )
public
# getNumAssertions( )
Returns the number of assertions performed by this test.
public
public
public
# dataName( )
public
# registerComparator( SebastianBergmann\Comparator\Comparator $comparator )
public
# getDataSetAsString( bool $includeData = true )
public
# getProvidedData( )
Gets the data set of a TestCase.
public
# addWarning( string $warning )
protected
# runTest( )
Override to run the test and assert its state.
protected
# iniSet( string $varName , $newValue )
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.
protected
# setLocale( $args ,… )
This method is a wrapper for the setlocale() function that automatically resets the locale to its original value after the test is run.
protected
# createMock( string|string[] $originalClassName )
Returns a test double for the specified class.
protected
# createConfiguredMock( string|string[] $originalClassName , array $configuration )
Returns a configured test double for the specified class.
protected
# createPartialMock( string|string[] $originalClassName , array $methods )
Returns a partial test double for the specified class.
protected
# createTestProxy( string $originalClassName , array $constructorArguments = array ( ) )
Returns a test proxy for the specified class.
protected
# getMockClass( string $originalClassName , array $methods = array ( ), array $arguments = array ( ), bool $mockClassName = '', bool $callOriginalConstructor = false, bool $callOriginalClone = true, bool $callAutoload = true, $cloneArguments = false )
Mocks the specified class and returns the name of the mocked class.
protected
# getMockForAbstractClass( string $originalClassName , array $arguments = array ( ), bool $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, array $callAutoload = true, bool $mockedMethods = array ( ), $cloneArguments = false )
Returns a mock object for the specified abstract class with all abstract methods of the class mocked. Concrete methods are not mocked by default. To mock concrete methods, use the 7th parameter ($mockedMethods).
protected
# getMockFromWsdl( string $wsdlFile , string $originalClassName = '', string $mockClassName = '', array $methods = array ( ), array $callOriginalConstructor = true, array $options = array ( ) )
Returns a mock object based on the given WSDL file.
protected
# getMockForTrait( string $traitName , array $arguments = array ( ), bool $mockClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, array $callAutoload = true, bool $mockedMethods = array ( ), $cloneArguments = false )
Returns 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.
protected
# getObjectForTrait( string $traitName , array $arguments = array ( ), bool $traitClassName = '', bool $callOriginalConstructor = true, bool $callOriginalClone = true, $callAutoload = true )
Returns an object for the specified trait.
protected
# prophesize( null|string $classOrInterface = NULL )
protected
# createResult( )
Creates a default TestResult object.
protected
# assertPreConditions( )
Performs assertions shared by all tests of a test case. This method is called between setUp() and test.
protected
# assertPostConditions( )
Performs assertions shared by all tests of a test case. This method is called between test and tearDown().
protected
# onNotSuccessfulTest( Throwable $t )
This method is called when a test method did not execute successfully.
Methods inherited from PHPUnit\Framework\Assert
assertArrayHasKey(), assertArraySubset(), assertArrayNotHasKey(), assertContains(), assertAttributeContains(), assertNotContains(), assertAttributeNotContains(), assertContainsOnly(), assertContainsOnlyInstancesOf(), assertAttributeContainsOnly(), assertNotContainsOnly(), assertAttributeNotContainsOnly(), assertCount(), assertAttributeCount(), assertNotCount(), assertAttributeNotCount(), assertEquals(), assertEqualsCanonicalizing(), assertEqualsIgnoringCase(), assertEqualsWithDelta(), assertAttributeEquals(), assertNotEquals(), assertNotEqualsCanonicalizing(), assertNotEqualsIgnoringCase(), assertNotEqualsWithDelta(), assertAttributeNotEquals(), assertEmpty(), assertAttributeEmpty(), assertNotEmpty(), assertAttributeNotEmpty(), assertGreaterThan(), assertAttributeGreaterThan(), assertGreaterThanOrEqual(), assertAttributeGreaterThanOrEqual(), assertLessThan(), assertAttributeLessThan(), assertLessThanOrEqual(), assertAttributeLessThanOrEqual(), assertFileEquals(), assertFileNotEquals(), assertStringEqualsFile(), assertStringNotEqualsFile(), assertIsReadable(), assertNotIsReadable(), assertIsWritable(), assertNotIsWritable(), assertDirectoryExists(), assertDirectoryNotExists(), assertDirectoryIsReadable(), assertDirectoryNotIsReadable(), assertDirectoryIsWritable(), assertDirectoryNotIsWritable(), assertFileExists(), assertFileNotExists(), assertFileIsReadable(), assertFileNotIsReadable(), assertFileIsWritable(), assertFileNotIsWritable(), assertTrue(), assertNotTrue(), assertFalse(), assertNotFalse(), assertNull(), assertNotNull(), assertFinite(), assertInfinite(), assertNan(), assertClassHasAttribute(), assertClassNotHasAttribute(), assertClassHasStaticAttribute(), assertClassNotHasStaticAttribute(), assertObjectHasAttribute(), assertObjectNotHasAttribute(), assertSame(), assertAttributeSame(), assertNotSame(), assertAttributeNotSame(), assertInstanceOf(), assertAttributeInstanceOf(), assertNotInstanceOf(), assertAttributeNotInstanceOf(), assertInternalType(), assertAttributeInternalType(), assertNotInternalType(), assertAttributeNotInternalType(), assertRegExp(), assertNotRegExp(), assertSameSize(), assertNotSameSize(), assertStringMatchesFormat(), assertStringNotMatchesFormat(), assertStringMatchesFormatFile(), assertStringNotMatchesFormatFile(), assertStringStartsWith(), assertStringStartsNotWith(), assertStringEndsWith(), assertStringEndsNotWith(), assertXmlFileEqualsXmlFile(), assertXmlFileNotEqualsXmlFile(), assertXmlStringEqualsXmlFile(), assertXmlStringNotEqualsXmlFile(), assertXmlStringEqualsXmlString(), assertXmlStringNotEqualsXmlString(), assertEqualXMLStructure(), assertThat(), assertJson(), assertJsonStringEqualsJsonString(), assertJsonStringNotEqualsJsonString(), assertJsonStringEqualsJsonFile(), assertJsonStringNotEqualsJsonFile(), assertJsonFileEqualsJsonFile(), assertJsonFileNotEqualsJsonFile(), logicalAnd(), logicalOr(), logicalNot(), logicalXor(), anything(), isTrue(), callback(), isFalse(), isJson(), isNull(), isFinite(), isInfinite(), isNan(), attribute(), contains(), containsOnly(), containsOnlyInstancesOf(), arrayHasKey(), equalTo(), attributeEqualTo(), isEmpty(), isWritable(), isReadable(), directoryExists(), fileExists(), greaterThan(), greaterThanOrEqual(), classHasAttribute(), classHasStaticAttribute(), objectHasAttribute(), identicalTo(), isInstanceOf(), isType(), lessThan(), lessThanOrEqual(), matchesRegularExpression(), matches(), stringStartsWith(), stringContains(), stringEndsWith(), countOf(), fail(), readAttribute(), getStaticAttribute(), getObjectAttribute(), markTestIncomplete(), markTestSkipped(), getCount(), resetCount()
Properties Summary
protected bool $backupGlobals
# NULL
protected array $backupGlobalsBlacklist
# array ( )
protected bool $backupStaticAttributes
# NULL
protected array $backupStaticAttributesBlacklist
# array ( )
protected bool $runTestInSeparateProcess
# NULL
protected bool $preserveGlobalState
# true