markdown PHPUnit版本中`TestCase`类中最流行的更改摘要
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown PHPUnit版本中`TestCase`类中最流行的更改摘要相关的知识,希望对你有一定的参考价值。
## Introduction
The most broadly extended class of [PHPUnit](https://phpunit.de/) is [`\PHPUnit\Framework\TestCase`](https://github.com/sebastianbergmann/phpunit/blob/HEAD/src/Framework/TestCase.php)
As PHPUnit evolved over the years, functionality has been added, deprecated and removed
This document tries to deliver an exhaustive list of which version a specific feature has been added or removed.
The main motivation behind this is make it easier to create test-code that is compattible across various PHPUnit versions.
## Version compatibility
| PHPUnit | Supported Until | Status | 5.3 | 5.4 | 5.5 | 5.6 | 7.0 | 7.1 | 7.2 | 7.3 | 7.4 |
| ------: | --------------: | :---------: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| `v8.0` | 2021 | upcoming | | | | | | | ✔ | ✔ | ✔ |
| `v7.2` | 2020 | current | | | | | | ✔ | ✔ | ✔ | |
| `v6.5` | 2019 | previous | | | | | ✔ | ✔ | ✔ | | |
| `v5.7` | 2018 | unsupported | | | | ✔ | ✔ | ✔ | | | |
| `v4.8` | 2016 | unsupported | ✔ | ✔ | ✔ | ✔ | | | | | |
## TestCase Changelog
### Classes
| Class | Added | Deprecated | Removed |
| -------------------------------------------------------- | ----------- | ---------- | ------- |
| `PHPUnit_Framework_TestCase` | `2.0` | `-` | `6.0` |
| `PHPUnit\Framework\TestCase` | `4.8`/`5.4` | `-` | `-` |
### Functions
#### New functions
| Function | Added |
| --------------------------------------------------------- | ----------- |
| `TestCase::assertDirectoryExists` | `5.6` |
| `TestCase::assertDirectoryIsReadable` | `5.6` |
| `TestCase::assertDirectoryIsWritable` | `5.6` |
| `TestCase::assertDirectoryNotExists` | `5.6` |
| `TestCase::assertDirectoryNotIsReadable` | `5.6` |
| `TestCase::assertDirectoryNotIsWritable` | `5.6` |
| `TestCase::assertFileIsReadable` | `5.6` |
| `TestCase::assertFileIsWritable` | `5.6` |
| `TestCase::assertFileNotIsReadable` | `5.6` |
| `TestCase::assertFileNotIsWritable` | `5.6` |
| `TestCase::assertFinite` | `5.0` |
| `TestCase::assertInfinite` | `5.0` |
| `TestCase::assertIsReadable` | `5.6` |
| `TestCase::assertIsWritable` | `5.6` |
| `TestCase::assertNan` | `5.0` |
| `TestCase::assertNotIsReadable` | `5.6` |
| `TestCase::assertNotIsWritable` | `5.6` |
| `TestCase::createConfiguredMock` | `5.6` |
| `TestCase::createMock` | `5.4` |
| `TestCase::createPartialMock` | `5.5` |
| `TestCase::createTestProxy` | `6.0` |
| `TestCase::expectException` | `5.2` |
| `TestCase::expectExceptionCode` | `5.2` |
| `TestCase::expectExceptionMessage` | `5.2` |
| `TestCase::expectExceptionMessageRegExp` | `5.2` |
| `TestCase::expectExceptionObject` | `6.4` |
| `TestCase::expectNotToPerformAssertions` | `7.2` |
| `TestCase::getExpectedExceptionCode` | `6.0` |
| `TestCase::getExpectedExceptionMessage` | `6.0` |
| `TestCase::registerComparator` | `6.4` |
#### Removed functions
| Function | Added | Deprecated | Removed |
| -------------------------------------------------------- | ----------- | ---------- | ------- |
| `TestCase::assertNotTag()` | `3.3` | `4.2` | `5.0` |
| `TestCase::assertSelectCount()` | `3.3` | `4.2` | `5.0` |
| `TestCase::assertSelectEquals()` | `3.3` | `4.2` | `5.0` |
| `TestCase::assertSelectRegExp()` | `3.3` | `4.2` | `5.0` |
| `TestCase::assertTag()` | `3.3` | `4.2` | `5.0` |
| `TestCase::getMock` | `3.0` | `5.4` | `6.0` |
| `TestCase::getMockObjectGenerator`<sup>(1)</sup> | `4.1` | `-` | `6.0` |
| `TestCase::getMockWithoutInvokingTheOriginalConstructor` | `5.0` | `5.4` | `6.0` |
| `TestCase::hasPerformedExpectationsOnOutput` | `3.6` | `4.3` | `6.0` |
| `TestCase::setExpectedException` | `3.2` | `5.2` | `6.0` |
| `TestCase::setExpectedExceptionRegExp` | `4.3` | `5.6` | `6.0` |
<sup>(1)</sup> Visibility changed from `protected` to `private`
### `@requires` annotation
| Function | Added |
| -------------------------------------------------------- | ----------- |
| `@requires OS` | `4.0` |
| Support for extension version | `5.2` |
| Support for comparison operators | `5.3` |
| Support for Composer-style version constraints | `6.1` |
| `@requires OSFAMILY` | `6.3` |
以上是关于markdown PHPUnit版本中`TestCase`类中最流行的更改摘要的主要内容,如果未能解决你的问题,请参考以下文章
markdown [观看Phpunit]观看phpunit测试#phpunit #test
markdown 如何在Behat FeatureContext中使用PHPUnit断言
markdown [代码覆盖率Phpunit]安装Xdebug并使用Phpunit运行代码覆盖率#xdebug #phpunit #code #coverage
markdown [漂亮的打印机] Phpunit Pretty Printer安装#phpunit #laravel #prettyprinter #intsall #php
如果重写setUp和tearDown,则不会调用PHP,phpunit和dbunit - getConnection和getDataSet