TestHelper

Static helper methods to assist unit testing PHP code.

since

1.0

package

Joomla Framework

Methods

getValue

Helper method that gets a protected or private property in a class by reflection.

getValue(string|object objectOrClass, string propertyName) : mixed
static
since

1.0

throws

\InvalidArgumentExceptionif property not available.

\ReflectionException

Arguments

objectOrClass

string|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, array methodArgs) : mixed
static

Example usage:

$this->assertTrue(TestHelper::invoke($this->object, 'methodName', 123)); where 123 is the input parameter for your method

since

1.0

throws

\ReflectionException

Arguments

object

objectThe object on which to invoke the method.

methodName

stringThe name of the method to invoke.

methodArgs

arrayThe arguments to pass forward to the method being called

Response

mixed

setValue

Helper method that sets a protected or private property in a class by relfection.

setValue(object object, string propertyName, mixed value) : void
static
since

1.0

throws

\ReflectionException

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.