8000 Towards 100% HHVM compat · symfony/symfony@b9a76ba · GitHub
[go: up one dir, main page]

Skip to content

Commit b9a76ba

Browse files
Towards 100% HHVM compat
1 parent 7e418fd commit b9a76ba

File tree

15 files changed

+75
-60
lines changed

15 files changed

+75
-60
lines changed

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ protected function tearDown()
3939

4040
public function testCompileTimeError()
4141
{
42+
if (defined('HHVM_VERSION')) {
43+
$this->markTestSkipped('HHVM behaves differently in this test case.');
44+
}
45+
4246
// the ContextErrorException must not be loaded to test the workaround
4347
// for https://bugs.php.net/bug.php?id=65322.
4448
if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) {
@@ -62,10 +66,10 @@ class_exists('PHPUnit_Framework_MockObject_Invocation_Object');
6266
$that->assertEquals(2, $exception->getLine());
6367
if (PHP_VERSION_ID < 70000) {
6468
$that->assertEquals(E_STRICT, $exception->getSeverity());
65-
$that->assertStringStartsWith('Runtime Notice: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage());
69+
$that->assertStringStartsWith('Runtime Notice: Declaration', $exception->getMessage());
6670
} else {
6771
$that->assertEquals(E_WARNING, $exception->getSeverity());
68-
$that->assertStringStartsWith('Warning: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage());
72+
$that->assertStringStartsWith('Warning: Declaration', $exception->getMessage());
6973
}
7074
$that->assertArrayHasKey('bar', $exception->getContext());
7175
};

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/createphar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public function getAlias()
4444
</xsd:schema>
4545
EOT
4646
);
47-
$phar->setStub('<?php require_once "phar://ProjectWithXsdExtensionInPhar.phar/ProjectWithXsdExtensionInPhar.php"; __HALT_COMPILER(); ?>');
47+
$phar->setStub('<?php Phar::mapPhar("ProjectWithXsdExtensionInPhar.phar"); require_once "phar://ProjectWithXsdExtensionInPhar.phar/ProjectWithXsdExtensionInPhar.php"; __HALT_COMPILER(); ?>');

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function chgrp($files, $group, $recursive = false)
229229
$this->chgrp(new \FilesystemIterator($file), $group, true);
230230
}
231231
if (is_link($file) && function_exists('lchgrp')) {
232-
if (true !== @lchgrp($file, $group)) {
232+
if (true !== @lchgrp($file, $group) || (defined('HHVM_VERSION') && !posix_getgrnam($group))) {
233233
throw new IOException(sprintf('Failed to chgrp file %s', $file));
234234
}
235235
} else {

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase
1515
{
1616
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
1717
{
18-
self::assertEquals($expected->format('c'), $actual->format('c'));
18+
self::assertEquals($expected->format('U'), $actual->format('U'));
1919
}
2020
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ public function testStartedOutside()
216216
{
217217
$storage = $this->getStorage();
218218

219-
$this->assertFalse(isset($_SESSION));
220219
$this->assertFalse($storage->getSaveHandler()->isActive());
221220
$this->assertFalse($storage->isStarted());
222221

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function testPhpSession54()
9191

9292
$storage = $this->getStorage();
9393

94-
$this->assertFalse(isset($_SESSION));
9594
$this->assertFalse($storage->getSaveHandler()->isActive());
9695
$this->assertFalse($storage->isStarted());
9796

src/Symfony/Component/Process/PhpExecutableFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function find($includeArgs = true)
3737
{
3838
// HHVM support
3939
if (defined('HHVM_VERSION')) {
40-
return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
40+
return (false !== (getenv('PHP_BINARY')) ?: PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : '');
4141
}
4242

4343
// PHP_BINARY return the current sapi executable

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 42 additions & 33 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Process\Tests;
1313

1414
use Symfony\Component\Process\Exception\LogicException;
15+
use Symfony\Component\Process\PhpExecutableFinder;
1516
use Symfony\Component\Process\Process;
1617
use Symfony\Component\Process\Exception\RuntimeException;
1718
use Symfony\Component\Process\ProcessPipes;
@@ -21,10 +22,18 @@
2122
*/
2223
abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
2324
{
25+
protected static $phpBin;
26+
27+
public static function setUpBeforeClass()
28+
{
29+
$phpBin = new PhpExecutableFinder();
30+
self::$phpBin = $phpBin->find();
31+
}
32+
2433
public function testThatProcessDoesNotThrowWarningDuringRun()
2534
{
2635
@trigger_error('Test Error', E_USER_NOTICE);
27-
$process = $this->getProcess("php -r 'sleep(3)'");
36+
$process = $this->getProcess(self::$phpBin." -r 'sleep(3)'");
2837
$process->run();
2938
$actualError = error_get_last();
3039
$this->assertEquals('Test Error', $actualError['message']);
@@ -158,7 +167,7 @@ public function testProcessPipes($code, $size)
158167

159168
public function testSetStdinWhileRunningThrowsAnException()
160169
{
161-
$process = $this->getProcess('php -r "usleep(500000);"');
170+
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
162171
$process->start();
163172
try {
164173
$process->setStdin('foobar');
@@ -177,7 +186,7 @@ public function testSetStdinWhileRunningThrowsAnException()
177186
*/
178187
public function testInvalidStdin($value)
179188
{
180-
$process = $this->getProcess('php -v');
189+
$process = $this->getProcess(self::$phpBin.' -v');
181190
$process->setStdin($value);
182191
}
183192

@@ -195,7 +204,7 @@ public function provideInvalidStdinValues()
195204
*/
196205
public function testValidStdin($expected, $value)
197206
{
198-
$process = $this->getProcess('php -v');
207+
$process = $this->getProcess(self::$phpBin.' -v');
199208
$process->setStdin($value);
200209
$this->assertSame($expected, $process->getStdin());
201210
}
@@ -452,7 +461,7 @@ public function testExitCodeText()
452461

453462
public function testStartIsNonBlocking()
454463
{
455-
$process = $this->getProcess('php -r "usleep(500000);"');
464+
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
456465
$start = microtime(true);
457466
$process->start();
458467
$end = microtime(true);
@@ -462,14 +471,14 @@ public function testStartIsNonBlocking()
462471

463472
public function testUpdateStatus()
464473
{
465-
$process = $this->getProcess('php -h');
474+
$process = $this->getProcess(self::$phpBin.' -v');
466475
$process->run();
467476
$this->assertTrue(strlen($process->getOutput()) > 0);
468477
}
469478

470479
public function testGetExitCodeIsNullOnStart()
471480
{
472-
$process = $this->getProcess('php -r "usleep(200000);"');
481+
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
473482
$this->assertNull($process->getExitCode());
474483
$process->start();
475484
$this->assertNull($process->getExitCode());
@@ -479,7 +488,7 @@ public function testGetExitCodeIsNullOnStart()
479488

480489
public function testGetExitCodeIsNullOnWhenStartingAgain()
481490
{
482-
$process = $this->getProcess('php -r "usleep(200000);"');
491+
$process = $this->getProcess(self::$phpBin.' -r "usleep(200000);"');
483492
$process->run();
484493
$this->assertEquals(0, $process->getExitCode());
485494
$process->start();
@@ -490,14 +499,14 @@ public function testGetExitCodeIsNullOnWhenStartingAgain()
490499

491500
public function testGetExitCode()
492501
{
493-
$process = $this->getProcess('php -m');
502+
$process = $this->getProcess(self::$phpBin.' -v');
494503
$process->run();
495504
$this->assertSame(0, $process->getExitCode());
496505
}
497506

498507
public function testStatus()
499508
{
500-
$process = $this->getProcess('php -r "usleep(500000);"');
509+
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
501510
$this->assertFalse($process->isRunning());
502511
$this->assertFalse($process->isStarted());
503512
$this->assertFalse($process->isTerminated());
@@ -516,7 +525,7 @@ public function testStatus()
516525

517526
public function testStop()
518527
{
519-
$process = $this->getProcess('php -r "sleep(4);"');
528+
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
520529
$process->start();
521530
$this->assertTrue($process->isRunning());
522531
$process->stop();
@@ -525,14 +534,14 @@ public function testStop()
525534

526535
public function testIsSuccessful()
527536
{
528-
$process = $this->getProcess('php -m');
537+
$process = $this->getProcess(self::$phpBin.' -v');
529538
$process->run();
530539
$this->assertTrue($process->isSuccessful());
531540
}
532541

533542
public function testIsSuccessfulOnlyAfterTerminated()
534543
{
535-
$process = $this->getProcess('php -r "sleep(1);"');
544+
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
536545
$process->start();
537546
while ($process->isRunning()) {
538547
$this->assertFalse($process->isSuccessful());
@@ -544,7 +553,7 @@ public function testIsSuccessfulOnlyAfterTerminated()
544553

545554
public function testIsNotSuccessful()
546555
{
547-
$process = $this->getProcess('php -r "usleep(500000);throw new \Exception(\'BOUM\');"');
556+
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);throw new \Exception(\'BOUM\');"');
548557
$process->start();
549558
$this->assertTrue($process->isRunning());
550559
$process->wait();
@@ -557,7 +566,7 @@ public function testProcessIsNotSignaled()
557566
$this->markTestSkipped('Windows does not support POSIX signals');
558567
}
559568

560-
$process = $this->getProcess('php -m');
569+
$process = $this->getProcess(self::$phpBin.' -v');
561570
$process->run();
562571
$this->assertFalse($process->hasBeenSignaled());
563572
}
@@ -568,7 +577,7 @@ public function testProcessWithoutTermSignalIsNotSignaled()
568577
$this->markTestSkipped('Windows does not support POSIX signals');
569578
}
570579

571-
$process = $this->getProcess('php -m');
580+
$process = $this->getProcess(self::$phpBin.' -v');
572581
$process->run();
573582
$this->assertFalse($process->hasBeenSignaled());
574583
}
@@ -579,7 +588,7 @@ public function testProcessWithoutTermSignal()
579588
$this->markTestSkipped('Windows does not support POSIX signals');
580589
}
581590

582-
$process = $this->getProcess('php -m');
591+
$process = $this->getProcess(self::$phpBin.' -v');
583592
$process->run();
584593
$this->assertEquals(0, $process->getTermSignal());
585594
}
@@ -590,7 +599,7 @@ public function testProcessIsSignaledIfStopped()
590599
$this->markTestSkipped('Windows does not support POSIX signals');
591600
}
592601

593-
$process = $this->getProcess('php -r "sleep(4);"');
602+
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
594603
$process->start();
595604
$process->stop();
596605
$this->assertTrue($process->hasBeenSignaled());
@@ -605,7 +614,7 @@ public function testProcessWithTermSignal()
605614
// SIGTERM is only defined if pcntl extension is present
606615
$termSignal = defined('SIGTERM') ? SIGTERM : 15;
607616

608-
$process = $this->getProcess('php -r "sleep(4);"');
617+
$process = $this->getProcess(self::$phpBin.' -r "sleep(4);"');
609618
$process->start();
610619
$process->stop();
611620

@@ -634,7 +643,7 @@ public function testProcessThrowsExceptionWhenExternallySignaled()
634643

635644
public function testRestart()
636645
{
637-
$process1 = $this->getProcess('php -r "echo getmypid();"');
646+
$process1 = $this->getProcess(self::$phpBin.' -r "echo getmypid();"');
638647
$process1->run();
639648
$process2 = $process1->restart();
640649

@@ -656,7 +665,7 @@ public function testPhpDeadlock()
656665

657666
// Sleep doesn't work as it will allow the process to handle signals and close
658667
// file handles from the other end.
659-
$process = $this->getProcess('php -r "while (true) {}"');
668+
$process = $this->getProcess(self::$phpBin.' -r "while (true) {}"');
660669
$process->start();
661670

662671
// PHP will deadlock when it tries to cleanup $process
@@ -665,7 +674,7 @@ public function testPhpDeadlock()
665674
public function testRunProcessWithTimeout()
666675
{
667676
$timeout = 0.5;
668-
$process = $this->getProcess('php -r "usleep(600000);"');
677+
$process = $this->getProcess(self::$phpBin.' -r "usleep(600000);"');
669678
$process->setTimeout($timeout);
670679
$start = microtime(true);
671680
try {
@@ -687,13 +696,13 @@ public function testRunProcessWithTimeout()
687696

688697
public function testCheckTimeoutOnNonStartedProcess()
689698
{
690-
$process = $this->getProcess('php -r "sleep(3);"');
699+
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
691700
$process->checkTimeout();
692701
}
693702

694703
public function testCheckTimeoutOnTerminatedProcess()
695704
{
696-
$process = $this->getProcess('php -v');
705+
$process = $this->getProcess(self::$phpBin.' -v');
697706
$process->run();
698707
$process->checkTimeout();
699708
}
@@ -702,7 +711,7 @@ public function testCheckTimeoutOnStartedProcess()
702711
{
703712
$timeout = 0.5;
704713
$precision = 100000;
705-
$process = $this->getProcess('php -r "sleep(3);"');
714+
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
706715
$process->setTimeout($timeout);
707716
$start = microtime(true);
708717

@@ -738,21 +747,21 @@ public function testStartAfterATimeout()
738747

739748
public function testGetPid()
740749
{
741-
$process = $this->getProcess('php -r "usleep(500000);"');
750+
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
742751
$process->start();
743752
$this->assertGreaterThan(0, $process->getPid());
744753
$process->wait();
745754
}
746755

747756
public function testGetPidIsNullBeforeStart()
748757
{
749-
$process = $this->getProcess('php -r "sleep(1);"');
758+
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
750759
$this->assertNull($process->getPid());
751760
}
752761

753762
public function testGetPidIsNullAfterRun()
754763
{
755-
$process = $this->getProcess('php -m');
764+
$process = $this->getProcess(self::$phpBin.' -v');
756765
$process->run();
757766
$this->assertNull($process->getPid());
758767
}
@@ -797,7 +806,7 @@ public function testExitCodeIsAvailableAfterSignal()
797806
public function testSignalProcessNotRunning()
798807
{
799808
$this->verifyPosixIsEnabled();
800-
$process = $this->getProcess('php -m');
809+
$process = $this->getProcess(self::$phpBin.' -v');
801810
$process->signal(SIGHUP);
802811
}
803812

@@ -806,7 +815,7 @@ public function testSignalProcessNotRunning()
806815
*/
807816
public function testMethodsThatNeedARunningProcess($method)
808817
{
809-
$process = $this->getProcess('php -m');
818+
$process = $this->getProcess(self::$phpBin.' -v');
810819
$this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method));
811820
$process->{$method}();
812821
}
@@ -827,7 +836,7 @@ public function provideMethodsThatNeedARunningProcess()
827836
*/
828837
public function testMethodsThatNeedATerminatedProcess($method)
829838
{
830-
$process = $this->getProcess('php -r "sleep(1);"');
839+
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
831840
$process->start();
832841
try {
833842
$process->{$method}();
@@ -869,7 +878,7 @@ public function testSignalWithWrongIntSignal()
869878
$this->markTestSkipped('POSIX signals do not work on Windows');
870879
}
871880

872-
$process = $this->getProcess('php -r "sleep(3);"');
881+
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
873882
$process->start();
874883
$process->signal(-4);
875884
}
@@ -883,7 +892,7 @@ public function testSignalWithWrongNonIntSignal()
883892
$this->markTestSkipped('POSIX signals do not work on Windows');
884893
}
885894

886-
$process = $this->getProcess('php -r "sleep(3);"');
895+
$process = $this->getProcess(self::$phpBin.' -r "sleep(3);"');
887896
$process->start();
888897
$process->signal('Céphalopodes');
889898
}

src/Symfony/Component/Process/Tests/ExecutableFinderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testFindWithOpenBaseDir()
102102
$this->markTestSkipped('Cannot test when open_basedir is set');
103103
}
104104

105-
$this->iniSet('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
105+
$this->iniSet('open_basedir', dirname(PHP_BINARY).(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
106106

107107
$finder = new ExecutableFinder();
108108
$result = $finder->find($this->getPhpBinaryName());
@@ -125,7 +125,7 @@ public function testFindProcessInOpenBasedir()
125125
}
126126

127127
$this->setPath('');
128-
$this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
128+
$this->iniSet('open_basedir', PHP_BINARY.(!defined('HHVM_VERSION') ? PATH_SEPARATOR.'/' : ''));
129129

130130
$finder = new ExecutableFinder();
131131
$result = $finder->find($this->getPhpBinaryName(), false);

0 commit comments

Comments
 (0)
0