Testomatio - Test Management for Codeception
JsonType matches JSON structures against templates. You can specify the type of fields in JSON or add additional validation rules.
JsonType is used by REST module in seeResponseMatchesJsonType
and dontSeeResponseMatchesJsonType
methods.
Usage example:
Class JsonType @package Codeception\Util
public __construct($jsonArray)
param $jsonArray array |
JsonArray |
Creates instance of JsonType
Pass an array or \Codeception\Util\JsonArray
with data.
If non-associative array is passed - the very first element of it will be used for matching.
public static addCustomFilter($name, callable $callable)
param string
$nameparam callable
$callablereturn void
Adds custom filter to JsonType list.
You should specify a name and parameters of a filter.
Example:
public static cleanCustomFilters()
return void
Removes all custom filters
public matches(array $jsonType)
param array
$jsonTypereturn string|bool
Checks data against passed JsonType.
If matching fails function returns a string with a message describing failure.
On success returns true
.