mhujer/consistence-phpunit

为来自 consistence/consistence 的 Enums 添加 PHPUnit 断言

2.1 2023-04-20 08:50 UTC

This package is auto-updated.

Last update: 2024-09-20 11:35:57 UTC


README

Build Status Latest Stable Version Total Downloads License Coverage Status

此库提供了用于 consistence/consistence 枚举的 EnumAssert PHPUnit 断言。

安装

$ composer require --dev mhujer/consistence-phpunit

使用方法

  1. use \Mhujer\ConsistencePhpunit\EnumAssert;

  2. 使用此断言的方式

EnumAssert::assertSame($expectedEnum, $actualEnum);

例如:

public function testEnumsAreSame(): void
{
    EnumAssert::assertSame(CardColor::get(CardColor::RED), CardColor::get(CardColor::BLACK));

    // Expected "Mhujer\ConsistencePhpunit\Fixtures\CardColor:red", but got "Mhujer\ConsistencePhpunit\Fixtures\CardColor:black
}

需求

支持 PHP 8.1 或更高版本和 PHPUnit 9.3 或更高版本。

提交错误和功能请求

错误和功能请求在 GitHub 上跟踪

作者

Martin Hujer

变更日志

2.0.0 (2022-09-20)

  • 需要 PHP 8.1+
  • 添加对原生枚举的支持,以便更容易进行迁移

1.2.0 (2021-02-28)

  • 需要 PHP 7.4+
  • 允许 PHP 8.0
  • 需要 PHPUnit 9.3+

1.1.0 (2020-02-07)

  • 允许 PHPUnit 9

1.0.0 (2019-11-24)

  • 初始版本