From b9a76bab5c22e035365e6aa4ffbe9b0f0fc9cc36 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 30 Jun 2015 08:51:58 +0200 Subject: [PATCH] Towards 100% HHVM compat --- .../Debug/Tests/ErrorHandlerTest.php | 8 +- .../ProjectWithXsdExtensionInPhar.phar | Bin 1138 -> 1161 bytes .../Tests/Fixtures/includes/createphar.php | 2 +- .../Component/Filesystem/Filesystem.php | 2 +- .../Core/DataTransformer/DateTimeTestCase.php | 2 +- .../Storage/NativeSessionStorageTest.php | 1 - .../Storage/PhpBridgeSessionStorageTest.php | 1 - .../Component/Process/PhpExecutableFinder.php | 2 +- .../Process/Tests/AbstractProcessTest.php | 75 ++++++++++-------- .../Process/Tests/ExecutableFinderTest.php | 4 +- .../Process/Tests/PhpExecutableFinderTest.php | 6 +- .../Process/Tests/SimpleProcessTest.php | 6 +- .../Dumper/PhpGeneratorDumperTest.php | 2 +- .../Stopwatch/Tests/StopwatchEventTest.php | 4 +- .../Component/Yaml/Tests/InlineTest.php | 20 +++-- 15 files changed, 75 insertions(+), 60 deletions(-) diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 942240bafe..115f599f56 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -39,6 +39,10 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase public function testCompileTimeError() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('HHVM behaves differently in this test case.'); + } + // the ContextErrorException must not be loaded to test the workaround // for https://bugs.php.net/bug.php?id=65322. if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { @@ -62,10 +66,10 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase $that->assertEquals(2, $exception->getLine()); if (PHP_VERSION_ID < 70000) { $that->assertEquals(E_STRICT, $exception->getSeverity()); - $that->assertStringStartsWith('Runtime Notice: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage()); + $that->assertStringStartsWith('Runtime Notice: Declaration', $exception->getMessage()); } else { $that->assertEquals(E_WARNING, $exception->getSeverity()); - $that->assertStringStartsWith('Warning: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage()); + $that->assertStringStartsWith('Warning: Declaration', $exception->getMessage()); } $that->assertArrayHasKey('bar', $exception->getContext()); }; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtensionInPhar.phar b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectWithXsdExtensionInPhar.phar index 402e17b2f2146572088215a07892fcb219fc3b43..040e136a342520de248a1e0ae9006bd67a732b1b 100644 GIT binary patch delta 278 zcmeyw(a9-lV_%R_pb(IeSY&0Dn^*v1XedqAXO!j8D*&>UG_5DHUKGe-WME(jnG_15 zk4c4JocK&hZVglnL>Coxe%l7(0|D4XuE`pVwoF{rlg}_pOm1WpXX8=;g6hc&7?s$; z%vvs>lrl{CJEJR-u*BpzCU%%qE|WThSvz?SlO`kAY%28gHXtQJi9xoS$2elUfl{S&(YS1raJv&PdHow5$JLbLH|aUly(8 Wzw#Q7^*XZE5_*_`PIq_mbpimEXis7Q delta 284 zcmeC={KUa(V_%R_FwyFwKpi6k!~eu=Ul9FO;rsf@(u_(9JD`FfI91i-p@ zxp*f>GupE7a#izA&SjFAyophqgO^JI2!I0T8I`yooLZ1Vkh}mBH$q;K$rV*z9w9f0 zNgc|m<(<5rNs}35!b>K1M&8K=%!WWRk=YYSu3}aJ%baJ{0MkF1<$addFromString('schema/project-1.0.xsd', << EOT ); -$phar->setStub(''); +$phar->setStub(''); diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 1e332effcd..eea41dad66 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -229,7 +229,7 @@ class Filesystem $this->chgrp(new \FilesystemIterator($file), $group, true); } if (is_link($file) && function_exists('lchgrp')) { - if (true !== @lchgrp($file, $group)) { + if (true !== @lchgrp($file, $group) || (defined('HHVM_VERSION') && !posix_getgrnam($group))) { throw new IOException(sprintf('Failed to chgrp file %s', $file)); } } else { diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php index f7722c496e..200cbc3282 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php @@ -15,6 +15,6 @@ abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase { public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual) { - self::assertEquals($expected->format('c'), $actual->format('c')); + self::assertEquals($expected->format('U'), $actual->format('U')); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index e2146d8434..851e6752b0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -216,7 +216,6 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase { $storage = $this->getStorage(); - $this->assertFalse(isset($_SESSION)); $this->assertFalse($storage->getSaveHandler()->isActive()); $this->assertFalse($storage->isStarted()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index 0acc4458cc..07d560f711 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -91,7 +91,6 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase $storage = $this->getStorage(); - $this->assertFalse(isset($_SESSION)); $this->assertFalse($storage->getSaveHandler()->isActive()); $this->assertFalse($storage->isStarted()); diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index 91d6d78a67..a86096f0e7 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -37,7 +37,7 @@ class PhpExecutableFinder { // HHVM support if (defined('HHVM_VERSION')) { - return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : ''); + return (false !== (getenv('PHP_BINARY')) ?: PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : ''); } // PHP_BINARY return the current sapi executable diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 3638e47ac4..b232451b7f 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Process\Tests; use Symfony\Component\Process\Exception\LogicException; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; use Symfony\Component\Process\Exception\RuntimeException; use Symfony\Component\Process\ProcessPipes; @@ -21,10 +22,18 @@ use Symfony\Component\Process\ProcessPipes; */ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { + protected static $phpBin; + + public static function setUpBeforeClass() + { + $phpBin = new PhpExecutableFinder(); + self::$phpBin = $phpBin->find(); + } + public function testThatProcessDoesNotThrowWarningDuringRun() { @trigger_error('Test Error', E_USER_NOTICE); - $process = $this->getProcess("php -r 'sleep(3)'"); + $process = $this->getProcess(self::$phpBin." -r 'sleep(3)'"); $process->run(); $actualError = error_get_last(); $this->assertEquals('Test Error', $actualError['message']); @@ -158,7 +167,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testSetStdinWhileRunningThrowsAnException() { - $process = $this->getProcess('php -r "usleep(500000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"'); $process->start(); try { $process->setStdin('foobar'); @@ -177,7 +186,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase */ public function testInvalidStdin($value) { - $process = $this->getProcess('php -v'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->setStdin($value); } @@ -195,7 +204,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase */ public function testValidStdin($expected, $value) { - $process = $this->getProcess('php -v'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->setStdin($value); $this->assertSame($expected, $process->getStdin()); } @@ -452,7 +461,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testStartIsNonBlocking() { - $process = $this->getProcess('php -r "usleep(500000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"'); $start = microtime(true); $process->start(); $end = microtime(true); @@ -462,14 +471,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testUpdateStatus() { - $process = $this->getProcess('php -h'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertTrue(strlen($process->getOutput()) > 0); } public function testGetExitCodeIsNullOnStart() { - $process = $this->getProcess('php -r "usleep(200000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"'); $this->assertNull($process->getExitCode()); $process->start(); $this->assertNull($process->getExitCode()); @@ -479,7 +488,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testGetExitCodeIsNullOnWhenStartingAgain() { - $process = $this->getProcess('php -r "usleep(200000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"'); $process->run(); $this->assertEquals(0, $process->getExitCode()); $process->start(); @@ -490,14 +499,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testGetExitCode() { - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertSame(0, $process->getExitCode()); } public function testStatus() { - $process = $this->getProcess('php -r "usleep(500000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"'); $this->assertFalse($process->isRunning()); $this->assertFalse($process->isStarted()); $this->assertFalse($process->isTerminated()); @@ -516,7 +525,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testStop() { - $process = $this->getProcess('php -r "sleep(4);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(4);"'); $process->start(); $this->assertTrue($process->isRunning()); $process->stop(); @@ -525,14 +534,14 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testIsSuccessful() { - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertTrue($process->isSuccessful()); } public function testIsSuccessfulOnlyAfterTerminated() { - $process = $this->getProcess('php -r "sleep(1);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(1);"'); $process->start(); while ($process->isRunning()) { $this->assertFalse($process->isSuccessful()); @@ -544,7 +553,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testIsNotSuccessful() { - $process = $this->getProcess('php -r "usleep(500000);throw new \Exception(\'BOUM\');"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(500000);throw new \Exception(\'BOUM\');"'); $process->start(); $this->assertTrue($process->isRunning()); $process->wait(); @@ -557,7 +566,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Windows does not support POSIX signals'); } - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertFalse($process->hasBeenSignaled()); } @@ -568,7 +577,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Windows does not support POSIX signals'); } - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertFalse($process->hasBeenSignaled()); } @@ -579,7 +588,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Windows does not support POSIX signals'); } - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertEquals(0, $process->getTermSignal()); } @@ -590,7 +599,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Windows does not support POSIX signals'); } - $process = $this->getProcess('php -r "sleep(4);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(4);"'); $process->start(); $process->stop(); $this->assertTrue($process->hasBeenSignaled()); @@ -605,7 +614,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase // SIGTERM is only defined if pcntl extension is present $termSignal = defined('SIGTERM') ? SIGTERM : 15; - $process = $this->getProcess('php -r "sleep(4);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(4);"'); $process->start(); $process->stop(); @@ -634,7 +643,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testRestart() { - $process1 = $this->getProcess('php -r "echo getmypid();"'); + $process1 = $this->getProcess(self::$phpBin.' -r "echo getmypid();"'); $process1->run(); $process2 = $process1->restart(); @@ -656,7 +665,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase // Sleep doesn't work as it will allow the process to handle signals and close // file handles from the other end. - $process = $this->getProcess('php -r "while (true) {}"'); + $process = $this->getProcess(self::$phpBin.' -r "while (true) {}"'); $process->start(); // PHP will deadlock when it tries to cleanup $process @@ -665,7 +674,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testRunProcessWithTimeout() { $timeout = 0.5; - $process = $this->getProcess('php -r "usleep(600000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(600000);"'); $process->setTimeout($timeout); $start = microtime(true); try { @@ -687,13 +696,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testCheckTimeoutOnNonStartedProcess() { - $process = $this->getProcess('php -r "sleep(3);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(3);"'); $process->checkTimeout(); } public function testCheckTimeoutOnTerminatedProcess() { - $process = $this->getProcess('php -v'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $process->checkTimeout(); } @@ -702,7 +711,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { $timeout = 0.5; $precision = 100000; - $process = $this->getProcess('php -r "sleep(3);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(3);"'); $process->setTimeout($timeout); $start = microtime(true); @@ -738,7 +747,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testGetPid() { - $process = $this->getProcess('php -r "usleep(500000);"'); + $process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"'); $process->start(); $this->assertGreaterThan(0, $process->getPid()); $process->wait(); @@ -746,13 +755,13 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testGetPidIsNullBeforeStart() { - $process = $this->getProcess('php -r "sleep(1);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(1);"'); $this->assertNull($process->getPid()); } public function testGetPidIsNullAfterRun() { - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->run(); $this->assertNull($process->getPid()); } @@ -797,7 +806,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testSignalProcessNotRunning() { $this->verifyPosixIsEnabled(); - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $process->signal(SIGHUP); } @@ -806,7 +815,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase */ public function testMethodsThatNeedARunningProcess($method) { - $process = $this->getProcess('php -m'); + $process = $this->getProcess(self::$phpBin.' -v'); $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method)); $process->{$method}(); } @@ -827,7 +836,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase */ public function testMethodsThatNeedATerminatedProcess($method) { - $process = $this->getProcess('php -r "sleep(1);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(1);"'); $process->start(); try { $process->{$method}(); @@ -869,7 +878,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('POSIX signals do not work on Windows'); } - $process = $this->getProcess('php -r "sleep(3);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(3);"'); $process->start(); $process->signal(-4); } @@ -883,7 +892,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('POSIX signals do not work on Windows'); } - $process = $this->getProcess('php -r "sleep(3);"'); + $process = $this->getProcess(self::$phpBin.' -r "sleep(3);"'); $process->start(); $process->signal('Céphalopodes'); } diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 20b12b1c3c..61a471b4f6 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -102,7 +102,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Cannot test when open_basedir is set'); } - $this->iniSet('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/'); + $this->iniSet('open_basedir', dirname(PHP_BINARY).(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : '')); $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName()); @@ -125,7 +125,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase } $this->setPath(''); - $this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); + $this->iniSet('open_basedir', PHP_BINARY.(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : '')); $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName(), false); diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index 8f8623930f..cd4abedc9d 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -53,10 +53,10 @@ class PhpExecutableFinderTest extends \PHPUnit_Framework_TestCase $f = new PhpExecutableFinder(); - $current = $f->find(); + $current = getenv('PHP_BINARY') ?: PHP_BINARY; - $this->assertEquals($f->find(), $current.' --php', '::find() returns the executable PHP'); - $this->assertEquals($f->find(false), $current, '::find() returns the executable PHP'); + $this->assertEquals($current.' --php', $f->find(), '::find() returns the executable PHP'); + $this->assertEquals($current, $f->find(false), '::find() returns the executable PHP'); } /** diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index 28296677f4..8203d8da3e 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -150,7 +150,7 @@ class SimpleProcessTest extends AbstractProcessTest public function testStopTerminatesProcessCleanly() { try { - $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"'); $process->run(function () use ($process) { $process->stop(); }); @@ -164,7 +164,7 @@ class SimpleProcessTest extends AbstractProcessTest $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); try { - $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"'); $process->run(function () use ($process) { if ($process->isRunning()) { $process->signal(defined('SIGKILL') ? SIGKILL : 9); @@ -180,7 +180,7 @@ class SimpleProcessTest extends AbstractProcessTest $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); try { - $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"'); $process->run(function () use ($process) { if ($process->isRunning()) { $process->signal(defined('SIGTERM') ? SIGTERM : 15); diff --git a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php index 65c54f596f..c8c5a4c3e9 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php @@ -39,7 +39,7 @@ class PhpGeneratorDumperTest extends \PHPUnit_Framework_TestCase $this->routeCollection = new RouteCollection(); $this->generatorDumper = new PhpGeneratorDumper($this->routeCollection); - $this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.php'; + $this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php'; @unlink($this->testTmpFilepath); } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index ccc4031967..18c3f87533 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -119,12 +119,12 @@ class StopwatchEventTest extends \PHPUnit_Framework_TestCase public function testStartTime() { $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertTrue($event->getStartTime() < 0.5); + $this->assertLessThan(0.5, $event->getStartTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); $event->stop(); - $this->assertTrue($event->getStartTime() < 1); + $this->assertLessThan(1, $event->getStartTime()); $event = new StopwatchEvent(microtime(true) * 1000); $event->start(); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index bd8147b3c9..dbb12f2834 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -46,15 +46,19 @@ class InlineTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('Your platform does not support locales.'); } - $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); - if (false === setlocale(LC_ALL, $required_locales)) { - $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales)); + try { + $requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); + if (false === setlocale(LC_NUMERIC, $requiredLocales)) { + $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales)); + } + + $this->assertEquals('1.2', Inline::dump(1.2)); + $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); + setlocale(LC_NUMERIC, $locale); + } catch (\Exception $e) { + setlocale(LC_NUMERIC, $locale); + throw $e; } - - $this->assertEquals('1.2', Inline::dump(1.2)); - $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0))); - - setlocale(LC_ALL, $locale); } public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()