public function test_matcher_with_json()
{
$json = '
{
"users":[
{
"id": 131,
"firstName": "Norbert",
"lastName": "Orzechowicz",
"enabled": true,
"roles": ["ROLE_DEVELOPER"]
},
{
"id": 132,
"firstName": "Michał",
"lastName": "Dąbrowski",
"enabled": false,
"roles": ["ROLE_DEVELOPER"]
}
],
"prevPage": "http:\\/\\/example.com\\/api\\/users\\/1?limit=2",
"nextPage": "http:\\/\\/example.com\\/api\\/users\\/3?limit=2"
}';
$jsonPattern = '
{
"users":[
{
"id": "@integer@",
"firstName":"Norbert",
"lastName":"Orzechowicz",
"enabled": "@boolean@",
"roles": "@array@"
},
{
"id": "@integer@",
"firstName": "Michał",
"lastName": "Dąbrowski",
"enabled": "expr(value == false)",
"roles": "@array@"
}
],
"prevPage": "@string@",
"nextPage": "@string@"
}';
$this->assertTrue($this->matcher->match($json, $jsonPattern));
$this->assertTrue(PHPMatcher::match($json, $jsonPattern));
}