minor #14975 [Console] Fix tests on Windows (mhujer)

This PR was squashed before being merged into the 2.7 branch (closes #14975).

Discussion
----------

[Console] Fix tests on Windows

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14975
| License       | MIT
| Doc PR        | none

Commits
-------

4f0f7ea [Console] Fix tests on Windows
This commit is contained in:
Fabien Potencier 2015-06-16 17:28:26 +02:00
commit daa38cf559
2 changed files with 23 additions and 24 deletions

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Console\Tests\Helper;
use Symfony\Component\Console\Helper\DebugFormatterHelper; use Symfony\Component\Console\Helper\DebugFormatterHelper;
use Symfony\Component\Console\Helper\HelperSet; use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Output\StreamOutput; use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Helper\ProcessHelper; use Symfony\Component\Console\Helper\ProcessHelper;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
@ -59,7 +58,7 @@ EOT;
EOT; EOT;
$successOutputDebugWithTags = <<<EOT $successOutputDebugWithTags = <<<EOT
RUN php -r "echo \"<info>42</info>\";" RUN php -r "echo '<info>42</info>';"
OUT <info>42</info> OUT <info>42</info>
RES Command ran successfully RES Command ran successfully
@ -92,7 +91,7 @@ EOT;
array('', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null), array('', 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERBOSE, null),
array($successOutputVerbose, 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERY_VERBOSE, null), array($successOutputVerbose, 'php -r "echo 42;"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
array($successOutputDebug, 'php -r "echo 42;"', StreamOutput::VERBOSITY_DEBUG, null), array($successOutputDebug, 'php -r "echo 42;"', StreamOutput::VERBOSITY_DEBUG, null),
array($successOutputDebugWithTags, 'php -r "echo \"<info>42</info>\";"', StreamOutput::VERBOSITY_DEBUG, null), array($successOutputDebugWithTags, 'php -r "echo \'<info>42</info>\';"', StreamOutput::VERBOSITY_DEBUG, null),
array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null), array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null),
array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null), array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null),
array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null), array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null),

View File

@ -323,17 +323,17 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
rewind($output->getStream()); rewind($output->getStream());
$this->assertEquals( $this->assertEquals(
" 0/200 [>---------------------------] 0%\n". ' 0/200 [>---------------------------] 0%'.PHP_EOL.
" 20/200 [==>-------------------------] 10%\n". ' 20/200 [==>-------------------------] 10%'.PHP_EOL.
" 40/200 [=====>----------------------] 20%\n". ' 40/200 [=====>----------------------] 20%'.PHP_EOL.
" 60/200 [========>-------------------] 30%\n". ' 60/200 [========>-------------------] 30%'.PHP_EOL.
" 80/200 [===========>----------------] 40%\n". ' 80/200 [===========>----------------] 40%'.PHP_EOL.
" 100/200 [==============>-------------] 50%\n". ' 100/200 [==============>-------------] 50%'.PHP_EOL.
" 120/200 [================>-----------] 60%\n". ' 120/200 [================>-----------] 60%'.PHP_EOL.
" 140/200 [===================>--------] 70%\n". ' 140/200 [===================>--------] 70%'.PHP_EOL.
" 160/200 [======================>-----] 80%\n". ' 160/200 [======================>-----] 80%'.PHP_EOL.
" 180/200 [=========================>--] 90%\n". ' 180/200 [=========================>--] 90%'.PHP_EOL.
" 200/200 [============================] 100%", ' 200/200 [============================] 100%',
stream_get_contents($output->getStream()) stream_get_contents($output->getStream())
); );
} }
@ -349,9 +349,9 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
rewind($output->getStream()); rewind($output->getStream());
$this->assertEquals( $this->assertEquals(
" 0/50 [>---------------------------] 0%\n". ' 0/50 [>---------------------------] 0%'.PHP_EOL.
" 25/50 [==============>-------------] 50%\n". ' 25/50 [==============>-------------] 50%'.PHP_EOL.
" 50/50 [============================] 100%", ' 50/50 [============================] 100%',
stream_get_contents($output->getStream()) stream_get_contents($output->getStream())
); );
} }
@ -364,8 +364,8 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
rewind($output->getStream()); rewind($output->getStream());
$this->assertEquals( $this->assertEquals(
" 0 [>---------------------------]\n". ' 0 [>---------------------------]'.PHP_EOL.
" 1 [->--------------------------]", ' 1 [->--------------------------]',
stream_get_contents($output->getStream()) stream_get_contents($output->getStream())
); );
} }
@ -500,7 +500,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
$mem = 100000 * $i; $mem = 100000 * $i;
$colors = $i++ ? '41;37' : '44;37'; $colors = $i++ ? '41;37' : '44;37';
return "\033[".$colors."m ".Helper::formatMemory($mem)." \033[0m"; return "\033[".$colors.'m '.Helper::formatMemory($mem)." \033[0m";
}); });
$bar->setFormat(" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n 🏁 %remaining:-10s% %memory:37s%"); $bar->setFormat(" \033[44;37m %title:-37s% \033[0m\n %current%/%max% %bar% %percent:3s%%\n 🏁 %remaining:-10s% %memory:37s%");
$bar->setBarCharacter($done = "\033[32m●\033[0m"); $bar->setBarCharacter($done = "\033[32m●\033[0m");
@ -518,17 +518,17 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
$this->generateOutput( $this->generateOutput(
" \033[44;37m Starting the demo... fingers crossed \033[0m\n". " \033[44;37m Starting the demo... fingers crossed \033[0m\n".
" 0/15 ".$progress.str_repeat($empty, 26)." 0%\n". ' 0/15 '.$progress.str_repeat($empty, 26)." 0%\n".
" \xf0\x9f\x8f\x81 1 sec \033[44;37m 0 B \033[0m" " \xf0\x9f\x8f\x81 1 sec \033[44;37m 0 B \033[0m"
). ).
$this->generateOutput( $this->generateOutput(
" \033[44;37m Looks good to me... \033[0m\n". " \033[44;37m Looks good to me... \033[0m\n".
" 4/15 ".str_repeat($done, 7).$progress.str_repeat($empty, 19)." 26%\n". ' 4/15 '.str_repeat($done, 7).$progress.str_repeat($empty, 19)." 26%\n".
" \xf0\x9f\x8f\x81 1 sec \033[41;37m 97 KiB \033[0m" " \xf0\x9f\x8f\x81 1 sec \033[41;37m 97 KiB \033[0m"
). ).
$this->generateOutput( $this->generateOutput(
" \033[44;37m Thanks, bye \033[0m\n". " \033[44;37m Thanks, bye \033[0m\n".
" 15/15 ".str_repeat($done, 28)." 100%\n". ' 15/15 '.str_repeat($done, 28)." 100%\n".
" \xf0\x9f\x8f\x81 1 sec \033[41;37m 195 KiB \033[0m" " \xf0\x9f\x8f\x81 1 sec \033[41;37m 195 KiB \033[0m"
), ),
stream_get_contents($output->getStream()) stream_get_contents($output->getStream())
@ -570,7 +570,7 @@ class ProgressBarTest extends \PHPUnit_Framework_TestCase
} }
/** /**
* Provides each defined format * Provides each defined format.
* *
* @return array * @return array
*/ */