webimpress / phpunit-migration
此包已被废弃,不再维护。未建议替代包。
将您的测试迁移到最新的 PHPUnit 版本
dev-master
2021-08-02 07:00 UTC
Requires
- php: ^7.3 || ^8.0
- ext-json: *
- composer/semver: ^1.7.1 || ^2.0 || ^3.2.4
- symfony/console: ^4.4.16 || ^5.1.8
Requires (Dev)
- phpunit/phpunit: ^9.4.3
- webimpress/coding-standard: ^1.2
This package is auto-updated.
Last update: 2023-03-29 00:18:35 UTC
README
PHPUnit 迁移工具
将项目迁移到最新的 PHPUnit 版本。
[进行中] 使用时请自行承担风险 :)
如何使用此工具?
克隆项目
$ git clone https://github.com/webimpress/phpunit-migration.git
进入目录并安装依赖项
$ cd phpunit-migration $ composer install
要将您的项目更新到最新的 PHPUnit 版本,请进入项目目录并运行
$ ../path/to/phpunit-migration/bin/phpunit-migration migrate
此工具会更改什么?
- 将依赖项组合到最新的 PHPUnit 版本中,
\PHPUnit_Framework_TestCase到命名空间\PHPUnit\Framework\TestCase,setExpectedException到expectException*,setUp和tearDown到protected和正确的命名(setup=>setUp等),@cover标签中的 FQCN(例如,@covers MyClass到@covers \MyClass),assertInternalType和assertNotInternalType到更具体的断言方法(PHPUnit 7.5+),getMock到getMockBuilder以及其他必需的函数调用(PHPUnit 5.4+),- 如果可能,将
getMockBuilder(...)->...->getMock()到createMock(...)(PHPUnit 5.4+), - 使用
$delta、$maxDepth、$canonicalize和$ignoreCase参数将assertEquals()和assertNotEquals()更改为更具体的断言方法(PHPUnit 7.5+), - 将以下方法的 void 返回类型添加到:
setUp()、tearDown()、setUpBeforeClass()、tearDownAfterClass()、assertPreConditions()、assertPostConditions()、onNotSuccessfulTest(\Throwable $th)(PHPUnit 8.0+), expectExceptionMessageRegExp到expectExceptionMessageMatches(PHPUnit 8.4+),- 使用新的(更易读的)断言名称
assertNotIsReadable替换为assertIsNotReadable,assertNotIsWritable替换为assertIsNotWritable,assertDirectoryNotExists替换为assertDirectoryDoesNotExist,assertDirectoryNotIsReadable替换为assertDirectoryIsNotReadable,assertDirectoryNotIsWritable替换为assertDirectoryIsNotWritable,assertFileNotExists替换为assertFileDoesNotExist,assertFileNotIsReadable替换为assertFileIsNotReadable,assertFileNotIsWritable替换为assertFileIsNotWritable,assertRegExp替换为assertMatchesRegularExpression,assertNotRegExp替换为assertDoesNotMatchRegularExpression。(PHPUnit 9.1+),
- 待办事项:如果可能,将
getMockBuilder(...)->...->setMethods(...)->getMock()到createPartialMock(...)(PHPUnit 5.5.3+), - 待办事项:将
assertContains()和assertNotContains()在string纱线中更改为更具体的断言方法(PHPUnit 7.5+), - 待办事项:将
$this->assert到self::assert。
此工具不会做什么?
- 更改
PHPUnit_Framework_Error_*类 - 可能还有其他我现在不记得的事情 ;-)
注意
请记住,这是一个开发者工具,它应该只作为将您的测试迁移到PHPUnit新版本的辅助工具使用。迁移后,请运行所有测试以验证应用的变化是否正确,并且您的测试仍然可以正常工作!