minor #11397 [2.3][Process] Fix unit tests on Windows platform (romainneutron)

This PR was merged into the 2.3 branch.

Discussion
----------

[2.3][Process] Fix unit tests on Windows platform

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

Commits
-------

d418935 [Process] Fix unit tests on Windows platform
This commit is contained in:
Fabien Potencier 2014-07-16 14:58:19 +02:00
commit 45df2f314c
1 changed files with 20 additions and 6 deletions

View File

@ -47,9 +47,9 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$this->setPath(dirname(PHP_BINARY));
$finder = new ExecutableFinder;
$result = $finder->find(basename(PHP_BINARY));
$result = $finder->find($this->getPhpBinaryName());
$this->assertEquals($result, PHP_BINARY);
$this->assertSamePath(PHP_BINARY, $result);
}
public function testFindWithDefault()
@ -83,9 +83,9 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
$extraDirs = array(dirname(PHP_BINARY));
$finder = new ExecutableFinder;
$result = $finder->find(basename(PHP_BINARY), null, $extraDirs);
$result = $finder->find($this->getPhpBinaryName(), null, $extraDirs);
$this->assertEquals(PHP_BINARY, $result);
$this->assertSamePath(PHP_BINARY, $result);
}
public function testFindWithOpenBaseDir()
@ -105,8 +105,22 @@ class ExecutableFinderTest extends \PHPUnit_Framework_TestCase
ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
$finder = new ExecutableFinder;
$result = $finder->find(basename(PHP_BINARY));
$result = $finder->find($this->getPhpBinaryName());
$this->assertEquals(PHP_BINARY, $result);
$this->assertSamePath(PHP_BINARY, $result);
}
private function assertSamePath($expected, $tested)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->assertEquals(strtolower($expected), strtolower($tested));
} else {
$this->assertEquals($expected, $tested);
}
}
private function getPhpBinaryName()
{
return basename(PHP_BINARY, defined('PHP_WINDOWS_VERSION_BUILD') ? '.exe' : '');
}
}