2017-12-14 06:06:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Parallel\Test\Worker;
|
|
|
|
|
|
|
|
use Amp\Parallel\Worker\DefaultWorkerFactory;
|
|
|
|
use Amp\Parallel\Worker\Worker;
|
|
|
|
use Amp\PHPUnit\TestCase;
|
|
|
|
|
2018-10-07 16:50:45 +02:00
|
|
|
class DefaultWorkerFactoryTest extends TestCase
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
/**
|
|
|
|
* @expectedException \Error
|
|
|
|
* @expectedExceptionMessage Invalid environment class name 'Invalid'
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testInvalidClassName()
|
|
|
|
{
|
2017-12-14 06:06:38 +01:00
|
|
|
$factory = new DefaultWorkerFactory("Invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException \Error
|
|
|
|
* @expectedExceptionMessage does not implement 'Amp\Parallel\Worker\Environment'
|
|
|
|
*/
|
2018-10-07 16:50:45 +02:00
|
|
|
public function testNonEnvironmentClassName()
|
|
|
|
{
|
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());
|
|
|
|
}
|
|
|
|
}
|