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'); }
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'); }
/** * 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; }
/** * @return CommandLine */ public function getCommandLine() { return new CommandLine(parent::getCommandLine()); }