1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-04 10:38:30 +01:00
parallel/test/Context/DefaultContextFactoryTest.php

29 lines
823 B
PHP
Raw Normal View History

2020-02-15 00:22:41 +01:00
<?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();
}
}