Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ protected function tearDown()

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)) {
Expand All @@ -62,10 +66,10 @@ class_exists('PHPUnit_Framework_MockObject_Invocation_Object');
$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());
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ public function getAlias()
</xsd:schema>
EOT
);
$phar->setStub('<?php require_once "phar://ProjectWithXsdExtensionInPhar.phar/ProjectWithXsdExtensionInPhar.php"; __HALT_COMPILER(); ?>');
$phar->setStub('<?php Phar::mapPhar("ProjectWithXsdExtensionInPhar.phar"); require_once "phar://ProjectWithXsdExtensionInPhar.phar/ProjectWithXsdExtensionInPhar.php"; __HALT_COMPILER(); ?>');
2 changes: 1 addition & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function chgrp($files, $group, $recursive = false)
$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))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are posix functions always available on HHVM ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

throw new IOException(sprintf('Failed to chgrp file %s', $file));
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public function testStartedOutside()
{
$storage = $this->getStorage();

$this->assertFalse(isset($_SESSION));
$this->assertFalse($storage->getSaveHandler()->isActive());
$this->assertFalse($storage->isStarted());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public function testPhpSession54()

$storage = $this->getStorage();

$this->assertFalse(isset($_SESSION));
$this->assertFalse($storage->getSaveHandler()->isActive());
$this->assertFalse($storage->isStarted());

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/PhpExecutableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function find($includeArgs = true)
{
// 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()) : '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this return true here rather than the PHP_BINARY variable ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6e1ae53

}

// PHP_BINARY return the current sapi executable
Expand Down
75 changes: 42 additions & 33 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,10 +22,18 @@
*/
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']);
Expand Down Expand Up @@ -158,7 +167,7 @@ public function testProcessPipes($code, $size)

public function testSetStdinWhileRunningThrowsAnException()
{
$process = $this->getProcess('php -r "usleep(500000);"');
$process = $this->getProcess(self::$phpBin.' -r "usleep(500000);"');
$process->start();
try {
$process->setStdin('foobar');
Expand All @@ -177,7 +186,7 @@ public function testSetStdinWhileRunningThrowsAnException()
*/
public function testInvalidStdin($value)
{
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->setStdin($value);
}

Expand All @@ -195,7 +204,7 @@ public function provideInvalidStdinValues()
*/
public function testValidStdin($expected, $value)
{
$process = $this->getProcess('php -v');
$process = $this->getProcess(self::$phpBin.' -v');
$process->setStdin($value);
$this->assertSame($expected, $process->getStdin());
}
Expand Down Expand Up @@ -452,7 +461,7 @@ public function testExitCodeText()

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);
Expand All @@ -462,14 +471,14 @@ public function testStartIsNonBlocking()

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());
Expand All @@ -479,7 +488,7 @@ public function testGetExitCodeIsNullOnStart()

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();
Expand All @@ -490,14 +499,14 @@ public function testGetExitCodeIsNullOnWhenStartingAgain()

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());
Expand All @@ -516,7 +525,7 @@ public function testStatus()

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();
Expand All @@ -525,14 +534,14 @@ public function testStop()

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());
Expand All @@ -544,7 +553,7 @@ public function testIsSuccessfulOnlyAfterTerminated()

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();
Expand All @@ -557,7 +566,7 @@ public function testProcessIsNotSignaled()
$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());
}
Expand All @@ -568,7 +577,7 @@ public function testProcessWithoutTermSignalIsNotSignaled()
$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());
}
Expand All @@ -579,7 +588,7 @@ public function testProcessWithoutTermSignal()
$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());
}
Expand All @@ -590,7 +599,7 @@ public function testProcessIsSignaledIfStopped()
$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());
Expand All @@ -605,7 +614,7 @@ public function testProcessWithTermSignal()
// 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();

Expand Down Expand Up @@ -634,7 +643,7 @@ public function testProcessThrowsExceptionWhenExternallySignaled()

public function testRestart()
{
$process1 = $this->getProcess('php -r "echo getmypid();"');
$process1 = $this->getProcess(self::$phpBin.' -r "echo getmypid();"');
$process1->run();
$process2 = $process1->restart();

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

// 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
Expand All @@ -665,7 +674,7 @@ public function testPhpDeadlock()
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 {
Expand All @@ -687,13 +696,13 @@ public function testRunProcessWithTimeout()

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();
}
Expand All @@ -702,7 +711,7 @@ public function testCheckTimeoutOnStartedProcess()
{
$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);

Expand Down Expand Up @@ -738,21 +747,21 @@ public function testStartAfterATimeout()

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();
}

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());
}
Expand Down Expand Up @@ -797,7 +806,7 @@ public function testExitCodeIsAvailableAfterSignal()
public function testSignalProcessNotRunning()
{
$this->verifyPosixIsEnabled();
$process = $this->getProcess('php -m');
$process = $this->getProcess(self::$phpBin.' -v');
$process->signal(SIGHUP);
}

Expand All @@ -806,7 +815,7 @@ public function testSignalProcessNotRunning()
*/
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}();
}
Expand All @@ -827,7 +836,7 @@ public function provideMethodsThatNeedARunningProcess()
*/
public function testMethodsThatNeedATerminatedProcess($method)
{
$process = $this->getProcess('php -r "sleep(1);"');
$process = $this->getProcess(self::$phpBin.' -r "sleep(1);"');
$process->start();
try {
$process->{$method}();
Expand Down Expand Up @@ -869,7 +878,7 @@ public function testSignalWithWrongIntSignal()
$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);
}
Expand All @@ -883,7 +892,7 @@ public function testSignalWithWrongNonIntSignal()
$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');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Process/Tests/ExecutableFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testFindWithOpenBaseDir()
$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());
Expand All @@ -125,7 +125,7 @@ public function testFindProcessInOpenBasedir()
}

$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);
Expand Down
Loading