1
0
Fork 0

Update PHPUnit to 8.5

pull/10343/head
Jordi Boggiano 2021-12-08 17:03:05 +01:00
parent d2ede370be
commit 2a771dfb2d
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
58 changed files with 1385 additions and 749 deletions

View File

@ -97,24 +97,6 @@ jobs:
if: "matrix.dependencies == 'locked'"
run: "composer install ${{ env.COMPOSER_FLAGS }}"
- name: "Require latest PHPUnitBridge for PHP 8.x"
if: "startsWith(matrix.php-version, '8.')"
# using ~ here to avoid issues with windows CLI removing the ^
run: 'composer require --no-update --dev "symfony/phpunit-bridge:~5.2"'
# temporary fix until phpunit-bridge has a release supporting 8.1
- name: "Require latest dev PHPUnitBridge for PHP 8.1"
if: "matrix.experimental"
# using ~ here to avoid issues with windows CLI removing the ^
run: 'composer require --no-update --dev "symfony/phpunit-bridge:~5.4@dev"'
- name: "Set ignored deprecations for php 8.1+ on lowest or locked deps"
if: "matrix.php-version >= '8.1' && !contains(matrix.dependencies, 'highest')"
run: "echo \"SYMFONY_DEPRECATIONS_HELPER=baselineFile=./tests/deprecations-8.1.json&max[direct]=0\" >> $GITHUB_ENV"
- name: "Update dev requirements to latest available for the current PHP even on locked builds as they are not bundled dependencies"
run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge phpspec/prophecy phpdocumentor/* sebastian/* doctrine/instantiator"
- name: "Run install again using composer binary from source"
run: "bin/composer install ${{ env.COMPOSER_FLAGS }}"
@ -123,11 +105,11 @@ jobs:
- name: "Run tests"
if: "matrix.php-version != '7.3'"
run: "vendor/bin/simple-phpunit --verbose"
run: "SYMFONY_PHPUNIT_VERSION=8.5 vendor/bin/simple-phpunit --verbose"
- name: "Run complete test suite on 7.3"
if: "matrix.php-version == '7.3'"
run: "vendor/bin/simple-phpunit --configuration tests/complete.phpunit.xml"
run: "SYMFONY_PHPUNIT_VERSION=8.5 vendor/bin/simple-phpunit --configuration tests/complete.phpunit.xml"
validation:
name: "Composer validation"

View File

@ -49,9 +49,5 @@ jobs:
- name: "Install highest dependencies from composer.json using composer binary provided by system"
run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}"
- name: "Install PHPStan"
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
run: "bin/composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}"
- name: "Run PHPStan"
run: "vendor/bin/phpstan analyse --configuration=phpstan/config.neon"
run: "composer phpstan"

View File

@ -41,7 +41,12 @@
},
"require-dev": {
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"phpspec/prophecy": "^1.10"
"phpspec/prophecy": "^1.10",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1",
"phpstan/phpstan-strict-rules": "^1",
"phpunit/phpunit": "^8.5"
},
"suggest": {
"ext-openssl": "Enabling the openssl extension allows you to access https URLs for repositories and packages",
@ -79,19 +84,15 @@
],
"scripts": {
"compile": "@php -dphar.readonly=0 bin/compile",
"test": "@php simple-phpunit",
"phpstan-setup": [
"@composer config platform --unset",
"@composer update",
"@composer require --dev phpstan/phpstan:^1.0 phpstan/phpstan-phpunit:^1.0 phpstan/phpstan-deprecation-rules:^1 phpstan/phpstan-strict-rules:^1 phpunit/phpunit:^7.5.20 --with-all-dependencies",
"git checkout composer.json composer.lock"
"test": [
"@putenv SYMFONY_PHPUNIT_VERSION=8.5",
"@php simple-phpunit"
],
"phpstan": "@php vendor/bin/phpstan analyse --configuration=phpstan/config.neon"
},
"scripts-descriptions": {
"compile": "Compile composer.phar",
"test": "Run all tests",
"phpstan-setup": "Prepare environment to run PHPStan locally (must be run with PHP7.4)",
"phpstan": "Runs PHPStan (after phpstan-setup was executed, must be run with PHP7.4)"
},
"support": {

1281
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -31,14 +31,14 @@ class AllFunctionalTest extends TestCase
*/
private static $pharPath;
public function setUp()
public function setUp(): void
{
$this->oldcwd = getcwd();
chdir(__DIR__.'/Fixtures/functional');
}
public function tearDown()
public function tearDown(): void
{
if ($this->oldcwd) {
chdir($this->oldcwd);
@ -51,12 +51,12 @@ class AllFunctionalTest extends TestCase
}
}
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$pharPath = self::getUniqueTmpDirectory() . '/composer.phar';
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
$fs = new Filesystem;
$fs->removeDirectory(dirname(self::$pharPath));

