Last active
April 19, 2017 06:39
-
-
Save esperecyan/8e8fa0d39989871796640082b566a5ff to your computer and use it in GitHub Desktop.
NetBeansの「PHPUnitスクリプト」欄に指定するファイルです。
This file contains hidden or 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
<?php | |
/** | |
* NetBeansの「PHPUnitスクリプト」欄に指定するファイルです。 | |
* | |
* Windows版のNetBeansでは、名前つきセットを含むテストの再実行が通常できません (PHPUnitプラグイン 0.28 現在) が、 | |
* ファイルメニュー ‣ ツール ‣ オプション ‣ PHP ‣ フレームワークおよびツール ‣ PHPUnit ‣ PHPUnitスクリプト | |
* に本スクリプトファイルを指定することにより、再実行を可能とします。 | |
* | |
* @version 1.1.2 | |
* @license BSD-3-Clause | |
* @author 100の人 | |
*/ | |
$offsets = array_keys($_SERVER['argv'], '--filter'); | |
if ($offsets) { | |
$offset = $offsets[0] + 1; | |
$optionsEndOffsets = array_keys($_SERVER['argv'], '--'); | |
$length = $optionsEndOffsets ? $optionsEndOffsets[0] - 1 - $offset : count($_SERVER['argv']); | |
array_splice($_SERVER['argv'], $offset, $length, [preg_replace_callback( | |
'/(?<=^%|\\|)\\\\b([^ ]+ with data set )(#[0-9][1-9]|.+?)\\\\b(?=\\||%$)/', | |
function (array $matches) { | |
return preg_match('/^#(?:0|[1-9][0-9]*)$/', $matches[2]) | |
? $matches[0] | |
: "$matches[1]\"$matches[2]\""; | |
}, | |
implode(' ', array_slice($_SERVER['argv'], $offset, $length)) | |
)]); | |
} | |
$_SERVER['argv'][0] = 'vendor\\bin\\phpunit.bat'; | |
passthru(implode(' ', array_map(function ($arg) { | |
$arg = preg_replace('/[&|<>()^"%]/', '^$0', $arg); | |
$arg = preg_replace('/\\\\+(?=\\^")/', '$0$0', $arg); | |
return '^"' . str_replace('^"', '\\^"', $arg) . '^"'; | |
}, $_SERVER['argv']))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment