kuria/phpunit-extras 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kuria/phpunit-extras

Composer 安装命令:

composer require kuria/phpunit-extras

包简介

Additional functionality for PHPUnit (such as assertions)

README 文档

README

Additional functionality for PHPUnit (such as assertions).

https://travis-ci.com/kuria/phpunit-extras.svg?branch=master

Contents

Requirements

  • PHP 7.1+

Usage

AssertionTrait

This trait exposes additional assertion methods to your test case.

<?php

namespace Acme;

use Kuria\PhpUnitExtras\Traits\AssertionTrait;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    use AssertionTrait;

    function testFooBar()
    {
        $this->assertEqualIterable([1, 2, 3], new \ArrayObject([1, 2, 3]));
    }
}

assertLooselyIdentical($expected, $actual, $canonicalizeKeys = false)

Assert that two values have the same type and value, but consider different instances of the same class identical as long as they have identical properties.

If $canonicalizeKeys = TRUE, then array key order is ignored.

assertSameIterable(iterable $expected, $actual)

Assert that two iterables contain the same values and types in the same order

Types are compared the same way as with the === operator.

assertLooselyIdenticalIterable(iterable $expected, $actual, $canonicalizeKeys = false)

Assert that two iterables contain the same values and types in the same order, but consider different instances of the same class identical as long as they have identical properties.

If $canonicalizeKeys = TRUE, then array key order is ignored.

assertEqualIterable(iterable $expected, $actual)

Assert that two iterables contain equal values in any order

Types are compared the same way as with the == operator.

looselyIdenticalTo($value, $canonicalizeKeys = false)

Create the IsLooselyIdentical constraint. See assertLooselyIdentical().

identicalIterable(iterable $expected)

Create the IsIdenticalIterable constraint. See assertSameIterable().

looselyIdenticalIterable(iterable $expected, $canonicalizeKeys = false)

Create the IsLooselyIdenticalIterable constraint. See assertLooselyIdenticalIterable().

equalIterable(iterable $expected)

Create the IsEqualIterable constraint. See assertEqualIterable().

ClockTrait

Mock current time in tests.

Only affects code that uses the kuria/clock component.

<?php

namespace Acme;

use Kuria\PhpUnitExtras\Traits\ClockTrait;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    use ClockTrait;

    function testFooBar()
    {
        $this->atTime(1535904500, function () {
            // some code that uses Kuria/Clock/Clock
        });
    }
}

统计信息

  • 总下载量: 3.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固