Remove setExpectedException wrapper
parent
32dcb93f24
commit
6ed3aeb343
|
@ -146,7 +146,8 @@ class ClassMapGeneratorTest extends TestCase
|
|||
$find = $r->getMethod('findClasses');
|
||||
$find->setAccessible(true);
|
||||
|
||||
$this->setExpectedException('RuntimeException', 'does not exist');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('does not exist');
|
||||
$find->invoke(null, __DIR__ . '/no-file');
|
||||
}
|
||||
|
||||
|
@ -232,7 +233,8 @@ class ClassMapGeneratorTest extends TestCase
|
|||
|
||||
public function testCreateMapThrowsWhenDirectoryDoesNotExist()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'Could not scan for classes inside');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('Could not scan for classes inside');
|
||||
ClassMapGenerator::createMap(__DIR__ . '/no-file.no-foler');
|
||||
}
|
||||
|
||||
|
|
|
@ -82,14 +82,14 @@ class InitCommandTest extends TestCase
|
|||
public function testParseEmptyAuthorString()
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$command->parseAuthorString('');
|
||||
}
|
||||
|
||||
public function testParseAuthorStringWithInvalidEmail()
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$command->parseAuthorString('John Smith <john>');
|
||||
}
|
||||
|
||||
|
|
|
@ -259,10 +259,8 @@ class ConfigTest extends TestCase
|
|||
*/
|
||||
public function testProhibitedUrlsThrowException($url)
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'Composer\Downloader\TransportException',
|
||||
'Your configuration does not allow connections to ' . $url
|
||||
);
|
||||
self::expectException('Composer\Downloader\TransportException');
|
||||
self::expectExceptionMessage('Your configuration does not allow connections to ' . $url);
|
||||
$config = new Config(false);
|
||||
$config->prohibitUrlByConfig($url);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class RuleSetTest extends TestCase
|
|||
{
|
||||
$ruleSet = new RuleSet;
|
||||
|
||||
$this->setExpectedException('OutOfBoundsException');
|
||||
self::expectException('OutOfBoundsException');
|
||||
// @phpstan-ignore-next-line
|
||||
$ruleSet->add(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => '', 'constraint' => new MatchAllConstraint)), 7);
|
||||
}
|
||||
|
|
|
@ -537,7 +537,7 @@ class SolverTest extends TestCase
|
|||
$this->request->requireName('A');
|
||||
|
||||
// must explicitly pick the provider, so error in this case
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
self::expectException('Composer\DependencyResolver\SolverProblemsException');
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->request->requireName('A');
|
||||
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
self::expectException('Composer\DependencyResolver\SolverProblemsException');
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
}
|
||||
|
@ -743,7 +743,7 @@ class SolverTest extends TestCase
|
|||
|
||||
$this->request->requireName('C', $this->getVersionConstraint('==', '2.0.0.0-dev'));
|
||||
|
||||
$this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
|
||||
self::expectException('Composer\DependencyResolver\SolverProblemsException');
|
||||
|
||||
$this->createSolver();
|
||||
$this->solver->solve($this->request);
|
||||
|
|
|
@ -37,7 +37,7 @@ class DownloadManagerTest extends TestCase
|
|||
$manager->setDownloader('test', $downloader);
|
||||
$this->assertSame($downloader, $manager->getDownloader('test'));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$manager->getDownloader('unregistered');
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class DownloadManagerTest extends TestCase
|
|||
|
||||
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$manager->getDownloaderForPackage($package);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class DownloadManagerTest extends TestCase
|
|||
->with('git')
|
||||
->will($this->returnValue($downloader));
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
$manager->getDownloaderForPackage($package);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class DownloadManagerTest extends TestCase
|
|||
->with('pear')
|
||||
->will($this->returnValue($downloader));
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
$manager->getDownloaderForPackage($package);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ class DownloadManagerTest extends TestCase
|
|||
|
||||
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
|
@ -536,7 +536,7 @@ class DownloadManagerTest extends TestCase
|
|||
$manager = new DownloadManager($this->io, false, $this->filesystem);
|
||||
$manager->setPreferSource(true);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$manager->download($package, 'target_dir');
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class FileDownloaderTest extends TestCase
|
|||
->will($this->returnValue(null))
|
||||
;
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloader();
|
||||
$downloader->download($packageMock, '/path');
|
||||
|
|
|
@ -60,7 +60,7 @@ class FossilDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->install($packageMock, '/path');
|
||||
|
@ -95,7 +95,7 @@ class FossilDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->prepare('update', $sourcePackageMock, '/path', $initialPackageMock);
|
||||
|
|
|
@ -100,7 +100,7 @@ class GitDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->download($packageMock, '/path');
|
||||
|
@ -322,7 +322,7 @@ class GitDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->download($sourcePackageMock, '/path', $initialPackageMock);
|
||||
|
|
|
@ -60,7 +60,7 @@ class HgDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->install($packageMock, '/path');
|
||||
|
@ -94,7 +94,7 @@ class HgDownloaderTest extends TestCase
|
|||
->method('getSourceReference')
|
||||
->will($this->returnValue(null));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$downloader = $this->getDownloaderMock();
|
||||
$downloader->prepare('update', $sourcePackageMock, '/path', $initialPackageMock);
|
||||
|
|
|
@ -108,7 +108,8 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
public function testZipArchiveOnlyFailed()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'There was an error extracting the ZIP file');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('There was an error extracting the ZIP file');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
@ -130,7 +131,8 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
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');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('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');
|
||||
}
|
||||
|
@ -173,7 +175,8 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
public function testSystemUnzipOnlyFailed()
|
||||
{
|
||||
$this->setExpectedException('Exception', 'Failed to extract : (1) unzip');
|
||||
self::expectException('Exception');
|
||||
self::expectExceptionMessage('Failed to extract : (1) unzip');
|
||||
$this->setPrivateProperty('isWindows', false);
|
||||
$this->setPrivateProperty('hasZipArchive', false);
|
||||
$this->setPrivateProperty('unzipCommands', array(array('unzip', 'unzip -qq %s -d %s')));
|
||||
|
@ -267,7 +270,8 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
public function testNonWindowsFallbackFailed()
|
||||
{
|
||||
$this->setExpectedException('Exception', 'There was an error extracting the ZIP file');
|
||||
self::expectException('Exception');
|
||||
self::expectExceptionMessage('There was an error extracting the ZIP file');
|
||||
if (!class_exists('ZipArchive')) {
|
||||
$this->markTestSkipped('zip extension missing');
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class EventDispatcherTest extends TestCase
|
|||
{
|
||||
public function testListenerExceptionsAreCaught()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||
$dispatcher = $this->getDispatcherStubForListenersTest(array(
|
||||
|
@ -449,7 +449,7 @@ class EventDispatcherTest extends TestCase
|
|||
|
||||
public function testDispatcherDetectInfiniteRecursion()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
|
@ -569,7 +569,7 @@ class EventDispatcherTest extends TestCase
|
|||
->method('isInteractive')
|
||||
->willReturn(1);
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
$dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ final class PlatformRequirementFilterFactoryTest extends TestCase
|
|||
|
||||
public function testFromBoolThrowsExceptionIfTypeIsUnknown()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException', 'PlatformRequirementFilter: Unknown $boolOrList parameter NULL. Please report at https://github.com/composer/composer/issues/new.');
|
||||
self::expectException('InvalidArgumentException');
|
||||
self::expectExceptionMessage('PlatformRequirementFilter: Unknown $boolOrList parameter NULL. Please report at https://github.com/composer/composer/issues/new.');
|
||||
|
||||
PlatformRequirementFilterFactory::fromBoolOrList(null);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ class BufferIOTest extends TestCase
|
|||
$input = $refl->getValue($bufferIO);
|
||||
|
||||
if (!$input instanceof StreamableInputInterface) {
|
||||
$this->setExpectedException('\RuntimeException', 'Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
|
||||
self::expectException('\RuntimeException');
|
||||
self::expectExceptionMessage('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
|
||||
}
|
||||
|
||||
$bufferIO->setUserInputs(array(
|
||||
|
|
|
@ -200,7 +200,7 @@ class InstalledVersionsTest extends TestCase
|
|||
|
||||
public function testGetVersionOutOfBounds()
|
||||
{
|
||||
$this->setExpectedException('OutOfBoundsException');
|
||||
self::expectException('OutOfBoundsException');
|
||||
InstalledVersions::getVersion('not/installed');
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class InstallationManagerTest extends TestCase
|
|||
$manager->addInstaller($installer);
|
||||
$this->assertSame($installer, $manager->getInstaller('vendor'));
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
$manager->getInstaller('unregistered');
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ class LibraryInstallerTest extends TestCase
|
|||
$this->assertFileExists($this->vendorDir, 'Vendor dir should be created');
|
||||
$this->assertFileExists($this->binDir, 'Bin dir should be created');
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$library->update($this->repository, $initial, $target);
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ class LibraryInstallerTest extends TestCase
|
|||
|
||||
$library->uninstall($this->repository, $package);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$library->uninstall($this->repository, $package);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class MetapackageInstallerTest extends TestCase
|
|||
|
||||
$this->installer->update($this->repository, $initial, $target);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$this->installer->update($this->repository, $initial, $target);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class MetapackageInstallerTest extends TestCase
|
|||
|
||||
$this->installer->uninstall($this->repository, $package);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
self::expectException('InvalidArgumentException');
|
||||
|
||||
$this->installer->uninstall($this->repository, $package);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ class InstallerTest extends TestCase
|
|||
* @param ?mixed[] $expectInstalled
|
||||
* @param ?string $expectOutput
|
||||
* @param string $expect
|
||||
* @param int|string $expectResult
|
||||
* @param int|class-string<\Throwable> $expectResult
|
||||
* @return void
|
||||
*/
|
||||
private function doTestIntegration($file, $message, $condition, $composerConfig, $lock, $installed, $run, $expectLock, $expectInstalled, $expectOutput, $expect, $expectResult)
|
||||
|
@ -319,7 +319,8 @@ class InstallerTest extends TestCase
|
|||
// Prepare for exceptions
|
||||
if (!is_int($expectResult)) {
|
||||
$normalizedOutput = rtrim(str_replace("\n", PHP_EOL, $expect));
|
||||
$this->setExpectedException($expectResult, $normalizedOutput);
|
||||
self::expectException($expectResult);
|
||||
self::expectExceptionMessage($normalizedOutput);
|
||||
}
|
||||
|
||||
// Create Composer mock object according to configuration
|
||||
|
|
|
@ -50,7 +50,7 @@ class ArchiveManagerTest extends ArchiverTest
|
|||
|
||||
public function testUnknownFormat()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
|
||||
$package = $this->setupPackage();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class BasePackageTest extends TestCase
|
|||
|
||||
public function testSetAnotherRepository()
|
||||
{
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class LockerTest extends TestCase
|
|||
->method('exists')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
$locker->getLockedRepository();
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ class LockerTest extends TestCase
|
|||
->method('getPrettyName')
|
||||
->will($this->returnValue('pkg1'));
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
$locker->setLockData(array($package1), array(), array(), array(), array(), 'dev', array(), false, false, array());
|
||||
}
|
||||
|
|
|
@ -432,13 +432,13 @@ class PluginInstallerTest extends TestCase
|
|||
/**
|
||||
* @dataProvider invalidImplementationClassNames
|
||||
* @param callable $invalidImplementationClassNames
|
||||
* @param string $expect
|
||||
* @param class-string<\Throwable> $expect
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQueryingWithInvalidCapabilityClassNameThrows($invalidImplementationClassNames, $expect = 'UnexpectedValueException')
|
||||
{
|
||||
$this->setExpectedException($expect);
|
||||
self::expectException($expect);
|
||||
|
||||
$capabilityApi = 'Composer\Plugin\Capability\Capability';
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ class StrictConfirmationQuestionTest extends TestCase
|
|||
{
|
||||
list($input, $dialog) = $this->createInput($answer."\n");
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'Please answer yes, y, no, or n.');
|
||||
self::expectException('InvalidArgumentException');
|
||||
self::expectExceptionMessage('Please answer yes, y, no, or n.');
|
||||
|
||||
$question = new StrictConfirmationQuestion('Do you like French fries?');
|
||||
$question->setMaxAttempts(1);
|
||||
|
|
|
@ -48,7 +48,7 @@ class FilesystemRepositoryTest extends TestCase
|
|||
|
||||
public function testCorruptedRepositoryFile()
|
||||
{
|
||||
$this->setExpectedException('Composer\Repository\InvalidRepositoryException');
|
||||
self::expectException('Composer\Repository\InvalidRepositoryException');
|
||||
$json = $this->createJsonFileMock();
|
||||
|
||||
$repository = new FilesystemRepository($json);
|
||||
|
|
|
@ -45,7 +45,7 @@ class InstalledRepositoryTest extends TestCase
|
|||
{
|
||||
$arrayRepoOne = new ArrayRepository;
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
self::expectException('LogicException');
|
||||
|
||||
new InstalledRepository(array($arrayRepoOne));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class PathRepositoryTest extends TestCase
|
|||
{
|
||||
public function testLoadPackageFromFileSystemWithIncorrectPath()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
|
||||
->getMock();
|
||||
|
||||
|
|
|
@ -57,12 +57,12 @@ class RepositoryManagerTest extends TestCase
|
|||
*
|
||||
* @param string $type
|
||||
* @param array<string, mixed> $options
|
||||
* @param string|null $exception
|
||||
* @param class-string<\Throwable>|null $exception
|
||||
*/
|
||||
public function testRepoCreation($type, $options, $exception = null)
|
||||
{
|
||||
if ($exception) {
|
||||
$this->setExpectedException($exception);
|
||||
self::expectException($exception);
|
||||
}
|
||||
|
||||
$rm = new RepositoryManager(
|
||||
|
|
|
@ -81,10 +81,8 @@ class GitBitbucketDriverTest extends TestCase
|
|||
|
||||
public function testGetRootIdentifierWrongScmType()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
'\RuntimeException',
|
||||
'https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo but remember that Bitbucket no longer supports the mercurial repositories. https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket'
|
||||
);
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo but remember that Bitbucket no longer supports the mercurial repositories. https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket');
|
||||
|
||||
$this->httpDownloader->expects($this->once())
|
||||
->method('get')
|
||||
|
|
|
@ -49,7 +49,8 @@ class SvnDriverTest extends TestCase
|
|||
|
||||
public function testWrongCredentialsInUrl()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', "Repository https://till:secret@corp.svn.local/repo could not be processed, wrong credentials provided (svn: OPTIONS of 'https://corp.svn.local/repo': authorization failed: Could not authenticate to server: rejected Basic challenge (https://corp.svn.local/))");
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage("Repository https://till:secret@corp.svn.local/repo could not be processed, wrong credentials provided (svn: OPTIONS of 'https://corp.svn.local/repo': authorization failed: Could not authenticate to server: rejected Basic challenge (https://corp.svn.local/))");
|
||||
|
||||
$console = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||
$httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
|
||||
|
|
|
@ -209,27 +209,6 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $exception
|
||||
* @param string|null $message
|
||||
* @param int|null $code
|
||||
* @return void
|
||||
*/
|
||||
public function setExpectedException($exception, $message = null, $code = null)
|
||||
{
|
||||
if (!class_exists('PHPUnit\Framework\Error\Notice')) {
|
||||
$exception = str_replace('PHPUnit\\Framework\\Error\\', 'PHPUnit_Framework_Error_', $exception);
|
||||
}
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException($exception);
|
||||
if (null !== $message) {
|
||||
$this->expectExceptionMessage($message);
|
||||
}
|
||||
} else {
|
||||
parent::setExpectedException($exception, $message, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms an escaped non-Windows command to match Windows escaping.
|
||||
*
|
||||
|
|
|
@ -475,7 +475,7 @@ class AuthHelperTest extends TestCase
|
|||
|
||||
public function testStoreAuthWithPromptInvalidAnswer()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
|
||||
$origin = 'github.com';
|
||||
$storeAuth = 'prompt';
|
||||
|
|
|
@ -270,7 +270,7 @@ class BitbucketTest extends TestCase
|
|||
|
||||
public function testRequestAccessTokenWithUsernameAndPasswordWithNotFoundResponse()
|
||||
{
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
self::expectException('Composer\Downloader\TransportException');
|
||||
$this->config->expects($this->once())
|
||||
->method('get')
|
||||
->with('bitbucket-oauth')
|
||||
|
|
|
@ -37,9 +37,11 @@ class ErrorHandlerTest extends TestCase
|
|||
public function testErrorHandlerCaptureNotice()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->setExpectedException('\ErrorException', 'Undefined array key "baz"');
|
||||
self::expectException('\ErrorException');
|
||||
self::expectExceptionMessage('Undefined array key "baz"');
|
||||
} else {
|
||||
$this->setExpectedException('\ErrorException', 'Undefined index: baz');
|
||||
self::expectException('\ErrorException');
|
||||
self::expectExceptionMessage('Undefined index: baz');
|
||||
}
|
||||
|
||||
$array = array('foo' => 'bar');
|
||||
|
@ -53,9 +55,11 @@ class ErrorHandlerTest extends TestCase
|
|||
public function testErrorHandlerCaptureWarning()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
$this->setExpectedException('TypeError', 'array_merge');
|
||||
self::expectException('TypeError');
|
||||
self::expectExceptionMessage('array_merge');
|
||||
} else {
|
||||
$this->setExpectedException('ErrorException', 'array_merge');
|
||||
self::expectException('ErrorException');
|
||||
self::expectExceptionMessage('array_merge');
|
||||
}
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
|
|
|
@ -308,7 +308,8 @@ class FilesystemTest extends TestCase
|
|||
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$this->assertFalse($fs->isJunction($this->workingDir));
|
||||
$this->assertFalse($fs->removeJunction($this->workingDir));
|
||||
$this->setExpectedException('LogicException', 'not available on non-Windows platform');
|
||||
self::expectException('LogicException');
|
||||
self::expectExceptionMessage('not available on non-Windows platform');
|
||||
}
|
||||
|
||||
$target = $this->workingDir . '/real/../real/nesting';
|
||||
|
|
|
@ -75,7 +75,8 @@ class GitLabTest extends TestCase
|
|||
|
||||
public function testUsernamePasswordFailure()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException', 'Invalid GitLab credentials 5 times in a row, aborting.');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('Invalid GitLab credentials 5 times in a row, aborting.');
|
||||
$io = $this->getIOMock();
|
||||
$io
|
||||
->expects($this->exactly(5))
|
||||
|
|
|
@ -73,7 +73,7 @@ class GitTest extends TestCase
|
|||
|
||||
public function testRunCommandPrivateGitHubRepositoryNotInitialCloneNotInteractiveWithoutAuthentication()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
|
||||
$that = $this;
|
||||
$commandCallable = function ($url) use ($that) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class ProxyHelperTest extends TestCase
|
|||
{
|
||||
$_SERVER['http_proxy'] = $url;
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
ProxyHelper::getProxyData();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class ProxyManagerTest extends TestCase
|
|||
{
|
||||
$_SERVER['http_proxy'] = 'localhost';
|
||||
$proxyManager = ProxyManager::getInstance();
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
self::expectException('Composer\Downloader\TransportException');
|
||||
$proxyManager->getProxyForRequest('http://example.com');
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ class RemoteFilesystemTest extends TestCase
|
|||
|
||||
public function testCopyWithNoRetryOnFailure()
|
||||
{
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
self::expectException('Composer\Downloader\TransportException');
|
||||
$fs = $this->getRemoteFilesystemWithMockedMethods(array('getRemoteContents'));
|
||||
|
||||
$fs->expects($this->once())->method('getRemoteContents')
|
||||
|
|
|
@ -52,7 +52,8 @@ class SilencerTest extends TestCase
|
|||
public function testSilencedException()
|
||||
{
|
||||
$verification = microtime();
|
||||
$this->setExpectedException('\RuntimeException', $verification);
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage($verification);
|
||||
Silencer::call(function () use ($verification) {
|
||||
throw new \RuntimeException($verification);
|
||||
});
|
||||
|
|
|
@ -157,7 +157,7 @@ class StreamContextFactoryTest extends TestCase
|
|||
$_SERVER['https_proxy'] = 'https://woopproxy.net';
|
||||
|
||||
// Pointless test replaced by ProxyHelperTest.php
|
||||
$this->setExpectedException('Composer\Downloader\TransportException');
|
||||
self::expectException('Composer\Downloader\TransportException');
|
||||
$context = StreamContextFactory::getContext('https://example.org', array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo')));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,13 @@ class TarTest extends TestCase
|
|||
|
||||
public function testThrowsExceptionIfTheTarHasNoComposerJson()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/nojson.tar.gz');
|
||||
}
|
||||
|
||||
public function testThrowsExceptionIfTheComposerJsonIsInASubSubfolder()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/subfolders.tar.gz');
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class TarTest extends TestCase
|
|||
|
||||
public function testMultipleTopLevelDirsIsInvalid()
|
||||
{
|
||||
$this->setExpectedException('RuntimeException');
|
||||
self::expectException('RuntimeException');
|
||||
Tar::getComposerJson(__DIR__.'/Fixtures/Tar/multiple.tar.gz');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ class ZipTest extends TestCase
|
|||
$this->markTestSkipped('The PHP zip extension is loaded.');
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'The Zip Util requires PHP\'s zip extension');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('The Zip Util requires PHP\'s zip extension');
|
||||
|
||||
Zip::getComposerJson('');
|
||||
}
|
||||
|
@ -59,7 +60,8 @@ class ZipTest extends TestCase
|
|||
$this->markTestSkipped('The PHP zip extension is not loaded.');
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'No composer.json found either at the top level or within the topmost directory');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('No composer.json found either at the top level or within the topmost directory');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/nojson.zip');
|
||||
}
|
||||
|
@ -70,7 +72,8 @@ class ZipTest extends TestCase
|
|||
$this->markTestSkipped('The PHP zip extension is not loaded.');
|
||||
}
|
||||
|
||||
$this->setExpectedException('\RuntimeException', 'No composer.json found either at the top level or within the topmost directory');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('No composer.json found either at the top level or within the topmost directory');
|
||||
|
||||
Zip::getComposerJson(__DIR__.'/Fixtures/Zip/subfolders.zip');
|
||||
}
|
||||
|
@ -102,7 +105,8 @@ class ZipTest extends TestCase
|
|||
$this->markTestSkipped('The PHP zip extension is not loaded.');
|
||||
}
|
||||
|
||||
$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/');
|
||||
self::expectException('RuntimeException');
|
||||
self::expectExceptionMessage('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');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue