Comos\Qpm\Pid\ManagerTest::testStart_Start2ProcessWithOnePidFile PHP Метод

testStart_Start2ProcessWithOnePidFile() публичный Метод

    public function testStart_Start2ProcessWithOnePidFile()
    {
        $pidfile = $this->_pidFile;
        $process = Process::fork(function () use($pidfile) {
            $man = new Manager($pidfile);
            $man->start();
            usleep(200 * 1000);
        });
        usleep(100 * 1000);
        $man1 = new Manager($pidfile);
        $process1 = $man1->getProcess();
        $this->assertTrue($process1 instanceof \Comos\Qpm\Process\Process);
        try {
            $man2 = new Manager($this->_pidFile);
            $man2->start();
            $this->fail('expects Exception');
        } catch (\Exception $e) {
            $st = 0;
            $pidfile = pcntl_wait($st);
            $this->assertEquals($pidfile, $process->getPid());
            $this->assertEquals($pidfile, $process1->getPid());
            $this->assertTrue(\pcntl_wifexited($st));
            $this->assertTrue($e instanceof \Comos\Qpm\Pid\Exception);
            $this->assertEquals('process exists, no need to start a new one', $e->getMessage());
        }
    }