Download the PHP package fangx/testing without Composer
On this page you can find all versions of the php package fangx/testing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download fangx/testing
More information about fangx/testing
Files in fangx/testing
Download fangx/testing
More information about fangx/testing
Files in fangx/testing
Please rate this library. Is it a good library?
Informations about the package testing
hyperf-testing
Hyperf 中单元测试增强扩展包
- [x] 支持数据库测试.
- [ ] 支持 Http Response 直接进行断言.
- [ ] 支持 Event 断言, 而不是直接执行 Event.
- [ ] 支持 Queue 断言, 而不是直接执行 Queue.
- [ ] 支持 Http 伪造响应, 而不需要真正向第三方发送请求.
- [ ] 支持 Blade 视图渲染测试.
在 hyperf 中使用数据库进行单元测试.
推荐使用 fangx/sqlite-driver 作为数据库驱动进行测试.
为了保证测试独立, 所以每个测试完成后都会重新刷新容器. 该情况下会导致使用异步协程情况的时候, 使用
ApplicationContext::getContainer()每次获取到的容器可能不一样 在异步里面应该避免直接使用ApplicationContext::getContainer()获取容器的相关内容. Hyperf 官方推荐做法是通过构造函数直接直接注入Container, 而不是每次使用容器都通过ApplicationContext::getContainer()获取.
安装
使用
Hyperf 2.0 使用 2.1 版本, Hyperf 2.1 使用 3.* 版本
Fangx\Testing\Concerns\CommandCaller: 提供command()方法, 在程序中执行命令.Fangx\Testing\Concerns\DatabaseMigrations: 参照 laravel. 需要依赖CommandCaller执行迁移命令.Fangx\Testing\Concerns\RefreshDatabase: 参照 laravel. 需要依赖CommandCaller执行迁移命令.Fangx\Testing\Concerns\DatabaseTransactions: 参照 laravel.
运行迁移时, 默认执行的是 migrations/testing 目录下的迁移文件. 可以通过设置 getMigrationsPath 方法来自定义迁移文件的目录
使用命令创建
直接创建
在项目中的测试目录下创建 Units/UserTest.php 填入一下内容.
All versions of testing with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.2
ext-swoole Version >=4.5
hyperf/contract Version 2.*
hyperf/db-connection Version 2.*
hyperf/devtool Version 2.*
hyperf/di Version 2.*
hyperf/utils Version 2.*
phpunit/phpunit Version ^9.0
psr/container Version ^1.0
ext-swoole Version >=4.5
hyperf/contract Version 2.*
hyperf/db-connection Version 2.*
hyperf/devtool Version 2.*
hyperf/di Version 2.*
hyperf/utils Version 2.*
phpunit/phpunit Version ^9.0
psr/container Version ^1.0
The package fangx/testing contains the following files
Loading the files please wait ...