承接 dentelis/phpunit-json-assert 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-06