本文整理汇总了PHP中Symfony\Component\Process\PhpProcess::wait方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpProcess::wait方法的具体用法?PHP PhpProcess::wait怎么用?PHP PhpProcess::wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\PhpProcess
的用法示例。
在下文中一共展示了PhpProcess::wait方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNonBlockingWorks
public function testNonBlockingWorks()
{
$expected = 'hello world!';
$process = new PhpProcess(<<<PHP
<?php echo '{$expected}';
PHP
);
$process->start();
$process->wait();
$this->assertEquals($expected, $process->getOutput());
}
示例2: testCommandLine
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');
}
示例3: testCommandLine
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');
}
示例4: testCompressEventsKate
/**
* @medium
* @dataProvider backends
*/
public function testCompressEventsKate($backend)
{
// CREATE web.scssdx1493.new
// MODIFY web.scssdx1493.new
// MOVED_FROM web.scssdx1493.new
// MOVED_TO web.scss
if (!$backend->isAvailable()) {
$this->markTestSkipped();
}
$f = __DIR__ . '/test/';
sleep(1);
$php = "<?php sleep(2);\n file_put_contents('{$f}foo.txtdx1493.new', 'x');\n rename('{$f}foo.txtdx1493.new', '{$f}foo.txt');\n\n file_put_contents('{$f}stop.txt', 'x');\n ";
$process = new PhpProcess($php);
$process->start();
$gotEvents = array();
$backend->setPath(__DIR__ . '/test');
$backend->addListener(ModifyEvent::NAME, function ($e) use(&$gotEvents, $backend) {
$gotEvents[] = 'modify';
});
$backend->addListener(CreateEvent::NAME, function ($e) use(&$gotEvents, $backend) {
if ($e->filename == __DIR__ . '/test/stop.txt') {
$backend->stop();
} else {
$gotEvents[] = 'create';
}
});
$backend->addListener(DeleteEvent::NAME, function ($e) use(&$gotEvents, $backend) {
$gotEvents[] = 'delete';
});
$backend->addListener(MoveEvent::NAME, function ($e) use(&$gotEvents, $backend) {
$gotEvents[] = 'move';
});
$backend->start();
$process->wait();
$this->assertTrue($process->isSuccessful());
$this->assertEquals($gotEvents, array('modify'));
}
示例5: wait
/**
* Waits for the process to terminate.
*
* The callback receives the type of output (out or err) and some bytes
* from the output in real-time while writing the standard input to the process.
* It allows to have feedback from the independent process during execution.
*
* @param callable|null $callback A valid PHP callback
*
* @throws RuntimeException When process timed out
* @throws RuntimeException When process stopped after receiving signal
* @throws LogicException When process is not yet started
*
* @return int The returnValue of the Closure
*/
public function wait($callback = null)
{
parent::wait($callback);
return $this->getReturnValue();
}