dentelis/phpunit-json-assert
Composer 安装命令:
composer require --dev dentelis/phpunit-json-assert
包简介
PhpUnit extension for asserting json structure with dentelis/php-structure-validator
README 文档
README
PHPUnit data structure validation for JSON documents
Installation
Use the package manager composer to install Validator.
composer require dentelis/phpunit-json-assert:dev-master
Usage
Add JsonAssertions trait to your test file
<?php declare(strict_types=1); use Dentelis\PhpUnitJsonAssert\JsonAssertions; use Dentelis\StructureValidator\Type\ObjectType; use Dentelis\StructureValidator\Type\StringType; use PHPUnit\Framework\TestCase; final class CustomTest extends TestCase { use JsonAssertions; public function test(): void { $this->assertJsonStructure( '{"name":"user","email":"user@example.com"}', (new ObjectType()) ->addProperty('name', (new StringType())->assertNotEmpty()) ->addProperty('email', (new StringType())->assertEmail()) ); } }
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-06