Merge branch '3.0'
* 3.0: [Process] Fix transient test on Windows [Process] Make tests more deterministic [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace [Validator] fixed wrong php docs Improved the design of the web debug toolbar [Routing] Skip PhpGeneratorDumperTest::testDumpWithTooManyRoutes on HHVM [Process] More robustness and deterministic tests
This commit is contained in:
commit
676ddab73b
@ -7,6 +7,9 @@
|
||||
'subtle_border_and_shadow': 'background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2);'
|
||||
} %}
|
||||
|
||||
{# when updating any of these colors, do the same in toolbar.css.twig #}
|
||||
{% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %}
|
||||
|
||||
{# Normalization
|
||||
(normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css)
|
||||
========================================================================= #}
|
||||
@ -232,9 +235,9 @@ table tbody ul {
|
||||
padding: 3px 7px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.label.status-success { background: #5E976E; color: #FFF; }
|
||||
.label.status-warning { background: #BC8034; color: #FFF; }
|
||||
.label.status-error { background: #B0413E; color: #FFF; }
|
||||
.label.status-success { background: {{ colors.success|raw }}; color: #FFF; }
|
||||
.label.status-warning { background: {{ colors.warning|raw }}; color: #FFF; }
|
||||
.label.status-error { background: {{ colors.error|raw }}; color: #FFF; }
|
||||
|
||||
{# Metrics
|
||||
------------------------------------------------------------------------- #}
|
||||
@ -342,10 +345,10 @@ tr.status-warning td {
|
||||
}
|
||||
|
||||
.status-warning .colored {
|
||||
color: #BC8034;
|
||||
color: {{ colors.warning|raw }};
|
||||
}
|
||||
.status-error .colored {
|
||||
color: #B0413E;
|
||||
color: {{ colors.error|raw }};
|
||||
}
|
||||
|
||||
{# Syntax highlighting
|
||||
@ -469,9 +472,9 @@ tr.status-warning td {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#summary .status-success { background: #5E976E; }
|
||||
#summary .status-warning { background: #BC8034; }
|
||||
#summary .status-error { background: #B0413E; }
|
||||
#summary .status-success { background: {{ colors.success|raw }}; }
|
||||
#summary .status-warning { background: {{ colors.warning|raw }}; }
|
||||
#summary .status-error { background: {{ colors.error|raw }}; }
|
||||
|
||||
#summary .status-success h2,
|
||||
#summary .status-success h2 a,
|
||||
@ -670,10 +673,10 @@ tr.status-warning td {
|
||||
}
|
||||
|
||||
#menu-profiler .label-status-warning .count {
|
||||
background: #BC8034;
|
||||
background: {{ colors.warning|raw }};
|
||||
}
|
||||
#menu-profiler .label-status-error .count {
|
||||
background: #B0413E;
|
||||
background: {{ colors.error|raw }};
|
||||
}
|
||||
|
||||
{# Timeline panel
|
||||
|
@ -1,3 +1,6 @@
|
||||
{# when updating any of these colors, do the same in profiler.css.twig #}
|
||||
{% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %}
|
||||
|
||||
.sf-minitoolbar {
|
||||
background-color: #222;
|
||||
border-top-left-radius: 4px;
|
||||
@ -46,8 +49,8 @@
|
||||
}
|
||||
.sf-toolbarreset svg,
|
||||
.sf-toolbarreset img {
|
||||
max-height: 24px;
|
||||
max-width: 24px;
|
||||
max-height: 20px;
|
||||
max-width: 20px;
|
||||
}
|
||||
|
||||
.sf-toolbarreset .hide-button {
|
||||
@ -180,30 +183,31 @@
|
||||
padding: 3px 6px;
|
||||
margin-bottom: 2px;
|
||||
vertical-align: middle;
|
||||
min-width: 6px;
|
||||
min-width: 15px;
|
||||
min-height: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sf-toolbar-block .sf-toolbar-status-green {
|
||||
background-color: rgba(117, 158, 43, 0.8);
|
||||
background-color: {{ colors.success|raw }};
|
||||
}
|
||||
.sf-toolbar-block .sf-toolbar-status-red {
|
||||
background-color: rgba(200, 43, 43, 0.8);
|
||||
background-color: {{ colors.error|raw }};
|
||||
}
|
||||
.sf-toolbar-block .sf-toolbar-status-yellow {
|
||||
background-color: rgb(189, 132, 0);
|
||||
background-color: {{ colors.warning|raw }};
|
||||
}
|
||||
|
||||
.sf-toolbar-block.sf-toolbar-status-green {
|
||||
background-color: rgba(117, 158, 43, 0.8);
|
||||
background-color: {{ colors.success|raw }};
|
||||
color: #FFF;
|
||||
}
|
||||
.sf-toolbar-block.sf-toolbar-status-red {
|
||||
background-color: rgba(200, 43, 43, 0.8);
|
||||
background-color: {{ colors.error|raw }};
|
||||
color: #FFF;
|
||||
}
|
||||
.sf-toolbar-block.sf-toolbar-status-yellow {
|
||||
background-color: rgb(189, 132, 0);
|
||||
background-color: {{ colors.warning|raw }};
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,12 @@ class PhpProcess extends Process
|
||||
$php .= ' '.ProcessUtils::escapeArgument($file);
|
||||
$script = null;
|
||||
}
|
||||
if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
|
||||
// exec is mandatory to deal with sending a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
$php = 'exec '.$php;
|
||||
}
|
||||
|
||||
parent::__construct($php, $cwd, $env, $script, $timeout, $options);
|
||||
}
|
||||
|
@ -76,12 +76,12 @@ class Process
|
||||
|
||||
private static $sigchild;
|
||||
private static $posixSignals = array(
|
||||
1 => 1, // SIGHUP
|
||||
2 => 2, // SIGINT
|
||||
3 => 3, // SIGQUIT
|
||||
6 => 6, // SIGABRT
|
||||
14 => 14, // SIGALRM
|
||||
15 => 15, // SIGTERM
|
||||
1, // SIGHUP
|
||||
2, // SIGINT
|
||||
3, // SIGQUIT
|
||||
6, // SIGABRT
|
||||
14, // SIGALRM
|
||||
15, // SIGTERM
|
||||
);
|
||||
|
||||
/**
|
||||
@ -285,11 +285,19 @@ class Process
|
||||
if (!isset($this->options['bypass_shell'])) {
|
||||
$this->options['bypass_shell'] = true;
|
||||
}
|
||||
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
$descriptors[3] = array('pipe', 'w');
|
||||
|
||||
$commandline = '';
|
||||
foreach (self::$posixSignals as $s) {
|
||||
$commandline .= "trap 'echo s$s >&3' $s;";
|
||||
}
|
||||
|
||||
$ptsWorkaround = null;
|
||||
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
|
||||
$commandline .= '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
|
||||
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
|
||||
|
||||
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
// Workaround for the bug, when PTS functionality is enabled.
|
||||
// @see : https://bugs.php.net/69442
|
||||
$ptsWorkaround = fopen(__FILE__, 'r');
|
||||
@ -297,15 +305,15 @@ class Process
|
||||
|
||||
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
|
||||
|
||||
if ($ptsWorkaround) {
|
||||
fclose($ptsWorkaround);
|
||||
}
|
||||
|
||||
if (!is_resource($this->process)) {
|
||||
throw new RuntimeException('Unable to launch a new process.');
|
||||
}
|
||||
$this->status = self::STATUS_STARTED;
|
||||
|
||||
if (isset($descriptors[3])) {
|
||||
$this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
|
||||
}
|
||||
|
||||
if ($this->tty) {
|
||||
return;
|
||||
}
|
||||
@ -596,8 +604,6 @@ class Process
|
||||
public function getExitCode()
|
||||
{
|
||||
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
$this->stop(0);
|
||||
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
|
||||
}
|
||||
|
||||
@ -651,8 +657,6 @@ class Process
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
$this->stop(0);
|
||||
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||
}
|
||||
|
||||
@ -674,8 +678,6 @@ class Process
|
||||
$this->requireProcessIsTerminated(__FUNCTION__);
|
||||
|
||||
if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
|
||||
$this->stop(0);
|
||||
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
|
||||
}
|
||||
|
||||
@ -1185,14 +1187,7 @@ class Process
|
||||
return $result = false;
|
||||
}
|
||||
|
||||
$proc = @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
|
||||
if (is_resource($proc)) {
|
||||
proc_close($proc);
|
||||
|
||||
return $result = true;
|
||||
}
|
||||
|
||||
return $result = false;
|
||||
return $result = (bool) @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1207,22 +1202,8 @@ class Process
|
||||
} else {
|
||||
$this->processPipes = UnixPipes::create($this, $this->input);
|
||||
}
|
||||
$descriptors = $this->processPipes->getDescriptors($this->outputDisabled);
|
||||
|
||||
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
|
||||
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
|
||||
$descriptors[3] = array('pipe', 'w');
|
||||
|
||||
$trap = '';
|
||||
foreach (self::$posixSignals as $s) {
|
||||
$trap .= "trap 'echo s$s >&3' $s;";
|
||||
}
|
||||
|
||||
$this->commandline = $trap.'{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
|
||||
$this->commandline .= 'pid=$!; echo p$pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
|
||||
}
|
||||
|
||||
return $descriptors;
|
||||
return $this->processPipes->getDescriptors($this->outputDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1340,10 +1321,13 @@ class Process
|
||||
$this->fallbackStatus['signaled'] = true;
|
||||
$this->fallbackStatus['exitcode'] = -1;
|
||||
$this->fallbackStatus['termsig'] = (int) substr($data, 1);
|
||||
} elseif ('x' === $data[0] && !isset($this->fallbackStatus['signaled'])) {
|
||||
} elseif ('x' === $data[0]) {
|
||||
$this->fallbackStatus['running'] = false;
|
||||
if (!isset($this->fallbackStatus['signaled'])) {
|
||||
$this->fallbackStatus['exitcode'] = (int) substr($data, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$callback($type === self::STDOUT ? self::OUT : self::ERR, $data);
|
||||
}
|
||||
@ -1423,14 +1407,6 @@ class Process
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled() && !isset(self::$posixSignals[$signal]) && !(function_exists('posix_kill') && @posix_kill($this->getPid(), $signal))) {
|
||||
if ($throwException) {
|
||||
throw new RuntimeException('This PHP has been compiled with --enable-sigchild and posix_kill() is not available.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
|
||||
if ($exitCode && $this->isRunning()) {
|
||||
@ -1440,15 +1416,22 @@ class Process
|
||||
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
|
||||
$ok = @proc_terminate($this->process, $signal);
|
||||
} elseif (function_exists('posix_kill')) {
|
||||
$ok = @posix_kill($this->getPid(), $signal);
|
||||
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $this->getPid()), array(2 => array('pipe', 'w')), $pipes)) {
|
||||
$ok = false === fgets($pipes[2]);
|
||||
}
|
||||
|
||||
if (true !== @proc_terminate($this->process, $signal) && '\\' !== DIRECTORY_SEPARATOR) {
|
||||
if (!$ok) {
|
||||
if ($throwException) {
|
||||
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->latestSignal = (int) $signal;
|
||||
$this->fallbackStatus['signaled'] = true;
|
||||
|
@ -30,16 +30,18 @@ function handleSignal($signal)
|
||||
break;
|
||||
}
|
||||
|
||||
echo "received signal $name\n";
|
||||
echo "signal $name\n";
|
||||
}
|
||||
|
||||
declare (ticks = 1);
|
||||
pcntl_signal(SIGTERM, 'handleSignal');
|
||||
pcntl_signal(SIGINT, 'handleSignal');
|
||||
|
||||
echo 'received ';
|
||||
|
||||
$duration = isset($argv[1]) ? (int) $argv[1] : 3;
|
||||
$start = microtime(true);
|
||||
|
||||
while ($duration > (microtime(true) - $start)) {
|
||||
usleep(1000);
|
||||
usleep(10000);
|
||||
pcntl_signal_dispatch();
|
||||
}
|
||||
|
@ -24,12 +24,23 @@ use Symfony\Component\Process\Process;
|
||||
class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private static $phpBin;
|
||||
private static $sigchild;
|
||||
private static $notEnhancedSigchild = false;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$phpBin = new PhpExecutableFinder();
|
||||
self::$phpBin = 'phpdbg' === PHP_SAPI ? 'php' : $phpBin->find();
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
// exec is mandatory to deal with sending a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
self::$phpBin = 'exec '.self::$phpBin;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
phpinfo(INFO_GENERAL);
|
||||
self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
|
||||
}
|
||||
|
||||
public function testThatProcessDoesNotThrowWarningDuringRun()
|
||||
@ -78,20 +89,18 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testStopWithTimeoutIsActuallyWorking()
|
||||
{
|
||||
// exec is mandatory here since we send a signal to the process
|
||||
// see https://github.com/symfony/symfony/issues/5030 about prepending
|
||||
// command with exec
|
||||
$p = $this->getProcess('exec '.self::$phpBin.' '.__DIR__.'/NonStopableProcess.php 3');
|
||||
$p = $this->getProcess(self::$phpBin.' '.__DIR__.'/NonStopableProcess.php 30');
|
||||
$p->start();
|
||||
usleep(100000);
|
||||
$start = microtime(true);
|
||||
$p->stop(1.1, SIGKILL);
|
||||
while ($p->isRunning()) {
|
||||
|
||||
while (false === strpos($p->getOutput(), 'received')) {
|
||||
usleep(1000);
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
$start = microtime(true);
|
||||
$p->stop(0.1);
|
||||
|
||||
$this->assertLessThan(4, $duration);
|
||||
$p->wait();
|
||||
|
||||
$this->assertLessThan(15, microtime(true) - $start);
|
||||
}
|
||||
|
||||
public function testAllOutputIsActuallyReadOnTermination()
|
||||
@ -109,12 +118,16 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
|
||||
|
||||
$p->start();
|
||||
// Let's wait enough time for process to finish...
|
||||
// Here we don't call Process::run or Process::wait to avoid any read of pipes
|
||||
usleep(500000);
|
||||
|
||||
if ($p->isRunning()) {
|
||||
$this->markTestSkipped('Process execution did not complete in the required time frame');
|
||||
// Don't call Process::run nor Process::wait to avoid any read of pipes
|
||||
$h = new \ReflectionProperty($p, 'process');
|
||||
$h->setAccessible(true);
|
||||
$h = $h->getValue($p);
|
||||
$s = proc_get_status($h);
|
||||
|
||||
while ($s['running']) {
|
||||
usleep(1000);
|
||||
$s = proc_get_status($h);
|
||||
}
|
||||
|
||||
$o = $p->getOutput();
|
||||
@ -124,18 +137,14 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCallbacksAreExecutedWithStart()
|
||||
{
|
||||
$data = '';
|
||||
|
||||
$process = $this->getProcess('echo foo && '.self::$phpBin.' -r "sleep(1);" && echo foo');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->start(function ($type, $buffer) use (&$data) {
|
||||
$data .= $buffer;
|
||||
});
|
||||
|
||||
while ($process->isRunning()) {
|
||||
usleep(10000);
|
||||
}
|
||||
$process->wait();
|
||||
|
||||
$this->assertEquals(2, preg_match_all('/foo/', $data, $matches));
|
||||
$this->assertSame('foo'.PHP_EOL, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,7 +209,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSetInputWhileRunningThrowsAnException()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(30);"');
|
||||
$process->start();
|
||||
try {
|
||||
$process->setInput('foobar');
|
||||
@ -220,7 +229,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInvalidInput($value)
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->setInput($value);
|
||||
}
|
||||
|
||||
@ -237,7 +246,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testValidInput($expected, $value)
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->setInput($value);
|
||||
$this->assertSame($expected, $process->getInput());
|
||||
}
|
||||
@ -455,7 +464,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTTYCommand()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does have /dev/tty support');
|
||||
$this->markTestSkipped('Windows does not have /dev/tty support');
|
||||
}
|
||||
|
||||
$process = $this->getProcess('echo "foo" >> /dev/null && '.self::$phpBin.' -r "usleep(100000);"');
|
||||
@ -567,12 +576,12 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$process->start();
|
||||
$end = microtime(true);
|
||||
$this->assertLessThan(0.4, $end - $start);
|
||||
$process->wait();
|
||||
$process->stop();
|
||||
}
|
||||
|
||||
public function testUpdateStatus()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertTrue(strlen($process->getOutput()) > 0);
|
||||
}
|
||||
@ -581,7 +590,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(100000);"');
|
||||
$this->assertNull($process->getExitCode());
|
||||
$process->start();
|
||||
$this->assertNull($process->getExitCode());
|
||||
@ -593,7 +602,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(100000);"');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getExitCode());
|
||||
$process->start();
|
||||
@ -606,14 +615,14 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertSame(0, $process->getExitCode());
|
||||
}
|
||||
|
||||
public function testStatus()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(100000);"');
|
||||
$this->assertFalse($process->isRunning());
|
||||
$this->assertFalse($process->isStarted());
|
||||
$this->assertFalse($process->isTerminated());
|
||||
@ -632,7 +641,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testStop()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(31);"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop();
|
||||
@ -643,7 +652,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
@ -652,14 +661,12 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(100000);"');
|
||||
$process->start();
|
||||
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
|
||||
while ($process->isRunning()) {
|
||||
usleep(300000);
|
||||
}
|
||||
$process->wait();
|
||||
|
||||
$this->assertTrue($process->isSuccessful());
|
||||
}
|
||||
@ -668,10 +675,8 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);throw new \Exception(\'BOUM\');"');
|
||||
$process->start();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->wait();
|
||||
$process = $this->getProcess(self::$phpBin.' -r "throw new \Exception(\'BOUM\');"');
|
||||
$process->run();
|
||||
$this->assertFalse($process->isSuccessful());
|
||||
}
|
||||
|
||||
@ -682,19 +687,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithoutTermSignalIsNotSignaled()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertFalse($process->hasBeenSignaled());
|
||||
}
|
||||
@ -706,7 +699,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertEquals(0, $process->getTermSignal());
|
||||
}
|
||||
@ -718,23 +711,10 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(32);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
$this->assertTrue($process->hasBeenSignaled());
|
||||
}
|
||||
|
||||
public function testProcessWithTermSignal()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Windows does not support POSIX signals');
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild();
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
|
||||
$process->start();
|
||||
$process->stop();
|
||||
|
||||
$this->assertEquals(15, $process->getTermSignal()); // SIGTERM
|
||||
}
|
||||
|
||||
@ -749,11 +729,9 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->skipIfNotEnhancedSigchild(false);
|
||||
|
||||
$termSignal = defined('SIGKILL') ? SIGKILL : 9;
|
||||
|
||||
$process = $this->getProcess('exec '.self::$phpBin.' -r "while (true) {}"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(32.1)"');
|
||||
$process->start();
|
||||
posix_kill($process->getPid(), $termSignal);
|
||||
posix_kill($process->getPid(), 9); // SIGKILL
|
||||
|
||||
$process->wait();
|
||||
}
|
||||
@ -778,12 +756,12 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
|
||||
* @expectedExceptionMessage exceeded the timeout of 0.5 seconds.
|
||||
* @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
|
||||
*/
|
||||
public function testRunProcessWithTimeout()
|
||||
{
|
||||
$timeout = 0.5;
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(600000);"');
|
||||
$timeout = 0.1;
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
|
||||
$process->setTimeout($timeout);
|
||||
$start = microtime(true);
|
||||
try {
|
||||
@ -804,25 +782,25 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCheckTimeoutOnNonStartedProcess()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
|
||||
$process->checkTimeout();
|
||||
$process = $this->getProcess('echo foo');
|
||||
$this->assertNull($process->checkTimeout());
|
||||
}
|
||||
|
||||
public function testCheckTimeoutOnTerminatedProcess()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$process->checkTimeout();
|
||||
$this->assertNull($process->checkTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
|
||||
* @expectedExceptionMessage exceeded the timeout of 0.5 seconds.
|
||||
* @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
|
||||
*/
|
||||
public function testCheckTimeoutOnStartedProcess()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
|
||||
$process->setTimeout(0.5);
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(33);"');
|
||||
$process->setTimeout(0.1);
|
||||
|
||||
$process->start();
|
||||
$start = microtime(true);
|
||||
@ -832,30 +810,29 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
$process->checkTimeout();
|
||||
usleep(100000);
|
||||
}
|
||||
$this->fail('A RuntimeException should have been raised');
|
||||
} catch (RuntimeException $e) {
|
||||
$this->fail('A ProcessTimedOutException should have been raised');
|
||||
} catch (ProcessTimedOutException $e) {
|
||||
}
|
||||
$duration = microtime(true) - $start;
|
||||
|
||||
$this->assertLessThan(3, $duration);
|
||||
$this->assertLessThan(15, microtime(true) - $start);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
public function testIdleTimeout()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
|
||||
$process->setTimeout(10);
|
||||
$process->setIdleTimeout(0.5);
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(34);"');
|
||||
$process->setTimeout(60);
|
||||
$process->setIdleTimeout(0.1);
|
||||
|
||||
try {
|
||||
$process->run();
|
||||
|
||||
$this->fail('A timeout exception was expected.');
|
||||
} catch (ProcessTimedOutException $ex) {
|
||||
$this->assertTrue($ex->isIdleTimeout());
|
||||
$this->assertFalse($ex->isGeneralTimeout());
|
||||
$this->assertEquals(0.5, $ex->getExceededTimeout());
|
||||
} catch (ProcessTimedOutException $e) {
|
||||
$this->assertTrue($e->isIdleTimeout());
|
||||
$this->assertFalse($e->isGeneralTimeout());
|
||||
$this->assertEquals(0.1, $e->getExceededTimeout());
|
||||
}
|
||||
}
|
||||
|
||||
@ -864,17 +841,23 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestIncomplete('This test fails with a timeout on Windows, can someone investigate please?');
|
||||
}
|
||||
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }')));
|
||||
$process->setTimeout(2);
|
||||
$process->setIdleTimeout(1);
|
||||
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('while (true) {echo "foo\n"; usleep(10000);}')));
|
||||
$process->setTimeout(1);
|
||||
$process->start();
|
||||
|
||||
while (false === strpos($process->getOutput(), 'foo')) {
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
$process->setIdleTimeout(0.1);
|
||||
|
||||
try {
|
||||
$process->run();
|
||||
$process->wait();
|
||||
$this->fail('A timeout exception was expected.');
|
||||
} catch (ProcessTimedOutException $ex) {
|
||||
$this->assertTrue($ex->isGeneralTimeout(), 'A general timeout is expected.');
|
||||
$this->assertFalse($ex->isIdleTimeout(), 'No idle timeout is expected.');
|
||||
$this->assertEquals(2, $ex->getExceededTimeout());
|
||||
$this->assertEquals(1, $ex->getExceededTimeout());
|
||||
}
|
||||
}
|
||||
|
||||
@ -884,38 +867,39 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testStartAfterATimeout()
|
||||
{
|
||||
$process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 1000; while ($n--) {echo \'\'; usleep(1000); }')));
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(35);"');
|
||||
$process->setTimeout(0.1);
|
||||
|
||||
try {
|
||||
$process->run();
|
||||
$this->fail('A RuntimeException should have been raised.');
|
||||
} catch (RuntimeException $e) {
|
||||
$this->fail('A ProcessTimedOutException should have been raised.');
|
||||
} catch (ProcessTimedOutException $e) {
|
||||
}
|
||||
$this->assertFalse($process->isRunning());
|
||||
$process->start();
|
||||
usleep(1000);
|
||||
$process->stop();
|
||||
$this->assertTrue($process->isRunning());
|
||||
$process->stop(0);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
public function testGetPid()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(36);"');
|
||||
$process->start();
|
||||
$this->assertGreaterThan(0, $process->getPid());
|
||||
$process->wait();
|
||||
$process->stop(0);
|
||||
}
|
||||
|
||||
public function testGetPidIsNullBeforeStart()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
|
||||
$process = $this->getProcess('foo');
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
|
||||
public function testGetPidIsNullAfterRun()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('echo foo');
|
||||
$process->run();
|
||||
$this->assertNull($process->getPid());
|
||||
}
|
||||
@ -925,7 +909,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSignal()
|
||||
{
|
||||
$process = $this->getProcess('exec '.self::$phpBin.' '.__DIR__.'/SignalListener.php');
|
||||
$process = $this->getProcess(self::$phpBin.' '.__DIR__.'/SignalListener.php');
|
||||
$process->start();
|
||||
|
||||
while (false === strpos($process->getOutput(), 'Caught')) {
|
||||
@ -964,7 +948,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSignalProcessNotRunning()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->signal(1); // SIGHUP
|
||||
}
|
||||
|
||||
@ -973,7 +957,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMethodsThatNeedARunningProcess($method)
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -v');
|
||||
$process = $this->getProcess('foo');
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
|
||||
$process->{$method}();
|
||||
}
|
||||
@ -996,7 +980,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMethodsThatNeedATerminatedProcess($method)
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(37);"');
|
||||
$process->start();
|
||||
try {
|
||||
$process->{$method}();
|
||||
@ -1020,36 +1004,38 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideWrongSignal
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongIntSignal()
|
||||
public function testWrongSignal($signal)
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(38);"');
|
||||
$process->start();
|
||||
$process->signal(-4);
|
||||
try {
|
||||
$process->signal($signal);
|
||||
$this->fail('A RuntimeException must have been thrown');
|
||||
} catch (RuntimeException $e) {
|
||||
$process->stop(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
|
||||
*/
|
||||
public function testSignalWithWrongNonIntSignal()
|
||||
throw $e;
|
||||
}
|
||||
|
||||
public function provideWrongSignal()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('POSIX signals do not work on Windows');
|
||||
}
|
||||
|
||||
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
|
||||
$process->start();
|
||||
$process->signal('Céphalopodes');
|
||||
return array(
|
||||
array(-4),
|
||||
array('Céphalopodes'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testDisableOutputDisablesTheOutput()
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess('foo');
|
||||
$this->assertFalse($p->isOutputDisabled());
|
||||
$p->disableOutput();
|
||||
$this->assertTrue($p->isOutputDisabled());
|
||||
@ -1063,7 +1049,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDisableOutputWhileRunningThrowsException()
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess(self::$phpBin.' -r "sleep(39);"');
|
||||
$p->start();
|
||||
$p->disableOutput();
|
||||
}
|
||||
@ -1074,7 +1060,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testEnableOutputWhileRunningThrowsException()
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess(self::$phpBin.' -r "sleep(40);"');
|
||||
$p->disableOutput();
|
||||
$p->start();
|
||||
$p->enableOutput();
|
||||
@ -1082,12 +1068,12 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testEnableOrDisableOutputAfterRunDoesNotThrowException()
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess('echo foo');
|
||||
$p->disableOutput();
|
||||
$p->start();
|
||||
$p->wait();
|
||||
$p->run();
|
||||
$p->enableOutput();
|
||||
$p->disableOutput();
|
||||
$this->assertTrue($p->isOutputDisabled());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1096,7 +1082,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDisableOutputWhileIdleTimeoutIsSet()
|
||||
{
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->setIdleTimeout(1);
|
||||
$process->disableOutput();
|
||||
}
|
||||
@ -1107,16 +1093,16 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSetIdleTimeoutWhileOutputIsDisabled()
|
||||
{
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->disableOutput();
|
||||
$process->setIdleTimeout(1);
|
||||
}
|
||||
|
||||
public function testSetNullIdleTimeoutWhileOutputIsDisabled()
|
||||
{
|
||||
$process = $this->getProcess('sleep 3');
|
||||
$process = $this->getProcess('foo');
|
||||
$process->disableOutput();
|
||||
$process->setIdleTimeout(null);
|
||||
$this->assertSame($process, $process->setIdleTimeout(null));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1124,7 +1110,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testStartWithACallbackAndDisabledOutput($startMethod, $exception, $exceptionMessage)
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess('foo');
|
||||
$p->disableOutput();
|
||||
$this->setExpectedException($exception, $exceptionMessage);
|
||||
if ('mustRun' === $startMethod) {
|
||||
@ -1149,7 +1135,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetOutputWhileDisabled($fetchMethod)
|
||||
{
|
||||
$p = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
|
||||
$p = $this->getProcess(self::$phpBin.' -r "sleep(41);"');
|
||||
$p->disableOutput();
|
||||
$p->start();
|
||||
$p->{$fetchMethod}();
|
||||
@ -1167,7 +1153,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testStopTerminatesProcessCleanly()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo 123; sleep(42);"');
|
||||
$process->run(function () use ($process) {
|
||||
$process->stop();
|
||||
});
|
||||
@ -1176,22 +1162,18 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testKillSignalTerminatesProcessCleanly()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo 123; sleep(43);"');
|
||||
$process->run(function () use ($process) {
|
||||
if ($process->isRunning()) {
|
||||
$process->signal(9); // SIGKILL
|
||||
}
|
||||
});
|
||||
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
|
||||
}
|
||||
|
||||
public function testTermSignalTerminatesProcessCleanly()
|
||||
{
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
|
||||
$process = $this->getProcess(self::$phpBin.' -r "echo 123; sleep(44);"');
|
||||
$process->run(function () use ($process) {
|
||||
if ($process->isRunning()) {
|
||||
$process->signal(15); // SIGTERM
|
||||
}
|
||||
});
|
||||
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
|
||||
}
|
||||
@ -1282,11 +1264,11 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function skipIfNotEnhancedSigchild($expectException = true)
|
||||
{
|
||||
if (self::$notEnhancedSigchild) {
|
||||
if ($expectException) {
|
||||
if (self::$sigchild) {
|
||||
if (!$expectException) {
|
||||
$this->markTestSkipped('PHP is compiled with --enable-sigchild.');
|
||||
} elseif (self::$notEnhancedSigchild) {
|
||||
$this->setExpectedException('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild.');
|
||||
} else {
|
||||
$this->markTestSkipped('PHP is compiled with --enable-sigchild and enhanced mode is disabled.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ class PropertyPathBuilder
|
||||
$this->elements[$offset + $i] = $path->getElement($pathOffset + $i);
|
||||
$this->isIndex[$offset + $i] = $path->isIndex($pathOffset + $i);
|
||||
}
|
||||
ksort($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,6 +252,17 @@ class PropertyPathBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($path, $builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testReplaceWithLongerPathKeepsOrder()
|
||||
{
|
||||
$path = new PropertyPath('new1.new2.new3');
|
||||
$expected = new PropertyPath('new1.new2.new3.old2');
|
||||
|
||||
$builder = new PropertyPathBuilder(new PropertyPath('old1.old2'));
|
||||
$builder->replace(0, 1, $path);
|
||||
|
||||
$this->assertEquals($expected, $builder->getPropertyPath());
|
||||
}
|
||||
|
||||
public function testRemove()
|
||||
{
|
||||
$this->builder->remove(3);
|
||||
|
@ -85,6 +85,10 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDumpWithTooManyRoutes()
|
||||
{
|
||||
if (defined('HHVM_VERSION_ID')) {
|
||||
$this->markTestSkipped('HHVM consumes too much memory on this test.');
|
||||
}
|
||||
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
|
||||
for ($i = 0; $i < 32769; ++$i) {
|
||||
$this->routeCollection->add('route_'.$i, new Route('/route_'.$i));
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Validator;
|
||||
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
/**
|
||||
* Entry point for the Validator component.
|
||||
*
|
||||
|
@ -15,6 +15,7 @@ use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
|
||||
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
/**
|
||||
* A configurable builder for ValidatorInterface objects.
|
||||
|
Reference in New Issue
Block a user