1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-03 10:07:49 +01:00
parallel/test/Context/DefaultContextFactoryTest.php
2020-02-14 17:22:41 -06:00

29 lines
823 B
PHP

<?php
namespace Amp\Parallel\Test\Context;
use Amp\Parallel\Context\Context;
use Amp\Parallel\Context\DefaultContextFactory;
use Amp\Parallel\Sync\ContextPanicError;
use Amp\PHPUnit\AsyncTestCase;
class DefaultWorkerFactoryTest extends AsyncTestCase
{
public function testCreate(): void
{
$factory = new DefaultContextFactory;
$context = $factory->create(__DIR__ . '/Fixtures/test-process.php');
$this->assertInstanceOf(Context::class, $context);
}
public function testRun(): \Generator
{
$this->expectException(ContextPanicError::class);
$this->expectExceptionMessage('No string provided');
$factory = new DefaultContextFactory;
$context = yield $factory->run(__DIR__ . '/Fixtures/test-process.php');
yield $context->join();
}
}