1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/test/Worker/DefaultWorkerFactoryTest.php

34 lines
896 B
PHP
Raw Normal View History

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());
}
}