atoum/json-schema-extension

JSON Schema extension for atoum, the simple modern and intuitive unit testing framework for PHP 5.3+

2.1.0 2017-09-25 19:30 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 6ca80b0d31c778f9c55efab87cd5d2a00b480864

  • jubianchi <contact.woop@jubianchi.fr>

jsonTDDatoumtestunit testingatoum-extension

This package is auto-updated.

Last update: 2026-06-29 01:01:29 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.

👁 atoum