diff --git a/phpunit b/phpunit index 74df7131b8..3a39e107db 100755 --- a/phpunit +++ b/phpunit @@ -24,15 +24,19 @@ if (!file_exists($COMPOSER = __DIR__.'/composer.phar')) { $PHP = ProcessUtils::escapeArgument($PHP); $COMPOSER = $PHP.' '.ProcessUtils::escapeArgument($COMPOSER); -if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) { +if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__) !== @file_get_contents("$PHPUNIT_DIR/.md5") || (isset($argv[1]) && 'install' === $argv[1])) { // Build a standalone phpunit without symfony/yaml $oldPwd = getcwd(); @mkdir($PHPUNIT_DIR); chdir($PHPUNIT_DIR); + if (file_exists("phpunit-$PHPUNIT_VERSION")) { + passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'del /S /F /Q %s & rmdir %1$s >nul 2>&1': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION")); + } if (extension_loaded('openssl') && ini_get('allow_url_fopen')) { stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb')); } else { + @unlink("$PHPUNIT_VERSION.zip"); passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip"); } $zip = new ZipArchive(); @@ -43,7 +47,14 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) { passthru("$COMPOSER remove --no-update symfony/yaml"); passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); passthru("$COMPOSER install --prefer-source --no-progress --ansi"); + chdir('..'); + if (file_exists('../src/Symfony/Bridge/PhpUnit') && `git diff --name-only HEAD^ -- ../src/Symfony/Bridge/PhpUnit`) { + 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"))); + symlink(realpath('../src/Symfony/Bridge/PhpUnit'), "phpunit-$PHPUNIT_VERSION/vendor/symfony/phpunit-bridge"); + } + file_put_contents('.md5', md5_file(__FILE__)); chdir($oldPwd); + } $cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);