Beispiel #1
0
    public function testCommandLine()
    {
        $process = new PhpProcess(<<<'PHP'
<?php echo 'foobar';
PHP
);
        $commandLine = $process->getCommandLine();
        $f = new PhpExecutableFinder();
        $this->assertContains($f->find(), $commandLine, '::getCommandLine() returns the command line of PHP before start');
        $process->start();
        $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
        $process->wait();
        $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
    }
Beispiel #2
0
    public function testCommandLine()
    {
        if ('phpdbg' === PHP_SAPI) {
            $this->markTestSkipped('phpdbg SAPI is not supported by this test.');
        }
        $process = new PhpProcess(<<<PHP
<?php echo 'foobar';
PHP
);
        $f = new PhpExecutableFinder();
        $commandLine = $f->find();
        $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP before start');
        $process->start();
        $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
        $process->wait();
        $this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
    }
Beispiel #3
0
    /**
     * Initiates new actor in a new PHP process
     * @param integer  $id An unique id of an actor, should be free tcp-port in current implementation
     * @param callable $handler
     * @return PhpProcess
     */
    public static function createAndRun($id, callable $handler)
    {
        $serializedHandler = base64_encode((new Serializer())->serialize($handler));
        $autoloadPath = Utils::getAutoloadPath();
        $process = new PhpProcess(<<<EOF
    <?php
        require '{$autoloadPath}';
        \\Phactor\\Phactor\\Actor::initializeChild({$id}, '{$serializedHandler}');
    ?>
EOF
);
        if (null === $process->getCommandLine()) {
            $process->setPhpBinary(PHP_BINARY);
        }
        // workaround for portable windows php
        $process->start();
        return $process;
    }
Beispiel #4
0
 /**
  * @return CommandLine
  */
 public function getCommandLine()
 {
     return new CommandLine(parent::getCommandLine());
 }