1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-27 04:44:56 +01:00

Fix worker tests to not use kill() so much

This commit is contained in:
coderstephen 2015-08-31 12:57:40 -05:00
parent 3df0194563
commit 3ee7e7ab0d

View File

@ -14,25 +14,32 @@ abstract class AbstractWorkerTest extends TestCase
public function testIsRunning()
{
$worker = $this->createWorker();
$this->assertFalse($worker->isRunning());
Coroutine\create(function () {
$worker = $this->createWorker();
$this->assertFalse($worker->isRunning());
$worker->start();
$this->assertTrue($worker->isRunning());
$worker->start();
$this->assertTrue($worker->isRunning());
$worker->kill();
sleep(1);
$this->assertFalse($worker->isRunning());
yield $worker->shutdown();
$this->assertFalse($worker->isRunning());
})->done();
Loop\run();
}
public function testIsIdleOnStart()
{
$worker = $this->createWorker();
$worker->start();
Coroutine\create(function () {
$worker = $this->createWorker();
$worker->start();
$this->assertTrue($worker->isIdle());
$this->assertTrue($worker->isIdle());
$worker->kill();
yield $worker->shutdown();
})->done();
Loop\run();
}
public function testEnqueue()