atoum / json-schema-extension
JSON Schema extension for atoum, the simple modern and intuitive unit testing framework for PHP 5.3+
Installs: 4 435
Dependents: 4
Suggesters: 0
Security: 0
Stars: 8
Watchers: 10
Forks: 4
Open Issues: 2
Requires
- php: ^5.6.0 || ^7.0.0
- atoum/atoum: ^3.0
- justinrainbow/json-schema: >=3.0.0 <=6.0.0
Requires (Dev)
- atoum/praspel-extension: ^0.16||^0.17
- hoa/compiler: ^3.16.08.15
- hoa/iterator: ^2.16.03.15
- hoa/praspel: ^1.16.01.14
This package is auto-updated.
Last update: 2024-11-29 05:09:22 UTC
README
This extension validates your JSON strings against a JSON-Schema specification.
It also checks if a string a valid JSON string.
Example
<?php namespace jubianchi\example\json; use atoum; class foo extends atoum\test { public function testIsJson() { $this ->given($string = '{"foo": "bar"}') ->then ->json($string) ; } public function testValidatesSchema() { $this ->given($string = '["foo", "bar"]') ->then ->json($string)->validates('{"title": "test", "type": "array"}') ->json($string)->validates('/path/to/json.schema') ; } }
Install it
Install extension using composer:
composer require --dev atoum/json-schema-extension
Enable the extension using atoum configuration file:
<?php // .atoum.php require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; use mageekguy\atoum\jsonSchema; $runner->addExtension(new jsonSchema\extension($script));
Links
License
json-schema-extension is released under the BSD-3-Clause License. See the bundled LICENSE file for details.