コード例 #1
0
            expect($error)->to->not->satisfy('is_resource');
            expect($process)->to->not->satisfy('is_resource');
        });
        it('should stop a running worker', function () {
            $this->worker->run('/path/to/test.php');
            $this->worker->close();
            expect($this->worker->isRunning())->to->be->false;
            expect($this->worker->isStarted())->to->be->false;
        });
    });
    describe('->free()', function () {
        it('should make the worker stop running', function () {
            $this->worker->run('/path/to/test.php');
            $this->worker->free();
            expect($this->worker->isRunning())->to->be->false;
        });
    });
    describe('->isRunning()', function () {
        it('should set the running status to false if an open proc has exited', function () {
            $worker = new Worker('php -v', $this->emitter, new ProcOpen());
            $worker->start();
            $start = microtime(true);
            while ($worker->isRunning()) {
                $now = microtime(true) - $start;
                if ($now > 2) {
                    throw new Exception("Timeout exceeded 2 second limit");
                }
            }
        });
    });
});