Implemented comparison for json structure by types #2391

Merged
merged 2 commits into from Sep 27, 2015

Conversation

Projects
None yet
1 participant
@DavertMik
Member

DavertMik commented Sep 21, 2015

REST module can now also check JSON data by field types.
Idea taken from #2373

Examples:

"{\"id\":11,\"retweeted\":false,\"in_reply_to_screen_name\":null,\"user\":{\"url\":\"http:\\/\\/davert.com\"}}"

can be matched with

<?php
$I->seeResponseMatchesJsonType(['id' => 'integer:>10',
        'retweeted' => 'Boolean',
        'in_reply_to_screen_name' => 'null|string',
        'user' => [
          'url' => 'String:url'
        ]
]);
?>

ToDo

  • implement specifying JSON part to check with JSONPath
  • add DateTime type
  • add more filters: email, >=, <=, ... etc
  • implment custom filters
  • write JsonType reference

@DavertMik DavertMik added this to the 2.1.3 milestone Sep 21, 2015

DavertMik added some commits Sep 21, 2015

implemented comparison for json structure by types
JsonArray should not be modified

JsonArrayTest should not be modified

updated changelog

added @part annotation for JsonTypes

matching can be specified with JsonPath

added custom filters to JsonType, written a reference for it

fixed version of this feature

DavertMik added a commit that referenced this pull request Sep 27, 2015

Merge pull request #2391 from Codeception/feature-json-type
Implemented comparison for json structure by types

@DavertMik DavertMik merged commit 03b868c into 2.1 Sep 27, 2015

3 checks passed

continuous-integration/appveyor AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@DavertMik DavertMik deleted the feature-json-type branch Oct 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment