Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfbda28

Browse files
Merge branch '2.7' into 2.8
* 2.7: [phpunit] Upgrade when a change is detected and when install subcommand is used
2 parents f5da7aa + e49fa27 commit cfbda28

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

phpunit

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ if (!file_exists($COMPOSER = __DIR__.'/composer.phar')) {
2424
$PHP = ProcessUtils::escapeArgument($PHP);
2525
$COMPOSER = $PHP.' '.ProcessUtils::escapeArgument($COMPOSER);
2626

27-
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
27+
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.md5") || (isset($argv[1]) && 'install' === $argv[1])) {
2828
// Build a standalone phpunit without symfony/yaml
2929

3030
$oldPwd = getcwd();
3131
@mkdir($PHPUNIT_DIR);
3232
chdir($PHPUNIT_DIR);
33+
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
34+
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'del /S /F /Q %s & rmdir %1$s >nul 2>&1': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
35+
}
3336
if (extension_loaded('openssl') && ini_get('allow_url_fopen')) {
3437
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
3538
} else {
39+
@unlink("$PHPUNIT_VERSION.zip");
3640
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
3741
}
3842
$zip = new ZipArchive();
@@ -43,7 +47,14 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
4347
passthru("$COMPOSER remove --no-update symfony/yaml");
4448
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\"");
4549
passthru("$COMPOSER install --prefer-source --no-progress --ansi");
50+
chdir('..');
51+
if (file_exists('../src/Symfony/Bridge/PhpUnit') && `git diff --name-only HEAD^ -- ../src/Symfony/Bridge/PhpUnit`) {
52+
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'del /S /F /Q %s & rmdir %1$s >nul 2>&1': 'rm -rf %s', str_replace('/', DIRECTORY_SEPARATOR, "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge")));
53+
symlink(realpath('../src/Symfony/Bridge/PhpUnit'), "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge");
54+
}
55+
file_put_contents('.md5', md5_file(__FILE__));
4656
chdir($oldPwd);
57+
4758
}
4859

4960
$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);

0 commit comments

Comments
 (0)