atoum / json-schema-extension
为 atoum 提供的 JSON Schema 扩展,atoum 是一个简单、现代且直观的 PHP 5.3+ 单元测试框架。
2.1.0
2017-09-25 19:30 UTC
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-08-29 04:35:09 UTC
README
此扩展可验证您的 JSON 字符串是否符合 JSON-Schema 规范。
它还会检查字符串是否为有效的 JSON 字符串。
示例
<?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') ; } }
安装它
使用 composer 安装扩展
composer require --dev atoum/json-schema-extension
使用 atoum 配置文件启用扩展
<?php // .atoum.php require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; use mageekguy\atoum\jsonSchema; $runner->addExtension(new jsonSchema\extension($script));
链接
许可
json-schema-extension 在 BSD-3-Clause 许可下发布。有关详细信息,请参阅捆绑的 LICENSE 文件。