Comments (4)
Hey, your example does not have a valid JSON, because of that PHPMatcher thinks this is just a regular text.
The following line is not correct from a json point of view.
{
"aws": {
"key": "laclédepassepartout",
"secret": "lesecretdupèrefouras",
- "@...@"
}
}
from php-matcher.
@tentacode can you try like this? :
$expectedJsonMatcher = <<<JSON
{
"aws": {
"key": "laclédepassepartout",
"secret": "lesecretdupèrefouras",
"@*@": "@*@"
}
}
JSON;
from php-matcher.
Hey, it's not the Json, but the Json Pattern, the Json is ok in the variable $actualJson
.
It should work when I read the documentation the @...@
should be supported.
https://github.com/coduo/php-matcher#json-matching-with-unbounded-arrays-and-objects
Json matching with unbounded arrays and objects
<?php
use Coduo\PHPMatcher\PHPMatcher;
$matcher = new PHPMatcher();
$matcher->match(
'{
"users":[
{
"firstName": "Norbert",
"lastName": "Orzechowicz",
"created": "2014-01-01",
"roles":["ROLE_USER", "ROLE_DEVELOPER"],
"attributes": {
"isAdmin": false,
"dateOfBirth": null,
"hasEmailVerified": true
},
"avatar": {
"url": "http://avatar-image.com/avatar.png"
}
},
{
"firstName": "Michał",
"lastName": "Dąbrowski",
"created": "2014-01-01",
"roles":["ROLE_USER", "ROLE_DEVELOPER", "ROLE_ADMIN"],
"attributes": {
"isAdmin": true,
"dateOfBirth": null,
"hasEmailVerified": true
},
"avatar": null
}
]
}',
'{
"users":[
{
"firstName": "@string@",
"lastName": "@string@",
"created": "@[email protected]()",
"roles": [
"ROLE_USER",
"@...@"
],
"attributes": {
"isAdmin": @boolean@,
"@*@": "@*@"
},
"avatar": "@[email protected]({\"url\":\"@[email protected]()\"})"
}
,
@...@
]
}'
);
from php-matcher.
@domis86 is right here, you should use "@*@" if you just want wildcard, @...@
was made for arrays, not properties.
There is also no such thing as "Json Pattern", in order to match value against pattern, json matcher must turn both of them into arrays, it's impossible to achieve that when pattern is not even a JSON.
from php-matcher.
Related Issues (20)
- UUID matcher throws error for NIL uuid HOT 8
- Not able to match @null@||@array@ HOT 1
- Fix typo in project description HOT 1
- Cannot use `match` as an identifier. It is a reserved keyword since PHP8.0 HOT 2
- Add @[email protected]() or @[email protected]('....') expanders HOT 1
- Confusing error message HOT 3
- How does the `.inArray()` pattern expander work ? HOT 3
- Expecting null but give an array throws strange runtime error HOT 3
- Make possible to use assertMatchesPattern in static methods HOT 2
- generate php-matcher checking rules from Open API swagger annotation
- ValueError: array_fill(): Argument #2 ($count) must be greater than or equal to 0
- Use of mutation testing in php-matcher - Help needed
- Cannot use positional argument after named argument HOT 1
- PHPUnit 10 support
- Consider upgrade doctrine/lexer to 2.x branch HOT 3
- Json array of object compare
- When new release with PHP Unit support? HOT 1
- Release 6.0.12 not longer compatible with PHPUnit 9 HOT 1
- Type pattern "@boolean@" is not supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-matcher.