PHP code example of wyrihaximus / react-phpunit-run-tests-in-fiber
1. Go to this page and download the library: Download wyrihaximus/react-phpunit-run-tests-in-fiber library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wyrihaximus / react-phpunit-run-tests-in-fiber example snippets
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use React\Promise\Promise;
use WyriHaximus\React\PHPUnit\RunTestsInFibersTrait;
use function React\Async\await;
final class SomeTest extends TestCase
{
use RunTestsInFibersTrait;
/**
* @test
*/
public function happyFlow()
{
self::assertTrue(await(new Promise(static function (callable $resolve): void {
$resolve(true);
})));
}
}
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use React\Promise\Promise;
use WyriHaximus\React\PHPUnit\RunTestsInFibersTrait;
use WyriHaximus\React\PHPUnit\TimeOut;
use function React\Async\await;
#[TimeOut(30)]
final class SomeTest extends TestCase
{
use RunTestsInFibersTrait;
/**
* @test
*/
#[TimeOut(0.1)]
public function happyFlow()
{
self::assertTrue(await(new Promise(static function (callable $resolve): void {
$resolve(true);
})));
}
}