From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sat, 4 May 2019 13:53:58 -1000
Subject: Use expectException instead of setExpectedException

---
 tests/Composer/Test/Command/InitCommandTest.php              |  4 ++--
 tests/Composer/Test/ConfigTest.php                           |  2 +-
 tests/Composer/Test/DependencyResolver/SolverTest.php        |  6 +++---
 tests/Composer/Test/Downloader/DownloadManagerTest.php       | 12 ++++++------
 tests/Composer/Test/EventDispatcher/EventDispatcherTest.php  |  2 +-
 tests/Composer/Test/Installer/InstallationManagerTest.php    |  2 +-
 tests/Composer/Test/Installer/LibraryInstallerTest.php       |  4 ++--
 tests/Composer/Test/Installer/MetapackageInstallerTest.php   |  4 ++--
 tests/Composer/Test/InstallerTest.php                        |  2 +-
 tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php  |  2 +-
 tests/Composer/Test/Package/LockerTest.php                   |  4 ++--
 tests/Composer/Test/Repository/RepositoryManagerTest.php     |  2 +-
 .../Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php  |  2 +-
 tests/Composer/Test/Util/ErrorHandlerTest.php                |  8 ++++----
 tests/Composer/Test/Util/FilesystemTest.php                  |  2 +-
 tests/Composer/Test/Util/SilencerTest.php                    |  2 +-
 16 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php
index d1c3b62..32b91d3 100644
--- a/tests/Composer/Test/Command/InitCommandTest.php
+++ b/tests/Composer/Test/Command/InitCommandTest.php
@@ -82,14 +82,14 @@ class InitCommandTest extends TestCase
     public function testParseEmptyAuthorString()
     {
         $command = new InitCommand;
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
         $command->parseAuthorString('');
     }
 
     public function testParseAuthorStringWithInvalidEmail()
     {
         $command = new InitCommand;
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
         $command->parseAuthorString('John Smith <john>');
     }
 }
diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php
index 4a4bf01..52fb026 100644
--- a/tests/Composer/Test/ConfigTest.php
+++ b/tests/Composer/Test/ConfigTest.php
@@ -238,7 +238,7 @@ class ConfigTest extends TestCase
      */
     public function testProhibitedUrlsThrowException($url)
     {
-        $this->setExpectedException(
+        $this->expectException(
             'Composer\Downloader\TransportException',
             'Your configuration does not allow connections to ' . $url
         );
diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php
index cf916fb..24cde47 100644
--- a/tests/Composer/Test/DependencyResolver/SolverTest.php
+++ b/tests/Composer/Test/DependencyResolver/SolverTest.php
@@ -415,7 +415,7 @@ class SolverTest extends TestCase
         $this->request->requireName('A');
 
         // must explicitly pick the provider, so error in this case
-        $this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
+        $this->expectException('Composer\DependencyResolver\SolverProblemsException');
         $this->createSolver();
         $this->solver->solve($this->request);
     }
@@ -449,7 +449,7 @@ class SolverTest extends TestCase
 
         $this->request->requireName('A');
 
-        $this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
+        $this->expectException('Composer\DependencyResolver\SolverProblemsException');
         $this->createSolver();
         $this->solver->solve($this->request);
     }
@@ -621,7 +621,7 @@ class SolverTest extends TestCase
 
         $this->request->requireName('C', $this->getVersionConstraint('==', '2.0.0.0-dev'));
 
-        $this->setExpectedException('Composer\DependencyResolver\SolverProblemsException');
+        $this->expectException('Composer\DependencyResolver\SolverProblemsException');
 
         $this->createSolver();
         $this->solver->solve($this->request);
diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php
index 4253882..b755e33 100644
--- a/tests/Composer/Test/Downloader/DownloadManagerTest.php
+++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php
@@ -34,7 +34,7 @@ class DownloadManagerTest extends TestCase
         $manager->setDownloader('test', $downloader);
         $this->assertSame($downloader, $manager->getDownloader('test'));
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
         $manager->getDownloader('unregistered');
     }
 
