mirror of
https://github.com/danog/parallel.git
synced 2024-11-30 04:39:01 +01:00
Fix tests
This commit is contained in:
parent
347132825e
commit
3c2979c18f
@ -9,14 +9,14 @@ use Icicle\Tests\Concurrent\TestCase;
|
||||
abstract class AbstractWorkerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return \Icicle\Concurrent\Worker\WorkerFactory
|
||||
* @return \Icicle\Concurrent\Worker\Worker
|
||||
*/
|
||||
abstract protected function getFactory();
|
||||
abstract protected function createWorker();
|
||||
|
||||
public function testIsRunning()
|
||||
{
|
||||
Coroutine\create(function () {
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$this->assertFalse($worker->isRunning());
|
||||
|
||||
$worker->start();
|
||||
@ -32,7 +32,7 @@ abstract class AbstractWorkerTest extends TestCase
|
||||
public function testIsIdleOnStart()
|
||||
{
|
||||
Coroutine\create(function () {
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$worker->start();
|
||||
|
||||
$this->assertTrue($worker->isIdle());
|
||||
@ -46,7 +46,7 @@ abstract class AbstractWorkerTest extends TestCase
|
||||
public function testEnqueue()
|
||||
{
|
||||
Coroutine\create(function () {
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$worker->start();
|
||||
|
||||
$returnValue = (yield $worker->enqueue(new TestTask(42)));
|
||||
@ -61,7 +61,7 @@ abstract class AbstractWorkerTest extends TestCase
|
||||
public function testEnqueueMultiple()
|
||||
{
|
||||
Coroutine\create(function () {
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$worker->start();
|
||||
|
||||
$values = (yield Awaitable\all([
|
||||
@ -81,7 +81,7 @@ abstract class AbstractWorkerTest extends TestCase
|
||||
public function testNotIdleOnEnqueue()
|
||||
{
|
||||
Coroutine\create(function () {
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$worker->start();
|
||||
|
||||
$coroutine = new Coroutine\Coroutine($worker->enqueue(new TestTask(42)));
|
||||
@ -96,7 +96,7 @@ abstract class AbstractWorkerTest extends TestCase
|
||||
|
||||
public function testKill()
|
||||
{
|
||||
$worker = $this->getFactory()->create();
|
||||
$worker = $this->createWorker();
|
||||
$worker->start();
|
||||
|
||||
$this->assertRunTimeLessThan([$worker, 'kill'], 0.2);
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Icicle\Tests\Concurrent\Worker;
|
||||
|
||||
use Icicle\Concurrent\Worker\WorkerForkFactory;
|
||||
use Icicle\Concurrent\Worker\WorkerFork;
|
||||
|
||||
/**
|
||||
* @group forking
|
||||
@ -9,8 +9,8 @@ use Icicle\Concurrent\Worker\WorkerForkFactory;
|
||||
*/
|
||||
class WorkerForkTest extends AbstractWorkerTest
|
||||
{
|
||||
protected function getFactory()
|
||||
protected function createWorker()
|
||||
{
|
||||
return new WorkerForkFactory();
|
||||
return new WorkerFork();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace Icicle\Tests\Concurrent\Worker;
|
||||
|
||||
use Icicle\Concurrent\Worker\WorkerProcessFactory;
|
||||
use Icicle\Concurrent\Worker\WorkerProcess;
|
||||
|
||||
class WorkerProcessTest extends AbstractWorkerTest
|
||||
{
|
||||
protected function getFactory()
|
||||
protected function createWorker()
|
||||
{
|
||||
return new WorkerProcessFactory();
|
||||
return new WorkerProcess();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace Icicle\Tests\Concurrent\Worker;
|
||||
|
||||
use Icicle\Concurrent\Worker\WorkerThreadFactory;
|
||||
use Icicle\Concurrent\Worker\WorkerThread;
|
||||
|
||||
/**
|
||||
* @group threading
|
||||
@ -9,8 +9,8 @@ use Icicle\Concurrent\Worker\WorkerThreadFactory;
|
||||
*/
|
||||
class WorkerThreadTest extends AbstractWorkerTest
|
||||
{
|
||||
protected function getFactory()
|
||||
protected function createWorker()
|
||||
{
|
||||
return new WorkerThreadFactory();
|
||||
return new WorkerThread();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user