TestHelper
Static helper methods to assist unit testing PHP code.
| since |
1.0 |
|---|---|
| package |
Joomla Framework |
Methods
assignMockCallbacks
Assigns mock callbacks to methods.
assignMockCallbacks(\PHPUnit_Framework_MockObject_MockObject mockObject, \PHPUnit\Framework\TestCase test, array array) : void
This method assumes that the mock callback is named {mock}{method name}.
| since |
1.0 |
|---|---|
| deprecated |
2.0 Manage callbacks within your test cases |
Arguments
- mockObject
\PHPUnit_Framework_MockObject_MockObjectThe mock object that the callbacks are being assigned to.- test
\PHPUnit\Framework\TestCaseThe test.- array
arrayAn array of methods names to mock with callbacks.
assignMockReturns
Assigns mock values to methods.
assignMockReturns(\PHPUnit_Framework_MockObject_MockObject mockObject, \PHPUnit\Framework\TestCase test, array array) : void
| since |
1.0 |
|---|---|
| deprecated |
2.0 Manage returns within your test cases |
Arguments
- mockObject
\PHPUnit_Framework_MockObject_MockObjectThe mock object.- test
\PHPUnit\Framework\TestCaseThe test.- array
arrayAn associative array of methods to mock with return values:
string (method name) => mixed (return value)
getValue
Helper method that gets a protected or private property in a class by reflection.
getValue(object object, string propertyName) : mixed
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- object
objectThe object from which to return the property value.- propertyName
stringThe name of the property to return.
Response
mixedThe value of the property.
invoke
Helper method that invokes a protected or private method in a class by reflection.
invoke(object object, string methodName) : mixed
Example usage:
$this->assertTrue(TestHelper::invoke($this->object, 'methodName', 123)); where 123 is the input parameter for your method
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- object
objectThe object on which to invoke the method.- methodName
stringThe name of the method to invoke.
Response
mixed
setValue
Helper method that sets a protected or private property in a class by reflection.
setValue(object object, string propertyName, mixed value) : void
| since |
1.0 |
|---|---|
| throws |
|
Arguments
- object
objectThe object for which to set the property.- propertyName
stringThe name of the property to set.- value
mixedThe value to set for the property.