2017-12-14 06:06:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Parallel\Test\Worker;
|
|
|
|
|
|
|
|
use Amp\Parallel\Worker\DefaultWorkerFactory;
|
|
|
|
use Amp\Parallel\Worker\Worker;
|
2019-08-27 19:17:41 +02:00
|
|
|
use Amp\PHPUnit\AsyncTestCase;
|
2017-12-14 06:06:38 +01:00
|
|
|
|
2019-08-27 19:17:41 +02:00
|
|
|
class DefaultWorkerFactoryTest extends AsyncTestCase
|
2018-10-07 16:50:45 +02:00
|
|
|
{
|
|
|
|
public function testInvalidClassName()
|
|
|
|
{
|
2019-08-27 19:17:41 +02:00
|
|
|
$this->expectException(\Error::class);
|
|
|
|
$this->expectExceptionMessage("Invalid environment class name 'Invalid'");
|
|
|
|
|
2017-12-14 06:06:38 +01:00
|
|
|
$factory = new DefaultWorkerFactory("Invalid");
|
|
|
|
}
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testNonEnvironmentClassName()
|
|
|
|
{
|
2019-08-27 19:17:41 +02:00
|
|
|
$this->expectException(\Error::class);
|
|
|
|
$this->expectExceptionMessage("does not implement 'Amp\\Parallel\\Worker\\Environment'");
|
|
|
|
|
2017-12-14 06:06:38 +01:00
|
|
|
$factory = new DefaultWorkerFactory(DefaultWorkerFactory::class);
|
|
|
|
}
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testCreate()
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
$factory = new DefaultWorkerFactory;
|
|
|
|
|
|
|
|
$this->assertInstanceOf(Worker::class, $factory->create());
|
|
|
|
}
|
|
|
|
}
|