@@ -48,7 +48,7 @@ class DownloadManagerTest extends TestCase
 
         $manager = new DownloadManager($this->io, false, $this->filesystem);
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
 
         $manager->getDownloaderForPackage($package);
     }
@@ -114,7 +114,7 @@ class DownloadManagerTest extends TestCase
             ->with('git')
             ->will($this->returnValue($downloader));
 
-        $this->setExpectedException('LogicException');
+        $this->expectException('LogicException');
 
         $manager->getDownloaderForPackage($package);
     }
@@ -180,7 +180,7 @@ class DownloadManagerTest extends TestCase
             ->with('pear')
             ->will($this->returnValue($downloader));
 
-        $this->setExpectedException('LogicException');
+        $this->expectException('LogicException');
 
         $manager->getDownloaderForPackage($package);
     }
@@ -304,7 +304,7 @@ class DownloadManagerTest extends TestCase
 
         $manager = new DownloadManager($this->io, false, $this->filesystem);
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->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');
+        $this->expectException('InvalidArgumentException');
         $manager->download($package, 'target_dir');
     }
 
diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
index bbf3e6b..54934a0 100644
--- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
+++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
@@ -543,7 +543,7 @@ class EventDispatcherTest extends TestCase
             ->method('writeError')
             ->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with error code 1</error>'));
 
-        $this->setExpectedException('RuntimeException');
+        $this->expectException('RuntimeException');
         $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
     }
 
diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php
index c7256fe..692aa1d 100644
--- a/tests/Composer/Test/Installer/InstallationManagerTest.php
+++ b/tests/Composer/Test/Installer/InstallationManagerTest.php
@@ -48,7 +48,7 @@ class InstallationManagerTest extends TestCase
         $manager->addInstaller($installer);
         $this->assertSame($installer, $manager->getInstaller('vendor'));
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
         $manager->getInstaller('unregistered');
     }
 
diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php
index 4bf81ea..f0f509d 100644
--- a/tests/Composer/Test/Installer/LibraryInstallerTest.php
+++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php
@@ -187,7 +187,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');
+        $this->expectException('InvalidArgumentException');
 
         $library->update($this->repository, $initial, $target);
     }
@@ -220,7 +220,7 @@ class LibraryInstallerTest extends TestCase
 
         $library->uninstall($this->repository, $package);
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
 
         $library->uninstall($this->repository, $package);
     }
diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php
index 481de79..f26ba0b 100644
--- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php
+++ b/tests/Composer/Test/Installer/MetapackageInstallerTest.php
@@ -71,7 +71,7 @@ class MetapackageInstallerTest extends TestCase
 
         $this->installer->update($this->repository, $initial, $target);
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
 
         $this->installer->update($this->repository, $initial, $target);
     }
@@ -93,7 +93,7 @@ class MetapackageInstallerTest extends TestCase
 
         $this->installer->uninstall($this->repository, $package);
 
-        $this->setExpectedException('InvalidArgumentException');
+        $this->expectException('InvalidArgumentException');
 
         $this->installer->uninstall($this->repository, $package);
     }
diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php
index 0d503a4..4ac3e5c 100644
--- a/tests/Composer/Test/InstallerTest.php
+++ b/tests/Composer/Test/InstallerTest.php
@@ -211,7 +211,7 @@ class InstallerTest extends TestCase
         // Prepare for exceptions
         if (!is_int($expectResult)) {
             $normalizedOutput = rtrim(str_replace("\n", PHP_EOL, $expect));
-            $this->setExpectedException($expectResult, $normalizedOutput);
+            $this->expectException($expectResult, $normalizedOutput);
         }
 
         // Create Composer mock object according to configuration
diff --git a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php
index 2c99ac6..4bdac61 100644
--- a/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php
+++ b/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php
@@ -47,7 +47,7 @@ class ArchiveManagerTest extends ArchiverTest
 
     public function testUnknownFormat()
     {
-        $this->setExpectedException('RuntimeException');
+        $this->expectException('RuntimeException');
 
         $package = $this->setupPackage();
 
diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php
index 29f3e7c..15205e1 100644
--- a/tests/Composer/Test/Package/LockerTest.php
+++ b/tests/Composer/Test/Package/LockerTest.php
@@ -53,7 +53,7 @@ class LockerTest extends TestCase
             ->method('exists')
             ->will($this->returnValue(false));
 
-        $this->setExpectedException('LogicException');
+        $this->expectException('LogicException');
 
         $locker->getLockedRepository();
     }
