12 namespace Symfony\Component\Console\Tests\Helper;
18 use Symfony\Component\Process\Process;
30 $helper->run($output, $cmd, $error);
31 $this->assertEquals($expected, $this->
getOutput($output));
41 $callback =
function () use (&$executed) { $executed =
true; };
43 $helper->run($output,
'php -r "echo 42;"', null, $callback);
44 $this->assertTrue($executed);
49 $successOutputVerbose = <<<EOT
54 $successOutputDebug = <<<EOT
60 $successOutputDebugWithTags = <<<EOT
61 RUN php -r
"echo '<info>42</info>';"
66 $successOutputProcessDebug = <<<EOT
67 RUN
'php' '-r' 'echo 42;'
72 $syntaxErrorOutputVerbose = <<<EOT
73 RUN php -r
"fwrite(STDERR, 'error message');usleep(50000);fwrite(STDOUT, 'out message');exit(252);"
74 RES 252
Command did not run successfully
77 $syntaxErrorOutputDebug = <<<EOT
78 RUN php -r
"fwrite(STDERR, 'error message');usleep(500000);fwrite(STDOUT, 'out message');exit(252);"
81 RES 252
Command did not run successfully
85 $errorMessage =
'An error occurred';
86 if (
'\\' === DIRECTORY_SEPARATOR) {
87 $successOutputProcessDebug = str_replace(
"'",
'"', $successOutputProcessDebug);
96 array($syntaxErrorOutputVerbose,
'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"',
StreamOutput::VERBOSITY_VERY_VERBOSE, null),
97 array($syntaxErrorOutputDebug,
'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"',
StreamOutput::VERBOSITY_DEBUG, null),
98 array($errorMessage.PHP_EOL,
'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"',
StreamOutput::VERBOSITY_VERBOSE, $errorMessage),
99 array($syntaxErrorOutputVerbose.$errorMessage.PHP_EOL,
'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"',
StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage),
100 array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL,
'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"',
StreamOutput::VERBOSITY_DEBUG, $errorMessage),
108 return new StreamOutput(fopen(
'php://memory',
'r+',
false), $verbosity,
false);
115 return stream_get_contents($output->
getStream());