PHP code example of matthiasnoback / phpunit-asynchronicity
1. Go to this page and download the library: Download matthiasnoback/phpunit-asynchronicity 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/ */
matthiasnoback / phpunit-asynchronicity example snippets
use Asynchronicity\PHPUnit\Asynchronicity;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
final class ProcessTest extends TestCase
{
use Asynchronicity;
/**
* @test
*/
public function it_creates_a_pid_file(): void
{
// start the asynchronous process that will eventually create a PID file...
self::assertEventually(
function (): void {
Assert::assertFileExists(__DIR__ . '/pid');
}
);
}
}
use Asynchronicity\PHPUnit\Asynchronicity;
use Behat\MinkExtension\Context\MinkContext;
use PHPUnit\Framework\Assert;
final class FeatureContext extends MinkContext
{
use Asynchronicity;
/**
* @Then the stock level has been updated to :expectedStockLevel
*/
public function thenTheFileHasBeenCreated(string $expectedStockLevel): void
{
self::assertEventually(function () use ($expectedStockLevel): void {
$this->visit('/stock-levels');
$actualStockLevel = $this->getSession()->getPage())->find('css', '.stock-level')->getText();
Assert::assertEquals($expectedStockLevel, $actualStockLevel);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.