View File

@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class ApplicationTest extends TestCase
{
public function tearDown()
public function tearDown(): void
{
parent::tearDown();

View File

@ -29,7 +29,7 @@ use Composer\Installer\InstallationManager;
use Composer\Config;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Platform;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use PHPUnit\Framework\MockObject\MockObject;
class AutoloadGeneratorTest extends TestCase
{
@ -54,12 +54,12 @@ class AutoloadGeneratorTest extends TestCase
private $origDir;
/**
* @var InstallationManager|MockObject
* @var InstallationManager&MockObject
*/
private $im;
/**
* @var InstalledRepositoryInterface|MockObject
* @var InstalledRepositoryInterface&MockObject
*/
private $repository;
@ -74,7 +74,7 @@ class AutoloadGeneratorTest extends TestCase
private $fs;
/**
* @var EventDispatcher|MockObject
* @var EventDispatcher&MockObject
*/
private $eventDispatcher;
@ -89,7 +89,7 @@ class AutoloadGeneratorTest extends TestCase
*/
public $configValueMap;
protected function setUp()
protected function setUp(): void
{
$this->fs = new Filesystem;
$that = $this;
@ -148,7 +148,7 @@ class AutoloadGeneratorTest extends TestCase
$this->generator = new AutoloadGenerator($this->eventDispatcher);
}
protected function tearDown()
protected function tearDown(): void
{
chdir($this->origDir);

View File

@ -28,7 +28,7 @@ class CacheTest extends TestCase
/** @var Cache&\PHPUnit\Framework\MockObject\MockObject */
private $cache;
public function setUp()
public function setUp(): void
{
$this->root = $this->getUniqueTmpDirectory();
$this->files = array();
@ -53,7 +53,7 @@ class CacheTest extends TestCase
->will($this->returnValue($this->finder));
}
protected function tearDown()
protected function tearDown(): void
{
if (is_dir($this->root)) {
$fs = new Filesystem;

View File

@ -34,13 +34,13 @@ class JsonConfigSourceTest extends TestCase
return __DIR__.'/Fixtures/'.$name;
}
protected function setUp()
protected function setUp(): void
{
$this->fs = new Filesystem;
$this->workingDir = $this->getUniqueTmpDirectory();
}
protected function tearDown()
protected function tearDown(): void
{
if (is_dir($this->workingDir)) {
$this->fs->removeDirectory($this->workingDir);

View File

@ -32,7 +32,7 @@ class DefaultPolicyTest extends TestCase
/** @var DefaultPolicy */
protected $policy;
public function setUp()
public function setUp(): void
{
$this->repositorySet = new RepositorySet('dev');
$this->repo = new ArrayRepository;

View File

@ -27,7 +27,7 @@ class RuleSetIteratorTest extends TestCase
/** @var Pool */
protected $pool;
protected function setUp()
protected function setUp(): void
{
$this->pool = new Pool();

View File

@ -48,7 +48,7 @@ class SolverTest extends TestCase
/** @var Pool */
protected $pool;
public function setUp()
public function setUp(): void
{
$this->repoSet = new RepositorySet();
$this->repo = new ArrayRepository;

View File

@ -23,7 +23,7 @@ use Composer\Test\TestCase;
class TransactionTest extends TestCase
{
public function setUp()
public function setUp(): void
{
}

View File

@ -23,7 +23,7 @@ class DownloadManagerTest extends TestCase
/** @var \Composer\IO\IOInterface&\PHPUnit\Framework\MockObject\MockObject */
protected $io;
public function setUp()
public function setUp(): void
{
$this->filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();

View File

@ -30,7 +30,7 @@ class FileDownloaderTest extends TestCase
/** @var \Composer\Config&\PHPUnit\Framework\MockObject\MockObject */
private $config;
public function setUp()
public function setUp(): void
{
$this->httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
$this->config = $this->getMockBuilder('Composer\Config')->getMock();

View File

@ -22,12 +22,12 @@ class FossilDownloaderTest extends TestCase
/** @var string */
private $workingDir;
protected function setUp()
protected function setUp(): void
{
$this->workingDir = $this->getUniqueTmpDirectory();
}
protected function tearDown()
protected function tearDown(): void
{
if (is_dir($this->workingDir)) {
$fs = new Filesystem;

View File

@ -27,7 +27,7 @@ class GitDownloaderTest extends TestCase
/** @var string */
private $workingDir;
protected function setUp()
protected function setUp(): void
{
$this->skipIfNotExecutable('git');
@ -37,7 +37,7 @@ class GitDownloaderTest extends TestCase
$this->workingDir = $this->getUniqueTmpDirectory();
}
protected function tearDown()
protected function tearDown(): void
{
if (is_dir($this->workingDir)) {
$this->fs->removeDirectory($this->workingDir);

View File

@ -22,12 +22,12 @@ class HgDownloaderTest extends TestCase
/** @var string */
private $workingDir;
protected function setUp()
protected function setUp(): void
{
$this->workingDir = $this->getUniqueTmpDirectory();
}
protected function tearDown()
protected function tearDown(): void
{
if (is_dir($this->workingDir)) {
$fs = new Filesystem;

View File

@ -43,7 +43,7 @@ class PerforceDownloaderTest extends TestCase
/** @var string */
protected $testPath;
protected function setUp()
protected function setUp(): void
{
$this->testPath = $this->getUniqueTmpDirectory();
$this->repoConfig = $this->getRepoConfig();

View File

@ -31,7 +31,7 @@ class XzDownloaderTest extends TestCase
*/
private $testDir;
public function setUp()
public function setUp(): void
{
if (Platform::isWindows()) {
$this->markTestSkipped('Skip test on Windows');
@ -39,7 +39,7 @@ class XzDownloaderTest extends TestCase
$this->testDir = $this->getUniqueTmpDirectory();
}
public function tearDown()
public function tearDown(): void
{
$this->fs = new Filesystem;
$this->fs->removeDirectory($this->testDir);

View File

@ -32,7 +32,7 @@ class ZipDownloaderTest extends TestCase
/** @var \Composer\Package\PackageInterface&\PHPUnit\Framework\MockObject\MockObject */
private $package;
public function setUp()
public function setUp(): void
{
$this->testDir = $this->getUniqueTmpDirectory();
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
@ -42,7 +42,7 @@ class ZipDownloaderTest extends TestCase
$this->package = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem;
$fs->removeDirectory($this->testDir);

View File

@ -22,7 +22,7 @@ class InstalledVersionsTest extends TestCase
*/
private $root;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
// disable multiple-ClassLoader-based checks of InstalledVersions by making it seem like no
// class loaders are registered
@ -31,12 +31,12 @@ class InstalledVersionsTest extends TestCase
$prop->setValue(array());
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
self::setUpBeforeClass();
}
public function setUp()
public function setUp(): void
{
$this->root = $this->getUniqueTmpDirectory();

View File

@ -46,7 +46,7 @@ class BinaryInstallerTest extends TestCase
*/
protected $fs;
protected function setUp()
protected function setUp(): void
{
$this->fs = new Filesystem;
@ -60,7 +60,7 @@ class BinaryInstallerTest extends TestCase
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
}
protected function tearDown()
protected function tearDown(): void
{
$this->fs->removeDirectory($this->rootDir);
}

View File

@ -36,7 +36,7 @@ class InstallationManagerTest extends TestCase
*/
protected $io;
public function setUp()
public function setUp(): void
{
$this->loop = $this->getMockBuilder('Composer\Util\Loop')->disableOriginalConstructor()->getMock();
$this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();

View File

@ -65,7 +65,7 @@ class LibraryInstallerTest extends TestCase
*/
protected $fs;
protected function setUp()
protected function setUp(): void
{
$this->fs = new Filesystem;
@ -96,7 +96,7 @@ class LibraryInstallerTest extends TestCase
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
}
protected function tearDown()
protected function tearDown(): void
{
$this->fs->removeDirectory($this->rootDir);
}

View File

@ -30,7 +30,7 @@ class MetapackageInstallerTest extends TestCase
*/
private $io;
protected function setUp()
protected function setUp(): void
{
$this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();

View File

@ -30,7 +30,7 @@ class SuggestedPackagesReporterTest extends TestCase
*/
private $suggestedPackagesReporter;
protected function setUp()
protected function setUp(): void
{
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();

View File

@ -50,13 +50,13 @@ class InstallerTest extends TestCase
/** @var ?string */
protected $tempComposerHome;
public function setUp()
public function setUp(): void
{
$this->prevCwd = getcwd();
chdir(__DIR__);
}
public function tearDown()
public function tearDown(): void
{
Platform::clearEnv('COMPOSER_POOL_OPTIMIZER');

View File

@ -33,7 +33,7 @@ class ArchivableFilesFinderTest extends TestCase
*/
protected $fs;
protected function setUp()
protected function setUp(): void
{
$fs = new Filesystem;
$this->fs = $fs;
@ -95,7 +95,7 @@ class ArchivableFilesFinderTest extends TestCase
}
}
protected function tearDown()
protected function tearDown(): void
{
$fs = new Filesystem;
$fs->removeDirectory($this->sources);

View File

@ -32,7 +32,7 @@ class ArchiveManagerTest extends ArchiverTest
*/
protected $targetDir;
public function setUp()
public function setUp(): void
{
parent::setUp();

View File

@ -34,14 +34,14 @@ abstract class ArchiverTest extends TestCase
*/
protected $testDir;
public function setUp()
public function setUp(): void
{
$this->filesystem = new Filesystem();
$this->process = new ProcessExecutor();
$this->testDir = $this->getUniqueTmpDirectory();
}
public function tearDown()
public function tearDown(): void
{
$this->filesystem->removeDirectory($this->testDir);
}

View File

@ -24,11 +24,11 @@ class ArrayDumperTest extends TestCase
*/
private $dumper;
/**
* @var \Composer\Package\CompletePackageInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Composer\Package\CompletePackageInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private $package;
public function setUp()
public function setUp(): void
{
$this->dumper = new ArrayDumper();
$this->package = $this->getMockBuilder('Composer\Package\CompletePackageInterface')->getMock();

View File

@ -24,7 +24,7 @@ class ArrayLoaderTest extends TestCase
*/
private $loader;
public function setUp()
public function setUp(): void
{
$this->loader = new ArrayLoader(null);
}

View File

@ -22,7 +22,7 @@ use Composer\Test\Mock\ProcessExecutorMock;
class VersionGuesserTest extends TestCase
{
public function setUp()
public function setUp(): void
{
if (!function_exists('proc_open')) {
$this->markTestSkipped('proc_open() is not available');

View File

@ -25,7 +25,7 @@ class HhvmDetectorTest extends TestCase
*/
private $hhvmDetector;
protected function setUp()
protected function setUp(): void
{
$this->hhvmDetector = new HhvmDetector();
$this->hhvmDetector->reset();

View File

@ -68,7 +68,7 @@ class PluginInstallerTest extends TestCase
*/
protected $io;
protected function setUp()
protected function setUp(): void
{
$loader = new JsonLoader(new ArrayLoader());
$this->packages = array();
@ -127,7 +127,7 @@ class PluginInstallerTest extends TestCase
$this->composer->setPluginManager($this->pm);
}
protected function tearDown()
protected function tearDown(): void
{
$filesystem = new Filesystem();
$filesystem->removeDirectory($this->directory);

View File

@ -12,10 +12,8 @@
namespace Composer\Test {
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Constraint\LogicalNot;
use PHPUnit\Framework\Constraint\StringContains;
if (method_exists('PHPUnit\Framework\TestCase', 'assertStringContainsString')) {
if (method_exists('PHPUnit\Framework\TestCase', 'assertFileDoesNotExist')) {
abstract class PolyfillTestCase extends TestCase
{
}
@ -23,196 +21,6 @@ namespace Composer\Test {
abstract class PolyfillTestCase extends TestCase
{
// all the functions below are form https://github.com/symfony/phpunit-bridge/blob/bd341a45ef79b30918376e8b8e2279fac6894c3b/Legacy/PolyfillAssertTrait.php
/**
* @param string $message
*
* @return void
*/
public static function assertIsInt($actual, $message = '')
{
static::assertInternalType('int', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsNumeric($actual, $message = '')
{
static::assertInternalType('numeric', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsObject($actual, $message = '')
{
static::assertInternalType('object', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsResource($actual, $message = '')
{
static::assertInternalType('resource', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsString($actual, $message = '')
{
static::assertInternalType('string', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsScalar($actual, $message = '')
{
static::assertInternalType('scalar', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsCallable($actual, $message = '')
{
static::assertInternalType('callable', $actual, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertIsIterable($actual, $message = '')
{
static::assertInternalType('iterable', $actual, $message);
}
/**
* @param string $needle
* @param string $haystack
* @param string $message
*
* @return void
*/
public static function assertStringContainsString($needle, $haystack, $message = '')
{
$constraint = new StringContains($needle, false);
static::assertThat($haystack, $constraint, $message);
}
/**
* @param string $needle
* @param string $haystack
* @param string $message
*
* @return void
*/
public static function assertStringContainsStringIgnoringCase($needle, $haystack, $message = '')
{
$constraint = new StringContains($needle, true);
static::assertThat($haystack, $constraint, $message);
}
/**
* @param string $needle
* @param string $haystack
* @param string $message
*
* @return void
*/
public static function assertStringNotContainsString($needle, $haystack, $message = '')
{
$constraint = new LogicalNot(new StringContains($needle, false));
static::assertThat($haystack, $constraint, $message);
}
/**
* @param string $needle
* @param string $haystack
* @param string $message
*
* @return void
*/
public static function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = '')
{
$constraint = new LogicalNot(new StringContains($needle, true));
static::assertThat($haystack, $constraint, $message);
}
/**
* @param string $message
*
* @return void
*/
public static function assertFinite($actual, $message = '')
{
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_finite($actual), $message ? $message : "Failed asserting that $actual is finite.");
}
/**
* @param string $message
*
* @return void
*/
public static function assertInfinite($actual, $message = '')
{
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_infinite($actual), $message ? $message : "Failed asserting that $actual is infinite.");
}
/**
* @param string $message
*
* @return void
*/
public static function assertNan($actual, $message = '')
{
static::assertInternalType('float', $actual, $message);
static::assertTrue(is_nan($actual), $message ? $message : "Failed asserting that $actual is nan.");
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertIsReadable($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertTrue(is_readable($filename), $message ? $message : "Failed asserting that $filename is readable.");
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertNotIsReadable($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertFalse(is_readable($filename), $message ? $message : "Failed asserting that $filename is not readable.");
}
/**
* @param string $filename
* @param string $message
@ -224,30 +32,6 @@ namespace Composer\Test {
static::assertNotIsReadable($filename, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertIsWritable($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertTrue(is_writable($filename), $message ? $message : "Failed asserting that $filename is writable.");
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertNotIsWritable($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertFalse(is_writable($filename), $message ? $message : "Failed asserting that $filename is not writable.");
}
/**
* @param string $filename
* @param string $message
@ -259,30 +43,6 @@ namespace Composer\Test {
static::assertNotIsWritable($filename, $message);
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryExists($directory, $message = '')
{
static::assertInternalType('string', $directory, $message);
static::assertTrue(is_dir($directory), $message ? $message : "Failed asserting that $directory exists.");
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryNotExists($directory, $message = '')
{
static::assertInternalType('string', $directory, $message);
static::assertFalse(is_dir($directory), $message ? $message : "Failed asserting that $directory does not exist.");
}
/**
* @param string $directory
* @param string $message
@ -294,30 +54,6 @@ namespace Composer\Test {
static::assertDirectoryNotExists($directory, $message);
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryIsReadable($directory, $message = '')
{
static::assertDirectoryExists($directory, $message);
static::assertIsReadable($directory, $message);
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryNotIsReadable($directory, $message = '')
{
static::assertDirectoryExists($directory, $message);
static::assertNotIsReadable($directory, $message);
}
/**
* @param string $directory
* @param string $message
@ -329,30 +65,6 @@ namespace Composer\Test {
static::assertDirectoryNotIsReadable($directory, $message);
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryIsWritable($directory, $message = '')
{
static::assertDirectoryExists($directory, $message);
static::assertIsWritable($directory, $message);
}
/**
* @param string $directory
* @param string $message
*
* @return void
*/
public static function assertDirectoryNotIsWritable($directory, $message = '')
{
static::assertDirectoryExists($directory, $message);
static::assertNotIsWritable($directory, $message);
}
/**
* @param string $directory
* @param string $message
@ -364,30 +76,6 @@ namespace Composer\Test {
static::assertDirectoryNotIsWritable($directory, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileExists($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertTrue(file_exists($filename), $message ? $message : "Failed asserting that $filename exists.");
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileNotExists($filename, $message = '')
{
static::assertInternalType('string', $filename, $message);
static::assertFalse(file_exists($filename), $message ? $message : "Failed asserting that $filename does not exist.");
}
/**
* @param string $filename
* @param string $message
@ -399,30 +87,6 @@ namespace Composer\Test {
static::assertFileNotExists($filename, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileIsReadable($filename, $message = '')
{
static::assertFileExists($filename, $message);
static::assertIsReadable($filename, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileNotIsReadable($filename, $message = '')
{
static::assertFileExists($filename, $message);
static::assertNotIsReadable($filename, $message);
}
/**
* @param string $filename
* @param string $message
@ -434,30 +98,6 @@ namespace Composer\Test {
static::assertFileNotIsReadable($filename, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileIsWritable($filename, $message = '')
{
static::assertFileExists($filename, $message);
static::assertIsWritable($filename, $message);
}
/**
* @param string $filename
* @param string $message
*
* @return void
*/
public static function assertFileNotIsWritable($filename, $message = '')
{
static::assertFileExists($filename, $message);
static::assertNotIsWritable($filename, $message);
}
/**
* @param string $filename
* @param string $message
@ -495,265 +135,3 @@ namespace Composer\Test {
}
}
}
namespace {
foreach (array(
'PHPUnit\Framework\Constraint\IsEqual',
'PHPUnit\Framework\Constraint\StringContains',
'PHPUnit\Framework\Constraint\TraversableContains',
) as $class) {
if (!class_exists($class) && class_exists(str_replace('\\', '_', $class))) {
class_alias(str_replace('\\', '_', $class), $class);
}
}
foreach (array(
'PHPUnit\Framework\SelfDescribing',
) as $interface) {
if (!interface_exists($interface) && interface_exists(str_replace('\\', '_', $interface))) {
class_alias(str_replace('\\', '_', $interface), $interface);
}
}
if (!class_exists('PHPUnit\Framework\Constraint\Constraint')) {
class_alias('PHPUnit_Framework_Constraint', 'PHPUnit\Framework\Constraint\Constraint');
}
}
// all the code below taken from various PHPUnit versions to make things work on PHPUnit 4.8 / PHP 5.3
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\Constraint {
use PHPUnit\Framework\ExpectationFailedException;
if (!class_exists('PHPUnit\Framework\Constraint\RegularExpression')) {
/**
* Constraint that asserts that the string it is evaluated for matches
* a regular expression.
*
* Checks a given value using the Perl Compatible Regular Expression extension
* in PHP. The pattern is matched by executing preg_match().
*
* The pattern string passed in the constructor.
*/
class RegularExpression extends Constraint
{
/**
* @var string
*/
protected $pattern;
/**
* @param string $pattern
*/
public function __construct($pattern)
{
parent::__construct();
$this->pattern = $pattern;
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
protected function matches($other)
{
return \preg_match($this->pattern, $other) > 0;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return \sprintf(
'matches PCRE pattern "%s"',
$this->pattern
);
}
}
}
if (!class_exists('PHPUnit\Framework\Constraint\LogicalNot')) {
/**
* Logical NOT.
*/
class LogicalNot extends Constraint
{
/**
* @var Constraint
*/
protected $constraint;
/**
* @param Constraint $constraint
*/
public function __construct($constraint)
{
parent::__construct();
if (!($constraint instanceof Constraint)) {
$constraint = new IsEqual($constraint);
}
$this->constraint = $constraint;
}
/**
* @param string $string
*
* @return string
*/
public static function negate($string)
{
$positives = array(
'contains ',
'exists',
'has ',
'is ',
'are ',
'matches ',
'starts with ',
'ends with ',
'reference ',
'not not ',
);
$negatives = array(
'does not contain ',
'does not exist',
'does not have ',
'is not ',
'are not ',
'does not match ',
'starts not with ',
'ends not with ',
'don\'t reference ',
'not ',
);
\preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches);
if (\count($matches) > 0) {
$nonInput = $matches[2];
$negatedString = \str_replace(
$nonInput,
\str_replace(
$positives,
$negatives,
$nonInput
),
$string
);
} else {
$negatedString = \str_replace(
$positives,
$negatives,
$string
);
}
return $negatedString;
}
/**
* Evaluates the constraint for parameter $other
*
* If $returnResult is set to false (the default), an exception is thrown
* in case of a failure. null is returned otherwise.
*
* If $returnResult is true, the result of the evaluation is returned as
* a boolean value instead: true in case of success, false in case of a
* failure.
*
* @param mixed $other Value or object to evaluate.
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
*
* @throws ExpectationFailedException
* @return mixed
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = !$this->constraint->evaluate($other, $description, true);
if ($returnResult) {
return $success;
}
if (!$success) {
$this->fail($other, $description);
}
}
/**
* Returns the description of the failure
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other Evaluated value or object.
*
* @return string
*/
protected function failureDescription($other)
{
switch (\get_class($this->constraint)) {
case 'PHPUnit\Framework\Constraint\LogicalAnd':
case 'PHPUnit\Framework\Constraint\LogicalNot':
case 'PHPUnit\Framework\Constraint\LogicalOr':
return 'not( ' . $this->constraint->failureDescription($other) . ' )';
default:
return self::negate(
$this->constraint->failureDescription($other)
);
}
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
switch (\get_class($this->constraint)) {
case 'PHPUnit\Framework\Constraint\LogicalAnd':
case 'PHPUnit\Framework\Constraint\LogicalNot':
case 'PHPUnit\Framework\Constraint\LogicalOr':
return 'not( ' . $this->constraint->toString() . ' )';
default:
return self::negate(
$this->constraint->toString()
);
}
}
/**
* Counts the number of constraint elements.
*
* @return int
*/
public function count()
{
return \count($this->constraint);
}
}
}
}

View File

@ -19,7 +19,7 @@ use Composer\Package\BasePackage;
class ArtifactRepositoryTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
if (!extension_loaded('zip')) {

View File

@ -25,7 +25,7 @@ class FilterRepositoryTest extends TestCase
*/
private $arrayRepo;
public function setUp()
public function setUp(): void
{
$this->arrayRepo = new ArrayRepository();
$this->arrayRepo->addPackage($this->getPackage('foo/aaa', '1.0.0'));

View File

@ -21,12 +21,12 @@ class RepositoryManagerTest extends TestCase
/** @var string */
protected $tmpdir;
public function setUp()
public function setUp(): void
{
$this->tmpdir = $this->getUniqueTmpDirectory();
}
public function tearDown()
public function tearDown(): void
{
if (is_dir($this->tmpdir)) {
$fs = new Filesystem();

View File

@ -28,7 +28,7 @@ class FossilDriverTest extends TestCase
*/
protected $config;
public function setUp()
public function setUp(): void
{
$this->home = $this->getUniqueTmpDirectory();
$this->config = new Config();
@ -39,7 +39,7 @@ class FossilDriverTest extends TestCase
));
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem();
$fs->removeDirectory($this->home);

View File

@ -33,7 +33,7 @@ class GitBitbucketDriverTest extends TestCase
/** @var string */
private $home;
protected function setUp()
protected function setUp(): void
{
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
@ -51,7 +51,7 @@ class GitBitbucketDriverTest extends TestCase
->getMock();
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem;
$fs->removeDirectory($this->home);

View File

@ -28,7 +28,7 @@ class GitHubDriverTest extends TestCase
/** @var Config */
private $config;
public function setUp()
public function setUp(): void
{
$this->home = $this->getUniqueTmpDirectory();
$this->config = new Config();
@ -39,7 +39,7 @@ class GitHubDriverTest extends TestCase
));
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem;
$fs->removeDirectory($this->home);

View File

@ -45,7 +45,7 @@ class GitLabDriverTest extends TestCase
*/
private $httpDownloader;
public function setUp()
public function setUp(): void
{
$this->home = $this->getUniqueTmpDirectory();
$this->config = new Config();
@ -66,7 +66,7 @@ class GitLabDriverTest extends TestCase
$this->httpDownloader = $this->prophesize('Composer\Util\HttpDownloader');
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem();
$fs->removeDirectory($this->home);

View File

@ -26,7 +26,7 @@ class HgDriverTest extends TestCase
/** @var string */
private $home;
public function setUp()
public function setUp(): void
{
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->home = $this->getUniqueTmpDirectory();
@ -38,7 +38,7 @@ class HgDriverTest extends TestCase
));
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem;
$fs->removeDirectory($this->home);

View File

@ -61,7 +61,7 @@ class PerforceDriverTest extends TestCase
const TEST_DEPOT = 'TEST_DEPOT_CONFIG';
const TEST_BRANCH = 'TEST_BRANCH_CONFIG';
protected function setUp()
protected function setUp(): void
{
$this->testPath = $this->getUniqueTmpDirectory();
$this->config = $this->getTestConfig($this->testPath);
@ -78,7 +78,7 @@ class PerforceDriverTest extends TestCase
$this->overrideDriverInternalPerforce($this->perforce);
}
protected function tearDown()
protected function tearDown(): void
{
//cleanup directory under test path
$fs = new Filesystem;

View File

@ -29,7 +29,7 @@ class SvnDriverTest extends TestCase
*/
protected $config;
public function setUp()
public function setUp(): void
{
$this->home = $this->getUniqueTmpDirectory();
$this->config = new Config();
@ -40,7 +40,7 @@ class SvnDriverTest extends TestCase
));
}
public function tearDown()
public function tearDown(): void
{
$fs = new Filesystem();
$fs->removeDirectory($this->home);

View File

@ -130,7 +130,7 @@ class VcsRepositoryTest extends TestCase
chdir($oldCwd);
}
public function setUp()
public function setUp(): void
{
if (!self::$gitRepo) {
$this->initialize();
@ -140,7 +140,7 @@ class VcsRepositoryTest extends TestCase
}
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
$fs = new Filesystem;
$fs->removeDirectory(self::$composerHome);

View File

@ -31,7 +31,7 @@ class AuthHelperTest extends TestCase
/** @var AuthHelper */
private $authHelper;
protected function setUp()
protected function setUp(): void
{
$this->io = $this
->getMockBuilder('Composer\IO\IOInterface')

View File

@ -48,7 +48,7 @@ class BitbucketTest extends TestCase
/** @var int */
private $time;
protected function setUp()
protected function setUp(): void
{
$this->io = $this
->getMockBuilder('Composer\IO\ConsoleIO')

View File

@ -20,12 +20,12 @@ use Composer\Test\TestCase;
*/
class ErrorHandlerTest extends TestCase
{
public function setUp()
public function setUp(): void
{
ErrorHandler::register();
}
public function tearDown()
public function tearDown(): void
{
restore_error_handler();
}

View File

@ -32,14 +32,14 @@ class FilesystemTest extends TestCase
*/
private $testFile;
public function setUp()
public function setUp(): void
{
$this->fs = new Filesystem;
$this->workingDir = $this->getUniqueTmpDirectory();
$this->testFile = $this->getUniqueTmpDirectory() . '/composer_test_file';
}
public function tearDown()
public function tearDown(): void
{
if (is_dir($this->workingDir)) {
$this->fs->removeDirectory($this->workingDir);

View File

@ -32,7 +32,7 @@ class GitTest extends TestCase
/** @var Filesystem&\PHPUnit\Framework\MockObject\MockObject */
private $fs;
protected function setUp()
protected function setUp(): void
{
$this->io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->config = $this->getMockBuilder('Composer\Config')->disableOriginalConstructor()->getMock();

View File

@ -17,7 +17,7 @@ use Composer\Test\TestCase;
class ProxyHelperTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
unset(
$_SERVER['HTTP_PROXY'],
@ -30,7 +30,7 @@ class ProxyHelperTest extends TestCase
);
}
protected function tearDown()
protected function tearDown(): void
{
unset(
$_SERVER['HTTP_PROXY'],

View File

@ -17,7 +17,7 @@ use Composer\Test\TestCase;
class ProxyManagerTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
unset(
$_SERVER['HTTP_PROXY'],
@ -31,7 +31,7 @@ class ProxyManagerTest extends TestCase
ProxyManager::reset();
}
protected function tearDown()
protected function tearDown(): void
{
unset(
$_SERVER['HTTP_PROXY'],

View File

@ -73,7 +73,7 @@ class IniHelperTest extends TestCase
$this->assertEquals($paths, IniHelper::getAll());
}
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
// Register our name with XdebugHandler
$xdebug = new XdebugHandler('composer');
@ -81,7 +81,7 @@ class IniHelperTest extends TestCase
self::$envOriginal = getenv('COMPOSER_ORIGINAL_INIS');
}
public static function tearDownAfterClass()
public static function tearDownAfterClass(): void
{
// Restore original state
if (false !== self::$envOriginal) {

View File

@ -37,7 +37,7 @@ class PerforceTest extends TestCase
const TEST_PORT = 'port';
const TEST_PATH = 'path';
protected function setUp()
protected function setUp(): void
{
$this->processExecutor = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
$this->repoConfig = $this->getTestRepoConfig();

View File

@ -18,13 +18,13 @@ use Composer\Test\TestCase;
class StreamContextFactoryTest extends TestCase
{
protected function setUp()
protected function setUp(): void
{
unset($_SERVER['HTTP_PROXY'], $_SERVER['http_proxy'], $_SERVER['HTTPS_PROXY'], $_SERVER['https_proxy'], $_SERVER['NO_PROXY'], $_SERVER['no_proxy']);
ProxyManager::reset();
}
protected function tearDown()
protected function tearDown(): void
{
unset($_SERVER['HTTP_PROXY'], $_SERVER['http_proxy'], $_SERVER['HTTPS_PROXY'], $_SERVER['https_proxy'], $_SERVER['NO_PROXY'], $_SERVER['no_proxy']);
ProxyManager::reset();