-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
- Loading branch information
Showing
5 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Orchestra\DuskUpdater; | ||
|
||
function chromedriver_binary_filename(string $binary, string $os): string | ||
{ | ||
return strpos($binary, DIRECTORY_SEPARATOR) > 0 | ||
? array_reverse(explode(DIRECTORY_SEPARATOR, str_replace('chromedriver', 'chromedriver-'.$os, $binary), 2))[0] | ||
: str_replace('chromedriver', 'chromedriver-'.$os, $binary); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Orchestra\DuskUpdater\Tests; | ||
|
||
use function Orchestra\DuskUpdater\chromedriver_binary_filename; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HelpersTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider binaryFileDataProvider | ||
*/ | ||
public function test_it_can_resolve_correct_filename($os, $given, $expected) | ||
{ | ||
$this->assertSame(chromedriver_binary_filename($given, $os), $expected); | ||
} | ||
|
||
public static function binaryFileDataProvider() | ||
{ | ||
yield ['linux', 'chromedriver', 'chromedriver-linux']; | ||
yield ['mac-intel', 'chromedriver', 'chromedriver-mac-intel']; | ||
yield ['mac-arm', 'chromedriver', 'chromedriver-mac-arm']; | ||
yield ['win32', 'chromedriver.exe', 'chromedriver-win32.exe']; | ||
|
||
yield ['linux', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-linux']; | ||
yield ['mac-intel', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-mac-intel']; | ||
yield ['mac-arm', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-mac-arm']; | ||
yield ['win32', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver.exe', 'chromedriver-win32.exe']; | ||
} | ||
} |