Test helpers
This page is incomplete |
getField($loader, $fieldname = null)
A helper to access a subfield of the field $loader.
Empty $fieldname
When fieldname is empty $load is returned
Example:
$test = 10; getField($test); // Returns 10;
$fieldname is a string
When $fieldname is a string, then a member of load with this name is returned
Example:
$test = new StdClass(); $test->member = 'ABC'; getField($test, 'member'); // Returns 'ABC';
$fieldname is a array index
When $fieldname is a string containing a array index (like field[index]) this index is returned.
Example:
$test = [1,2,3]; getField($test,'[1]'); // Returns 2
$fieldname is a double array index
When $fieldname is a string containing a double array index (like field[index][index2]) this index is returned.
Example:
$test = [[1,2,3],[4,5,6][7,8,9]]; getField($test,'[1][1]'); // Returns 5
$fieldname is a arrowed string
When $fieldname is a string containing an arrow (like field->subfield) the subfield is returned.
Example:
$test = new StdClass(); $subfield = new StdClass(); $subfield->member = 'ABC'; $test->subfield = $subfield; getField($test, 'subfield->member'); // Returns 'ABC';
$fieldname is a value with array index
When $fieldname is a string containing an field with array index (like field[index]) this index is returned.
Example:
$test = new StdClass(); $array = [1,2,3]; $test->subfield = $array; getField($test,'subfield[1]'); // Returns 2
$fieldname is a double array index
When $fieldname is a string containing a double array index (like field[index][index2]) this index is returned.
Example:
$test = new StdClass(); $array = [[1,2,3],[4,5,6][7,8,9]]; $test->subfield = $array; getField($test,'subfield[1][1]'); // Returns 5
invokeMethod(object &$object, string $methodName, array $parameters = array())
This function calls the protected method $methodName of the object $object with the parameters $parameters.
Example:
callProtectedMethod(object &$object, string $methodName, array $parameters = array())
An alias to invokeMethod().
setProtectedProperty(object &$object,string $property_name,mixed $value)
This function sets the value of the protected property $property_name of the object $object to the value $value.
getProtectedProptery(object &$object,string $property_name): mixed
This method returns the protected property $property_name of the object $object.
checkArrays(array $expect, array $test): bool
This function test if every element of $expect is a memeber of the array $test. If the element of $expect is in turn an array the function is called recursivly.