8000 minor #11397 [2.3][Process] Fix unit tests on Windows platform (romai… · symfony/symfony@45df2f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45df2f3

Browse files
committed
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
2 parents ace5a29 + d418935 commit 45df2f3

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function testFind()
4747
$this->setPath(dirname(PHP_BINARY));
4848

4949
$finder = new ExecutableFinder;
50-
$result = $finder->find(basename(PHP_BINARY));
50+
$result = $finder->find($this->getPhpBinaryName());
5151

52-
$this->assertEquals($result, PHP_BINARY);
52+
$this->assertSamePath(PHP_BINARY, $result);
5353
}
5454

5555
public function testFindWithDefault()
@@ -83,9 +83,9 @@ public function testFindWithExtraDirs()
8383
$extraDirs = array(dirname(PHP_BINARY));
8484

8585
$finder = new ExecutableFinder;
86-
$result = $finder->find(basename(PHP_BINARY), null, $extraDirs);
86+
$result = $finder->find($this->getPhpBinaryName(), null, $extraDirs);
8787

88-
$this->assertEquals(PHP_BINARY, $result);
88+
$this->assertSamePath(PHP_BINARY, $result);
8989
}
9090

9191
public function testFindWithOpenBaseDir()
@@ -105,8 +105,22 @@ public function testFindWithOpenBaseDir()
105105
ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/');
106106

107107
$finder = new ExecutableFinder;
108-
$result = $finder->find(basename(PHP_BINARY));
108+
$result = $finder->find($this->getPhpBinaryName());
109109

110-
$this->assertEquals(PHP_BINARY, $result);
110+
$this->assertSamePath(PHP_BINARY, $result);
111+
}
112+
113+
private function assertSamePath($expected, $tested)
114+
{
115+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
116+
$this->assertEquals(strtolower($expected), strtolower($tested));
117+
} else {
118+
$this->assertEquals($expected, $tested);
119+
}
120+
}
121+
122+
private function getPhpBinaryName()
123+
{
124+
return basename(PHP_BINARY, defined('PHP_WINDOWS_VERSION_BUILD') ? '.exe' : '');
111125
}
112126
}

0 commit comments

Comments
 (0)
0