minor #13195 [Process] Fixes to executable finder tests (mpajunen)

This PR was merged into the 2.3 branch.

Discussion
----------

[Process] Fixes to executable finder tests

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

A couple of fixes for ExecutableFinder tests:
- Use PHPUnit ini_set wrapper to avoid side effects.
- Skip a test on Windows (similar to an earlier test that was already skipped).
- Removed an unused variable.

Commits
-------

75d0d59 Use PHPUnit ini_set wrapper in tests
99ff8a6 [Process] Added a test skip check for Windows
5a14941 [Process] Removed unused variable assignment
This commit is contained in:
Fabien Potencier 2015-01-03 08:54:46 +01:00
commit a7d5624233
5 changed files with 15 additions and 24 deletions

View File

@ -26,21 +26,14 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
*/
protected $errorReporting;
/**
* @var string Display errors setting before running tests.
*/
protected $displayErrors;
public function setUp()
{
$this->errorReporting = error_reporting(E_ALL | E_STRICT);
$this->displayErrors = ini_get('display_errors');
ini_set('display_errors', '1');
$this->iniSet('display_errors', '1');
}
public function tearDown()
{
ini_set('display_errors', $this->displayErrors);
error_reporting($this->errorReporting);
}

View File

@ -35,8 +35,8 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
ini_set('session.save_handler', 'files');
ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test');
$this->iniSet('session.save_handler', 'files');
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test');
if (!is_dir($this->savePath)) {
mkdir($this->savePath);
}
@ -121,7 +121,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
public function testDefaultSessionCacheLimiter()
{
ini_set('session.cache_limiter', 'nocache');
$this->iniSet('session.cache_limiter', 'nocache');
$storage = new NativeSessionStorage();
$this->assertEquals('', ini_get('session.cache_limiter'));
@ -129,7 +129,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
public function testExplicitSessionCacheLimiter()
{
ini_set('session.cache_limiter', 'nocache');
$this->iniSet('session.cache_limiter', 'nocache');
$storage = new NativeSessionStorage(array('cache_limiter' => 'public'));
$this->assertEquals('public', ini_get('session.cache_limiter'));
@ -171,7 +171,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Test skipped, for PHP 5.3 only.');
}
ini_set('session.save_handler', 'files');
$this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage();
$storage->setSaveHandler();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\NativeProxy', $storage->getSaveHandler());
@ -193,7 +193,7 @@ class NativeSessionStorageTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Test skipped, for PHP 5.4 only.');
}
ini_set('session.save_handler', 'files');
$this->iniSet('session.save_handler', 'files');
$storage = $this->getStorage();
$storage->setSaveHandler();
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy', $storage->getSaveHandler());

View File

@ -30,8 +30,8 @@ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
ini_set('session.save_handler', 'files');
ini_set('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test');
$this->iniSet('session.save_handler', 'files');
$this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test');
if (!is_dir($this->savePath)) {
mkdir($this->savePath);
}

View File

@ -56,8 +56,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWithoutLogger($event, $event2)
{
// store the current error_log, and disable it temporarily
$errorLog = ini_set('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul');
$this->iniSet('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul');
$l = new ExceptionListener('foo');
$l->onKernelException($event);
@ -69,9 +68,6 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
} catch (\Exception $e) {
$this->assertSame('foo', $e->getMessage());
}
// restore the old error_log
ini_set('error_log', $errorLog);
}
/**

View File

@ -102,7 +102,7 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Cannot test when open_basedir is set');
}
ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
$this->iniSet('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
$finder = new ExecutableFinder();
$result = $finder->find($this->getPhpBinaryName());
@ -120,10 +120,12 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Requires the PHP_BINARY constant');
}
$execPath = __DIR__.'/SignalListener.php';
if ('\\' === DIRECTORY_SEPARATOR) {
$this->markTestSkipped('Cannot run test on windows');
}
$this->setPath('');
ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
$this->iniSet('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/');
$finder = new ExecutableFinder();
$result = $finder->find($this->getPhpBinaryName(), false);