wyrihaximus / async-test-utilities
api-clients 包的测试工具
8.0.5
2024-07-03 20:07 UTC
Requires
- php: ^8.2
- phpunit/phpunit: ^10.5.25
- react/async: ^4.3.0
- react/event-loop: ^1.5.0
- react/promise: ^3.2.0
- wyrihaximus/phpstan-react: ^1
- wyrihaximus/react-phpunit-run-tests-in-fiber: ^2.0.0
- wyrihaximus/test-utilities: ^6.0.9
Requires (Dev)
- react/promise-timer: ^1.11.0
Conflicts
- composer/compoer: <2.6.0
- dev-master
- 8.0.5
- 8.0.4
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0.0
- 7.3.0
- 7.2.0
- 7.1.0
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.0.25
- 5.0.24
- 5.0.23
- 5.0.22
- 5.0.21
- 5.0.20
- 5.0.19
- 5.0.18
- 5.0.17
- 5.0.16
- 5.0.15
- 5.0.14
- 5.0.12
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.7
- 5.0.6
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.0
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.24
- 3.4.23
- 3.4.22
- 3.4.21
- 3.4.20
- 3.4.19
- 3.4.18
- 3.4.17
- 3.4.16
- 3.4.15
- 3.4.14
- 3.4.13
- 3.4.12
- 3.4.11
- 3.4.10
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- 2.0.0-alpha2
- 2.0.0-alpha1
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- dev-renovate/phpunit
- dev-renovate/major-phpunit
- dev-renovate/php-8.x
- dev-Switch-to-specific-PHP-package-Renovate-config
- dev-revert-191-dependabot/composer/wyrihaximus/test-utilities-5.5.0
- dev-read-contributing-are-documentation
- dev-add-boring-cyborg
- dev-only-have-one-dependabot-pr-open-at-any-give-time
This package is auto-updated.
Last update: 2024-09-21 22:24:13 UTC
README
安装
通过 Composer 安装,使用以下命令,它将自动检测最新版本并将其与 ^
绑定。
composer require wyrihaximus/async-test-utilities
使用方法
任何测试文件都可以扩展 WyriHaximus\AsyncTestUtilities\TestCase
,并提供一些有用的功能,如用于文件存储相关测试的随机命名空间和随机目录。
由于所有测试都在纤维内部执行,因此默认超时时间为 30
秒。要降低或提高此超时,该包提供 TimeOut
属性。它可以在类和方法级别设置。当在方法级别设置时,它优先于类级别。
<?php declare(strict_types=1); namespace WyriHaximus\Tests\AsyncTestUtilities; use React\EventLoop\Loop; use WyriHaximus\AsyncTestUtilities\AsyncTestCase; use WyriHaximus\AsyncTestUtilities\TimeOut; use function React\Async\async; use function React\Async\await; use function React\Promise\resolve; use function React\Promise\Timer\sleep; use function time; #[TimeOut(0.3)] final class AsyncTestCaseTest extends AsyncTestCase { #[TimeOut(1)] public function testAllTestsAreRanInAFiber(): void { self::expectOutputString('ab'); Loop::futureTick(async(static function (): void { echo 'a'; })); await(sleep(1)); echo 'b'; } public function testExpectCallableExactly(): void { $callable = $this->expectCallableExactly(3); Loop::futureTick($callable); Loop::futureTick($callable); Loop::futureTick($callable); } public function testExpectCallableOnce(): void { Loop::futureTick($this->expectCallableOnce()); } }
许可证
MIT 许可证 (MIT)
版权所有 (c) 2023 Cees-Jan Kiewiet
特此授予任何获得此软件及其相关文档副本(“软件”)的人免费使用软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向提供软件的人授予这样做,前提是以下条件
上述版权声明和本许可声明应包含在软件的任何副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论是在合同、侵权或其他行为中产生的,无论是由于软件或其使用或其他方式。