wyrihaximus / async-test-utilities
Test utilities for api-clients packages
Fund package maintenance!
WyriHaximus
Installs: 553 358
Dependents: 105
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 6
Language:Makefile
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/php-8.x
- dev-dependabot/composer/symfony/process-7.1.7
- dev-dependabot/composer/symfony/validator-7.1.7
- dev-renovate/major-phpunit
- dev-renovate/phpunit
- 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-11-21 20:13:24 UTC
README
Installation
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^
.
composer require wyrihaximus/async-test-utilities
Usage
Any test file can extend WyriHaximus\AsyncTestUtilities\TestCase
and it comes with some goodies such as random
namespaces and random directories to use for file storage related tests.
Since all tests are executed inside a fiber, there is a default timeout of 30
seconds. To lower or raise that timeout
this package comes with a TimeOut
attribute. It can be set on the class and method level. When set on both the method level it takes priority over the class level.
<?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()); } }
License
The MIT License (MIT)
Copyright (c) 2023 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.