@@ -170,7 +170,7 @@ class LockerTest extends TestCase
             ->method('getPrettyName')
             ->will($this->returnValue('pkg1'));
 
-        $this->setExpectedException('LogicException');
+        $this->expectException('LogicException');
 
         $locker->setLockData(array($package1), array(), array(), array(), array(), 'dev', array(), false, false, array());
     }
diff --git a/tests/Composer/Test/Repository/RepositoryManagerTest.php b/tests/Composer/Test/Repository/RepositoryManagerTest.php
index 1d59b63..7d545df 100644
--- a/tests/Composer/Test/Repository/RepositoryManagerTest.php
+++ b/tests/Composer/Test/Repository/RepositoryManagerTest.php
@@ -56,7 +56,7 @@ class RepositoryManagerTest extends TestCase
     public function testRepoCreation($type, $options, $exception = null)
     {
         if ($exception) {
-            $this->setExpectedException($exception);
+            $this->expectException($exception);
         }
 
         $rm = new RepositoryManager(
diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php
index 2dae0ab..0bad336 100644
--- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php
+++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php
@@ -80,7 +80,7 @@ class GitBitbucketDriverTest extends TestCase
 
     public function testGetRootIdentifierWrongScmType()
     {
-        $this->setExpectedException(
+        $this->expectException(
             '\RuntimeException',
             'https://bitbucket.org/user/repo.git does not appear to be a git repository, use https://bitbucket.org/user/repo if this is a mercurial bitbucket repository'
         );
diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php
index c7651b8..486aa1c 100644
--- a/tests/Composer/Test/Util/ErrorHandlerTest.php
+++ b/tests/Composer/Test/Util/ErrorHandlerTest.php
@@ -36,9 +36,9 @@ class ErrorHandlerTest extends TestCase
     public function testErrorHandlerCaptureNotice()
     {
         if (PHP_VERSION_ID >= 80000) {
-            $this->setExpectedException('\ErrorException', 'Undefined array key "baz"');
+            $this->expectException('\ErrorException', 'Undefined array key "baz"');
         } else {
-            $this->setExpectedException('\ErrorException', 'Undefined index: baz');
+            $this->expectException('\ErrorException', 'Undefined index: baz');
         }
 
         $array = array('foo' => 'bar');
@@ -51,9 +51,9 @@ class ErrorHandlerTest extends TestCase
     public function testErrorHandlerCaptureWarning()
     {
         if (PHP_VERSION_ID >= 80000) {
-            $this->setExpectedException('TypeError', 'array_merge');
+            $this->expectException('TypeError', 'array_merge');
         } else {
-            $this->setExpectedException('ErrorException', 'array_merge');
+            $this->expectException('ErrorException', 'array_merge');
         }
 
         array_merge(array(), 'string');
diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php
index 0fb4bab..d821c05 100644
--- a/tests/Composer/Test/Util/FilesystemTest.php
+++ b/tests/Composer/Test/Util/FilesystemTest.php
@@ -292,7 +292,7 @@ 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');
+            $this->expectException('LogicException', 'not available on non-Windows platform');
         }
 
         $target = $this->workingDir . '/real/../real/nesting';
diff --git a/tests/Composer/Test/Util/SilencerTest.php b/tests/Composer/Test/Util/SilencerTest.php
index 6e93c3c..3f929b4 100644
--- a/tests/Composer/Test/Util/SilencerTest.php
+++ b/tests/Composer/Test/Util/SilencerTest.php
@@ -52,7 +52,7 @@ class SilencerTest extends TestCase
     public function testSilencedException()
     {
         $verification = microtime();
-        $this->setExpectedException('\RuntimeException', $verification);
+        $this->expectException('\RuntimeException', $verification);
         Silencer::call(function () use ($verification) {
             throw new \RuntimeException($verification);
         });
