Merge pull request #9200 from Seldaek/phpunit-warns
Fix warnings on higher phpunit versionspull/9203/head
commit
a1c731b552
|
@ -154,7 +154,7 @@ jobs:
|
|||
|
||||
- name: "Run tests"
|
||||
if: "matrix.php-version != '7.3'"
|
||||
run: "vendor/bin/simple-phpunit"
|
||||
run: "vendor/bin/simple-phpunit --verbose"
|
||||
|
||||
- name: "Run complete test suite on 7.3"
|
||||
if: "matrix.php-version == '7.3'"
|
||||
|
|
|
@ -4,6 +4,7 @@ parameters:
|
|||
- '../tests/Composer/Test/Fixtures/*'
|
||||
- '../tests/Composer/Test/Autoload/Fixtures/*'
|
||||
- '../tests/Composer/Test/Plugin/Fixtures/*'
|
||||
- '../tests/Composer/Test/PolyfillTestCase.php'
|
||||
ignoreErrors:
|
||||
# unused parameters
|
||||
- '~^Constructor of class Composer\\Repository\\VcsRepository has an unused parameter \$dispatcher\.$~'
|
||||
|
@ -24,7 +25,7 @@ parameters:
|
|||
- '~^Unsafe usage of new static\(\)\.$~'
|
||||
|
||||
# BC with older PHPUnit
|
||||
- '~^Call to an undefined static method PHPUnit\\Framework\\TestCase::setExpectedException\(\)\.$~'
|
||||
- '~^Call to an undefined static method Composer\\Test\\PolyfillTestCase::setExpectedException\(\)\.$~'
|
||||
|
||||
paths:
|
||||
- ../src
|
||||
|
|
|
@ -770,8 +770,8 @@ EOF;
|
|||
include $this->vendorDir.'/composer/autoload_classmap.php'
|
||||
);
|
||||
$this->assertAutoloadFiles('classmap5', $this->vendorDir.'/composer', 'classmap');
|
||||
$this->assertNotContains('$loader->setClassMapAuthoritative(true);', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertNotContains('$loader->setApcuPrefix(', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringNotContainsString('$loader->setClassMapAuthoritative(true);', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringNotContainsString('$loader->setApcuPrefix(', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
}
|
||||
|
||||
public function testClassMapAutoloadingAuthoritativeAndApcu()
|
||||
|
@ -819,8 +819,8 @@ EOF;
|
|||
);
|
||||
$this->assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap');
|
||||
|
||||
$this->assertContains('$loader->setClassMapAuthoritative(true);', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertContains('$loader->setApcuPrefix(', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringContainsString('$loader->setClassMapAuthoritative(true);', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringContainsString('$loader->setApcuPrefix(', file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
}
|
||||
|
||||
public function testFilesAutoloadGeneration()
|
||||
|
@ -1380,8 +1380,8 @@ EOF;
|
|||
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
|
||||
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
|
||||
$this->assertStringEqualsFile($vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
|
||||
$this->assertContains("\$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertContains("\$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertStringContainsString("\$vendorDir . '/b/b/bootstrap.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertStringContainsString("\$baseDir . '/test.php',\n", file_get_contents($vendorDir.'/composer/autoload_files.php'));
|
||||
}
|
||||
|
||||
public function testUpLevelRelativePaths()
|
||||
|
@ -1459,7 +1459,7 @@ EOF;
|
|||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_namespaces.php', $expectedNamespace);
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_psr4.php', $expectedPsr4);
|
||||
$this->assertStringEqualsFile($this->vendorDir.'/composer/autoload_classmap.php', $expectedClassmap);
|
||||
$this->assertContains("\$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
|
||||
$this->assertStringContainsString("\$baseDir . '/../test.php',\n", file_get_contents($this->vendorDir.'/composer/autoload_files.php'));
|
||||
}
|
||||
|
||||
public function testEmptyPaths()
|
||||
|
@ -1671,10 +1671,10 @@ EOF;
|
|||
|
||||
if (null === $expectedFixture) {
|
||||
$this->assertFalse(file_exists($this->vendorDir . '/composer/platform_check.php'));
|
||||
$this->assertNotContains("require __DIR__ . '/platform_check.php';", file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringNotContainsString("require __DIR__ . '/platform_check.php';", file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
} else {
|
||||
$this->assertFileContentEquals(__DIR__ . '/Fixtures/platform/' . $expectedFixture . '.php', $this->vendorDir . '/composer/platform_check.php');
|
||||
$this->assertContains("require __DIR__ . '/platform_check.php';", file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
$this->assertStringContainsString("require __DIR__ . '/platform_check.php';", file_get_contents($this->vendorDir.'/composer/autoload_real.php'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,16 +120,13 @@ class ClassMapGeneratorTest extends TestCase
|
|||
), ClassMapGenerator::createMap($finder));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage does not exist
|
||||
*/
|
||||
public function testFindClassesThrowsWhenFileDoesNotExist()
|
||||
{
|
||||
$r = new \ReflectionClass('Composer\\Autoload\\ClassMapGenerator');
|
||||
$find = $r->getMethod('findClasses');
|
||||
$find->setAccessible(true);
|
||||
|
||||
$this->setExpectedException('RuntimeException', 'does not exist');
|
||||
$find->invoke(null, __DIR__ . '/no-file');
|
||||
}
|
||||
|
||||
|
@ -213,12 +210,9 @@ class ClassMapGeneratorTest extends TestCase
|
|||
$fs->removeDirectory($tempDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Could not scan for classes inside
|
||||
*/
|
||||
public function testCreateMapThrowsWhenDirectoryDoesNotExist()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'Could not scan for classes inside');
|
||||
ClassMapGenerator::createMap(__DIR__ . '/no-file.no-foler');
|
||||
}
|
||||
|
||||
|
|
|
@ -63,13 +63,11 @@ class RuleSetTest extends TestCase
|
|||
$this->assertCount(1, $ruleSet->getIteratorFor(array(RuleSet::TYPE_REQUEST)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OutOfBoundsException
|
||||
*/
|
||||
public function testAddWhenTypeIsNotRecognized()
|
||||
{
|
||||
$ruleSet = new RuleSet;
|
||||
|
||||
$this->setExpectedException('OutOfBoundsException');
|
||||
$ruleSet->add(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, null), 7);
|
||||
}
|
||||
|
||||
|
@ -152,6 +150,6 @@ class RuleSetTest extends TestCase
|
|||
|
||||
$ruleSet->add($rule, RuleSet::TYPE_REQUEST);
|
||||
|
||||
$this->assertContains('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($repositorySetMock, $requestMock, $pool));
|
||||
$this->assertStringContainsString('REQUEST : No package found to satisfy root composer.json require foo/bar', $ruleSet->getPrettyString($repositorySetMock, $requestMock, $pool));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,6 @@ class FileDownloaderTest extends TestCase
|
|||
return new FileDownloader($io, $this->config, $httpDownloader, $eventDispatcher, $cache, $filesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDownloadForPackageWithoutDistReference()
|
||||
{
|
||||
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -48,6 +45,8 @@ class FileDownloaderTest extends TestCase
|
|||
->will($this->returnValue(null))
|
||||
;
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloader();
|
||||
$downloader->download($packageMock, '/path');
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ class FileDownloaderTest extends TestCase
|
|||
unlink($path);
|
||||
}
|
||||
$this->assertInstanceOf('RuntimeException', $e);
|
||||
$this->assertContains('exists and is not a directory', $e->getMessage());
|
||||
$this->assertStringContainsString('exists and is not a directory', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +152,7 @@ class FileDownloaderTest extends TestCase
|
|||
}
|
||||
|
||||
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
|
||||
$this->assertContains('could not be saved to', $e->getMessage());
|
||||
$this->assertStringContainsString('could not be saved to', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +238,7 @@ class FileDownloaderTest extends TestCase
|
|||
}
|
||||
|
||||
$this->assertInstanceOf('UnexpectedValueException', $e, $e->getMessage());
|
||||
$this->assertContains('checksum verification', $e->getMessage());
|
||||
$this->assertStringContainsString('checksum verification', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,6 @@ class FossilDownloaderTest extends TestCase
|
|||
return new FossilDownloader($io, $config, $executor, $filesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testInstallForPackageWithoutSourceReference()
|
||||
{
|
||||
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -55,6 +52,8 @@ class FossilDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->install($packageMock, '/path');
|
||||
}
|
||||
|
@ -92,9 +91,6 @@ class FossilDownloaderTest extends TestCase
|
|||
$downloader->install($packageMock, 'repo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUpdateforPackageWithoutSourceReference()
|
||||
{
|
||||
$initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -103,6 +99,8 @@ class FossilDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->prepare('update', $sourcePackageMock, '/path', $initialPackageMock);
|
||||
$downloader->update($initialPackageMock, $sourcePackageMock, '/path');
|
||||
|
|
|
@ -78,9 +78,6 @@ class GitDownloaderTest extends TestCase
|
|||
return new GitDownloader($io, $config, $executor, $filesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDownloadForPackageWithoutSourceReference()
|
||||
{
|
||||
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -88,6 +85,8 @@ class GitDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->download($packageMock, '/path');
|
||||
$downloader->prepare('install', $packageMock, '/path');
|
||||
|
@ -370,9 +369,6 @@ class GitDownloaderTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUpdateforPackageWithoutSourceReference()
|
||||
{
|
||||
$initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -381,6 +377,8 @@ class GitDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->download($sourcePackageMock, '/path', $initialPackageMock);
|
||||
$downloader->prepare('update', $sourcePackageMock, '/path', $initialPackageMock);
|
||||
|
|
|
@ -45,9 +45,6 @@ class HgDownloaderTest extends TestCase
|
|||
return new HgDownloader($io, $config, $executor, $filesystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDownloadForPackageWithoutSourceReference()
|
||||
{
|
||||
$packageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -55,6 +52,8 @@ class HgDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->install($packageMock, '/path');
|
||||
}
|
||||
|
@ -86,9 +85,6 @@ class HgDownloaderTest extends TestCase
|
|||
$downloader->install($packageMock, 'composerPath');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUpdateforPackageWithoutSourceReference()
|
||||
{
|
||||
$initialPackageMock = $this->getMockBuilder('Composer\Package\PackageInterface')->getMock();
|
||||
|
@ -97,6 +93,8 @@ class HgDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->prepare('update', $sourcePackageMock, '/path', $initialPackageMock);
|
||||
$downloader->update($initialPackageMock, $sourcePackageMock, '/path');
|
||||
|
|
|
@ -96,16 +96,13 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
$this->fail('Download of invalid zip files should throw an exception');
|
||||
} catch (\Exception $e) {
|
||||
$this->assertContains('is not a zip archive', $e->getMessage());
|
||||
$this->assertStringContainsString('is not a zip archive', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage There was an error extracting the ZIP file
|
||||
*/
|
||||
public function testZipArchiveOnlyFailed()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'There was an error extracting the ZIP file');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
@ -126,12 +123,9 @@ class ZipDownloaderTest extends TestCase
|
|||
$this->wait($promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): Not a directory
|
||||
*/
|
||||
public function testZipArchiveExtractOnlyFailed()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): Not a directory');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
@ -174,12 +168,9 @@ class ZipDownloaderTest extends TestCase
|
|||
$this->wait($promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage Failed to extract : (1) unzip
|
||||
*/
|
||||
public function testSystemUnzipOnlyFailed()
|
||||
{
|
||||
$this->setExpectedException('Exception', 'Failed to extract : (1) unzip');
|
||||
$this->setPrivateProperty('isWindows', false);
|
||||
$this->setPrivateProperty('hasSystemUnzip', true);
|
||||
$this->setPrivateProperty('hasZipArchive', false);
|
||||
|
@ -272,12 +263,9 @@ class ZipDownloaderTest extends TestCase
|
|||
$this->wait($promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage There was an error extracting the ZIP file
|
||||
*/
|
||||
public function testNonWindowsFallbackFailed()
|
||||
{
|
||||
$this->setExpectedException('Exception', 'There was an error extracting the ZIP file');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
@ -345,12 +333,9 @@ class ZipDownloaderTest extends TestCase
|
|||
$this->wait($promise);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage Failed to execute (1) unzip
|
||||
*/
|
||||
public function testWindowsFallbackFailed()
|
||||
{
|
||||
$this->setExpectedException('Exception', 'Failed to execute (1) unzip');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
|
|
@ -27,11 +27,10 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
|
||||
class EventDispatcherTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testListenerExceptionsAreCaught()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||
$dispatcher = $this->getDispatcherStubForListenersTest(array(
|
||||
'Composer\Test\EventDispatcher\EventDispatcherTest::call',
|
||||
|
@ -425,11 +424,10 @@ class EventDispatcherTest extends TestCase
|
|||
$this->assertEquals($expected, $io->getOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testDispatcherDetectInfiniteRecursion()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
|
|
|
@ -42,7 +42,7 @@ class NullIOTest extends TestCase
|
|||
{
|
||||
$io = new NullIO();
|
||||
|
||||
$this->assertInternalType('array', $io->getAuthentications());
|
||||
$this->assertTrue(is_array($io->getAuthentications()));
|
||||
$this->assertEmpty($io->getAuthentications());
|
||||
$this->assertEquals(array('username' => null, 'password' => null), $io->getAuthentication('foo'));
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ class JsonFileTest extends TestCase
|
|||
$result = JsonFile::parseJson($json);
|
||||
$this->fail(sprintf("Parsing should have failed but didn't.\nExpected:\n\"%s\"\nFor:\n\"%s\"\nGot:\n\"%s\"", $text, $json, var_export($result, true)));
|
||||
} catch (ParsingException $e) {
|
||||
$this->assertContains($text, $e->getMessage());
|
||||
$this->assertStringContainsString($text, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,10 @@ class BasePackageTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testSetAnotherRepository()
|
||||
{
|
||||
$this->setExpectedException('LogicException');
|
||||
|
||||
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
|
||||
|
||||
$package->setRepository($this->getMockBuilder('Composer\Repository\RepositoryInterface')->getMock());
|
||||
|
|
|
@ -398,10 +398,11 @@ class PluginInstallerTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider invalidImplementationClassNames
|
||||
* @expectedException \UnexpectedValueException
|
||||
*/
|
||||
public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames)
|
||||
public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames, $expect = 'UnexpectedValueException')
|
||||
{
|
||||
$this->setExpectedException($expect);
|
||||
|
||||
$capabilityApi = 'Composer\Plugin\Capability\Capability';
|
||||
|
||||
$plugin = $this->getMockBuilder('Composer\Test\Plugin\Mock\CapablePluginInterface')
|
||||
|
@ -434,10 +435,9 @@ class PluginInstallerTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider nonExistingOrInvalidImplementationClassTypes
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testQueryingWithNonExistingOrWrongCapabilityClassTypesThrows($wrongImplementationClassTypes)
|
||||
{
|
||||
$this->testQueryingWithInvalidCapabilityClassNameThrows($wrongImplementationClassTypes);
|
||||
$this->testQueryingWithInvalidCapabilityClassNameThrows($wrongImplementationClassTypes, 'RuntimeException');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,762 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Test {
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\Constraint\IsEqual;
|
||||
use PHPUnit\Framework\Constraint\LogicalNot;
|
||||
use PHPUnit\Framework\Constraint\RegularExpression;
|
||||
use PHPUnit\Framework\Constraint\StringContains;
|
||||
use PHPUnit\Framework\Constraint\TraversableContains;
|
||||
|
||||
if (method_exists('PHPUnit\Framework\TestCase', 'assertStringContainsString')) {
|
||||
abstract class PolyfillTestCase extends TestCase {}
|
||||
} else {
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertIsNotReadable($filename, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertIsNotWritable($filename, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertDirectoryDoesNotExist($directory, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertDirectoryIsNotReadable($directory, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertDirectoryIsNotWritable($directory, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertFileDoesNotExist($filename, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertFileIsNotReadable($filename, $message = '')
|
||||
{
|
||||
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
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertFileIsNotWritable($filename, $message = '')
|
||||
{
|
||||
static::assertFileNotIsWritable($filename, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertMatchesRegularExpression($pattern, $string, $message = '')
|
||||
{
|
||||
static::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
* @param string $string
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertDoesNotMatchRegularExpression($pattern, $string, $message = '')
|
||||
{
|
||||
static::assertNotRegExp($pattern, $string, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 Countable;
|
||||
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
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,14 +38,14 @@ class StrictConfirmationQuestionTest extends TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedExceptionMessage Please answer yes, y, no, or n.
|
||||
* @dataProvider getAskConfirmationBadData
|
||||
*/
|
||||
public function testAskConfirmationBadAnswer($answer)
|
||||
{
|
||||
list($input, $dialog) = $this->createInput($answer."\n");
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'Please answer yes, y, no, or n.');
|
||||
|
||||
$question = new StrictConfirmationQuestion('Do you like French fries?');
|
||||
$question->setMaxAttempts(1);
|
||||
$dialog->ask($input, $this->createOutputInterface(), $question);
|
||||
|
|
|
@ -43,11 +43,9 @@ class FilesystemRepositoryTest extends TestCase
|
|||
$this->assertSame('vendor', $packages[0]->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Composer\Repository\InvalidRepositoryException
|
||||
*/
|
||||
public function testCorruptedRepositoryFile()
|
||||
{
|
||||
$this->setExpectedException('Composer\Repository\InvalidRepositoryException');
|
||||
$json = $this->createJsonFileMock();
|
||||
|
||||
$repository = new FilesystemRepository($json);
|
||||
|
|
|
@ -19,12 +19,9 @@ use Composer\Package\Version\VersionParser;
|
|||
|
||||
class PathRepositoryTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testLoadPackageFromFileSystemWithIncorrectPath()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
|
|
|
@ -40,11 +40,10 @@ class SvnDriverTest extends TestCase
|
|||
$fs->removeDirectory($this->home);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testWrongCredentialsInUrl()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$console = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||
$httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
|
||||
|
||||
|
|
|
@ -19,12 +19,11 @@ use Composer\Package\PackageInterface;
|
|||
use Composer\Semver\Constraint\Constraint;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Util\Silencer;
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
use Composer\Package\Loader\ArrayLoader;
|
||||
use Composer\Package\BasePackage;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
abstract class TestCase extends PolyfillTestCase
|
||||
{
|
||||
private static $parser;
|
||||
private static $executableCache = array();
|
||||
|
|
|
@ -472,11 +472,10 @@ class AuthHelperTest extends TestCase
|
|||
$this->authHelper->storeAuth($origin, $storeAuth);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testStoreAuthWithPromptInvalidAnswer()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$origin = 'github.com';
|
||||
$storeAuth = 'prompt';
|
||||
$answer = 'invalid';
|
||||
|
|
|
@ -261,11 +261,9 @@ class BitbucketTest extends TestCase
|
|||
$this->assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Composer\Downloader\TransportException
|
||||
*/
|
||||
public function testRequestAccessTokenWithUsernameAndPasswordWithNotFoundResponse()
|
||||
{
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
$this->config->expects($this->once())
|
||||
->method('get')
|
||||
->with('bitbucket-oauth')
|
||||
|
|
|
@ -72,12 +72,9 @@ class GitLabTest extends TestCase
|
|||
$this->assertTrue($gitLab->authorizeOAuthInteractively('http', $this->origin, $this->message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Invalid GitLab credentials 5 times in a row, aborting.
|
||||
*/
|
||||
public function testUsernamePasswordFailure()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'Invalid GitLab credentials 5 times in a row, aborting.');
|
||||
$io = $this->getIOMock();
|
||||
$io
|
||||
->expects($this->exactly(5))
|
||||
|
|
|
@ -62,11 +62,10 @@ class GitTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testRunCommandPrivateGitHubRepositoryNotInitialCloneNotInteractiveWithoutAuthentication()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$that = $this;
|
||||
$commandCallable = function ($url) use ($that) {
|
||||
$that->assertSame('https://github.com/acme/repo', $url);
|
||||
|
|
|
@ -30,7 +30,7 @@ class IniHelperTest extends TestCase
|
|||
);
|
||||
|
||||
$this->setEnv($paths);
|
||||
$this->assertContains('does not exist', IniHelper::getMessage());
|
||||
$this->assertStringContainsString('does not exist', IniHelper::getMessage());
|
||||
$this->assertEquals($paths, IniHelper::getAll());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class IniHelperTest extends TestCase
|
|||
);
|
||||
|
||||
$this->setEnv($paths);
|
||||
$this->assertContains('loaded.ini', IniHelper::getMessage());
|
||||
$this->assertStringContainsString('loaded.ini', IniHelper::getMessage());
|
||||
}
|
||||
|
||||
public function testWithLoadedIniAndAdditional()
|
||||
|
@ -53,7 +53,7 @@ class IniHelperTest extends TestCase
|
|||
);
|
||||
|
||||
$this->setEnv($paths);
|
||||
$this->assertContains('multiple ini files', IniHelper::getMessage());
|
||||
$this->assertStringContainsString('multiple ini files', IniHelper::getMessage());
|
||||
$this->assertEquals($paths, IniHelper::getAll());
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class IniHelperTest extends TestCase
|
|||
);
|
||||
|
||||
$this->setEnv($paths);
|
||||
$this->assertContains('multiple ini files', IniHelper::getMessage());
|
||||
$this->assertStringContainsString('multiple ini files', IniHelper::getMessage());
|
||||
$this->assertEquals($paths, IniHelper::getAll());
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class RemoteFilesystemTest extends TestCase
|
|||
{
|
||||
$fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock());
|
||||
$this->callCallbackGet($fs, STREAM_NOTIFY_FILE_SIZE_IS, 0, '', 0, 0, 20);
|
||||
$this->assertAttributeEquals(20, 'bytesMax', $fs);
|
||||
$this->assertAttributeEqualsCustom(20, 'bytesMax', $fs);
|
||||
}
|
||||
|
||||
public function testCallbackGetNotifyProgress()
|
||||
|
@ -138,7 +138,7 @@ class RemoteFilesystemTest extends TestCase
|
|||
$this->setAttribute($fs, 'progress', true);
|
||||
|
||||
$this->callCallbackGet($fs, STREAM_NOTIFY_PROGRESS, 0, '', 0, 10, 20);
|
||||
$this->assertAttributeEquals(50, 'lastProgress', $fs);
|
||||
$this->assertAttributeEqualsCustom(50.0, 'lastProgress', $fs);
|
||||
}
|
||||
|
||||
public function testCallbackGetPassesThrough404()
|
||||
|
@ -152,7 +152,7 @@ class RemoteFilesystemTest extends TestCase
|
|||
{
|
||||
$fs = new RemoteFilesystem($this->getIOInterfaceMock(), $this->getConfigMock());
|
||||
|
||||
$this->assertContains('testGetContents', $fs->getContents('http://example.org', 'file://'.__FILE__));
|
||||
$this->assertStringContainsString('testGetContents', $fs->getContents('http://example.org', 'file://'.__FILE__));
|
||||
}
|
||||
|
||||
public function testCopy()
|
||||
|
@ -162,15 +162,13 @@ class RemoteFilesystemTest extends TestCase
|
|||
$file = tempnam(sys_get_temp_dir(), 'c');
|
||||
$this->assertTrue($fs->copy('http://example.org', 'file://'.__FILE__, $file));
|
||||
$this->assertFileExists($file);
|
||||
$this->assertContains('testCopy', file_get_contents($file));
|
||||
$this->assertStringContainsString('testCopy', file_get_contents($file));
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Composer\Downloader\TransportException
|
||||
*/
|
||||
public function testCopyWithNoRetryOnFailure()
|
||||
{
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
$fs = $this->getRemoteFilesystemWithMockedMethods(array('getRemoteContents'));
|
||||
|
||||
$fs->expects($this->once())->method('getRemoteContents')
|
||||
|
@ -240,7 +238,7 @@ class RemoteFilesystemTest extends TestCase
|
|||
|
||||
$this->assertTrue($copyResult);
|
||||
$this->assertFileExists($file);
|
||||
$this->assertContains('Copied', file_get_contents($file));
|
||||
$this->assertStringContainsString('Copied', file_get_contents($file));
|
||||
|
||||
unlink($file);
|
||||
}
|
||||
|
@ -394,6 +392,13 @@ class RemoteFilesystemTest extends TestCase
|
|||
$attr->setValue($object, $value);
|
||||
}
|
||||
|
||||
private function assertAttributeEqualsCustom($value, $attribute, $object)
|
||||
{
|
||||
$attr = new ReflectionProperty($object, $attribute);
|
||||
$attr->setAccessible(true);
|
||||
$this->assertSame($value, $attr->getValue($object));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockObject|IOInterface
|
||||
*/
|
||||
|
|
|
@ -33,19 +33,15 @@ class TarTest extends TestCase
|
|||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsExceptionIfTheTarHasNoComposerJson()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/nojson.tar.gz');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsExceptionIfTheComposerJsonIsInASubSubfolder()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/subfolders.tar.gz');
|
||||
}
|
||||
|
||||
|
@ -61,11 +57,9 @@ class TarTest extends TestCase
|
|||
$this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testMultipleTopLevelDirsIsInvalid()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/multiple.tar.gz');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,9 +55,6 @@ class ZipTest extends TestCase
|
|||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsExceptionIfTheZipHasNoComposerJson()
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
|
@ -65,12 +62,11 @@ class ZipTest extends TestCase
|
|||
return;
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'No composer.json found either at the top level or within the topmost directory');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/nojson.zip');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsExceptionIfTheComposerJsonIsInASubSubfolder()
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
|
@ -78,6 +74,8 @@ class ZipTest extends TestCase
|
|||
return;
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'No composer.json found either at the top level or within the topmost directory');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/subfolders.zip');
|
||||
}
|
||||
|
||||
|
@ -104,9 +102,6 @@ class ZipTest extends TestCase
|
|||
$this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testMultipleTopLevelDirsIsInvalid()
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
|
@ -114,6 +109,8 @@ class ZipTest extends TestCase
|
|||
return;
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: folder1/,folder2/');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/multiple.zip');
|
||||
}
|
||||
|
||||
|
@ -129,9 +126,6 @@ class ZipTest extends TestCase
|
|||
$this->assertEquals("{\n \"name\": \"foo/bar\"\n}\n", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testThrowsExceptionIfMultipleComposerInSubFoldersWereFound()
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
|
@ -139,6 +133,8 @@ class ZipTest extends TestCase
|
|||
return;
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'Archive has more than one top level directories, and no composer.json was found on the top level, so it\'s an invalid archive. Top level paths found were: foo3/,__MACOSX/');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/multiple_subfolders.zip');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue