From: =?utf-8?q?David_Pr=C3=A9vot?= <david@tilapin.org>
Date: Tue, 5 Dec 2017 17:59:15 -1000
Subject: Move away from setExpectedException and @expectedException

---
 .../Monolog/Formatter/GelfMessageFormatterTest.php |  2 +-
 .../Monolog/Formatter/NormalizerFormatterTest.php  |  7 ++--
 tests/Monolog/Formatter/WildfireFormatterTest.php  |  2 +-
 tests/Monolog/Handler/AbstractHandlerTest.php      |  4 +-
 tests/Monolog/Handler/ElasticSearchHandlerTest.php |  7 ++--
 tests/Monolog/Handler/ErrorLogHandlerTest.php      |  4 +-
 tests/Monolog/Handler/FilterHandlerTest.php        |  2 +-
 .../Monolog/Handler/FingersCrossedHandlerTest.php  |  2 +-
 tests/Monolog/Handler/GroupHandlerTest.php         |  2 +-
 tests/Monolog/Handler/HipChatHandlerTest.php       |  4 +-
 tests/Monolog/Handler/MongoDBHandlerTest.php       |  4 +-
 tests/Monolog/Handler/NativeMailerHandlerTest.php  | 20 +++-------
 tests/Monolog/Handler/NewRelicHandlerTest.php      |  4 +-
 tests/Monolog/Handler/PHPConsoleHandlerTest.php    |  4 +-
 tests/Monolog/Handler/RedisHandlerTest.php         |  4 +-
 tests/Monolog/Handler/SocketHandlerTest.php        | 44 ++++++----------------
 tests/Monolog/Handler/StreamHandlerTest.php        | 16 ++++----
 tests/Monolog/Handler/SyslogHandlerTest.php        |  2 +-
 tests/Monolog/Handler/SyslogUdpHandlerTest.php     |  4 +-
 tests/Monolog/Handler/UdpSocketTest.php            |  4 +-
 .../Handler/WhatFailureGroupHandlerTest.php        |  2 +-
 tests/Monolog/LoggerTest.php                       | 12 +++---
 tests/Monolog/Processor/WebProcessorTest.php       |  4 +-
 tests/Monolog/RegistryTest.php                     |  8 ++--
 tests/Monolog/UtilsTest.php                        |  2 +-
 25 files changed, 61 insertions(+), 109 deletions(-)

diff --git a/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/tests/Monolog/Formatter/GelfMessageFormatterTest.php
index 0cae9f7..95a9233 100644
--- a/tests/Monolog/Formatter/GelfMessageFormatterTest.php
+++ b/tests/Monolog/Formatter/GelfMessageFormatterTest.php
@@ -82,10 +82,10 @@ class GelfMessageFormatterTest extends \PHPUnit\Framework\TestCase
 
     /**
      * @covers Monolog\Formatter\GelfMessageFormatter::format
-     * @expectedException InvalidArgumentException
      */
     public function testFormatInvalidFails()
     {
+        $this->expectException('InvalidArgumentException');
         $formatter = new GelfMessageFormatter();
         $record = array(
             'level' => Logger::ERROR,
diff --git a/tests/Monolog/Formatter/NormalizerFormatterTest.php b/tests/Monolog/Formatter/NormalizerFormatterTest.php
index a93401d..72c5762 100644
--- a/tests/Monolog/Formatter/NormalizerFormatterTest.php
+++ b/tests/Monolog/Formatter/NormalizerFormatterTest.php
@@ -130,7 +130,8 @@ class NormalizerFormatterTest extends TestCase
     public function testFormatToStringExceptionHandle()
     {
         $formatter = new NormalizerFormatter('Y-m-d');
-        $this->setExpectedException('RuntimeException', 'Could not convert to string');
+        $this->expectException('RuntimeException');
+        $this->expectExceptionMessage('Could not convert to string');
         $formatter->format(array(
             'myObject' => new TestToStringError(),
         ));
@@ -285,11 +286,9 @@ class NormalizerFormatterTest extends TestCase
         $this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']);
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testThrowsOnInvalidEncoding()
     {
+        $this->expectException('RuntimeException');
         if (version_compare(PHP_VERSION, '5.5.0', '<')) {
             // Ignore the warning that will be emitted by PHP <5.5.0
             Warning::$enabled = false;
diff --git a/tests/Monolog/Formatter/WildfireFormatterTest.php b/tests/Monolog/Formatter/WildfireFormatterTest.php
index 0f80b42..cc85df2 100644
--- a/tests/Monolog/Formatter/WildfireFormatterTest.php
+++ b/tests/Monolog/Formatter/WildfireFormatterTest.php
@@ -91,10 +91,10 @@ class WildfireFormatterTest extends \PHPUnit\Framework\TestCase
 
     /**
      * @covers Monolog\Formatter\WildfireFormatter::formatBatch
-     * @expectedException BadMethodCallException
      */
     public function testBatchFormatThrowException()
     {
+        $this->expectException('BadMethodCallException');
         $wildfire = new WildfireFormatter();
         $record = array(
             'level' => Logger::ERROR,
diff --git a/tests/Monolog/Handler/AbstractHandlerTest.php b/tests/Monolog/Handler/AbstractHandlerTest.php
index 568eb9d..1599c34 100644
--- a/tests/Monolog/Handler/AbstractHandlerTest.php
+++ b/tests/Monolog/Handler/AbstractHandlerTest.php
@@ -86,10 +86,10 @@ class AbstractHandlerTest extends TestCase
     /**
      * @covers Monolog\Handler\AbstractHandler::pushProcessor
      * @covers Monolog\Handler\AbstractHandler::popProcessor
-     * @expectedException LogicException
      */
     public function testPushPopProcessor()
     {
+        $this->expectException('LogicException');
         $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
         $processor1 = new WebProcessor;
         $processor2 = new WebProcessor;
@@ -104,10 +104,10 @@ class AbstractHandlerTest extends TestCase
 
     /**
      * @covers Monolog\Handler\AbstractHandler::pushProcessor
-     * @expectedException InvalidArgumentException
      */
     public function testPushProcessorWithNonCallable()
     {
+        $this->expectException('InvalidArgumentException');
         $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
 
         $handler->pushProcessor(new \stdClass());
diff --git a/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/tests/Monolog/Handler/ElasticSearchHandlerTest.php
index 512c720..cb9f6f1 100644
--- a/tests/Monolog/Handler/ElasticSearchHandlerTest.php
+++ b/tests/Monolog/Handler/ElasticSearchHandlerTest.php
@@ -97,11 +97,11 @@ class ElasticSearchHandlerTest extends TestCase
 
     /**
      * @covers                   Monolog\Handler\ElasticSearchHandler::setFormatter
-     * @expectedException        InvalidArgumentException
-     * @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter
      */
     public function testSetFormatterInvalid()
     {
+        $this->expectException('InvalidArgumentException');
+        $this->expectExceptionMessage('ElasticSearchHandler is only compatible with ElasticaFormatter');
         $handler = new ElasticSearchHandler($this->client);
         $formatter = new NormalizerFormatter();
         $handler->setFormatter($formatter);
@@ -134,7 +134,8 @@ class ElasticSearchHandlerTest extends TestCase
         $handler = new ElasticSearchHandler($client, $handlerOpts);
 
         if ($expectedError) {
-            $this->setExpectedException($expectedError[0], $expectedError[1]);
+            $this->expectedException($expectedError[0]);
+            $this->expectedExceptionMessage($expectedError[1]);
             $handler->handle($this->getRecord());
         } else {
             $this->assertFalse($handler->handle($this->getRecord()));
diff --git a/tests/Monolog/Handler/ErrorLogHandlerTest.php b/tests/Monolog/Handler/ErrorLogHandlerTest.php
index bbd1aba..5985bd9 100644
--- a/tests/Monolog/Handler/ErrorLogHandlerTest.php
+++ b/tests/Monolog/Handler/ErrorLogHandlerTest.php
@@ -29,11 +29,11 @@ class ErrorLogHandlerTest extends TestCase
 
     /**
      * @covers Monolog\Handler\ErrorLogHandler::__construct
-     * @expectedException InvalidArgumentException
-     * @expectedExceptionMessage The given message type "42" is not supported
      */
     public function testShouldNotAcceptAnInvalidTypeOnContructor()
     {
+        $this->expectException('InvalidArgumentException');
+        $this->expectExceptionMessage('The given message type "42" is not supported');
         new ErrorLogHandler(42);
     }
 
diff --git a/tests/Monolog/Handler/FilterHandlerTest.php b/tests/Monolog/Handler/FilterHandlerTest.php
index 5784c1a..60006a9 100644
--- a/tests/Monolog/Handler/FilterHandlerTest.php
+++ b/tests/Monolog/Handler/FilterHandlerTest.php
@@ -156,10 +156,10 @@ class FilterHandlerTest extends TestCase
 
     /**
      * @covers Monolog\Handler\FilterHandler::handle
-     * @expectedException \RuntimeException
      */
     public function testHandleWithBadCallbackThrowsException()
     {
+        $this->expectException('\RuntimeException');
         $handler = new FilterHandler(
             function ($record, $handler) {
                 return 'foo';
diff --git a/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/tests/Monolog/Handler/FingersCrossedHandlerTest.php
index 5d51de1..eac70e4 100644
--- a/tests/Monolog/Handler/FingersCrossedHandlerTest.php
+++ b/tests/Monolog/Handler/FingersCrossedHandlerTest.php
@@ -129,10 +129,10 @@ class FingersCrossedHandlerTest extends TestCase
     /**
      * @covers Monolog\Handler\FingersCrossedHandler::handle
      * @covers Monolog\Handler\FingersCrossedHandler::activate
-     * @expectedException RuntimeException
      */
     public function testHandleWithBadCallbackThrowsException()
     {
+        $this->expectException('RuntimeException');
         $handler = new FingersCrossedHandler(function ($record, $handler) {
                     return 'foo';
                 });
diff --git a/tests/Monolog/Handler/GroupHandlerTest.php b/tests/Monolog/Handler/GroupHandlerTest.php
index e20be64..be0d7ae 100644
--- a/tests/Monolog/Handler/GroupHandlerTest.php
+++ b/tests/Monolog/Handler/GroupHandlerTest.php
@@ -18,10 +18,10 @@ class GroupHandlerTest extends TestCase
 {
     /**
      * @covers Monolog\Handler\GroupHandler::__construct
-     * @expectedException InvalidArgumentException
      */
     public function testConstructorOnlyTakesHandler()
     {
+        $this->expectException('InvalidArgumentException');
         new GroupHandler(array(new TestHandler(), "foo"));
     }
 
diff --git a/tests/Monolog/Handler/HipChatHandlerTest.php b/tests/Monolog/Handler/HipChatHandlerTest.php
index 52dc9da..98400c9 100644
--- a/tests/Monolog/Handler/HipChatHandlerTest.php
+++ b/tests/Monolog/Handler/HipChatHandlerTest.php
@@ -263,11 +263,9 @@ class HipChatHandlerTest extends TestCase
         $this->handler->setFormatter($this->getIdentityFormatter());
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testCreateWithTooLongName()
     {
+        $this->expectException('InvalidArgumentException');
         $hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere');
     }
 
diff --git a/tests/Monolog/Handler/MongoDBHandlerTest.php b/tests/Monolog/Handler/MongoDBHandlerTest.php
index 0fdef63..049477a 100644
--- a/tests/Monolog/Handler/MongoDBHandlerTest.php
+++ b/tests/Monolog/Handler/MongoDBHandlerTest.php
@@ -16,11 +16,9 @@ use Monolog\Logger;
 
 class MongoDBHandlerTest extends TestCase
 {
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testConstructorShouldThrowExceptionForInvalidMongo()
     {
+        $this->expectException('InvalidArgumentException');
         new MongoDBHandler(new \stdClass(), 'DB', 'Collection');
     }
 
diff --git a/tests/Monolog/Handler/NativeMailerHandlerTest.php b/tests/Monolog/Handler/NativeMailerHandlerTest.php
index d9087ce..cb510b7 100644
--- a/tests/Monolog/Handler/NativeMailerHandlerTest.php
+++ b/tests/Monolog/Handler/NativeMailerHandlerTest.php
@@ -27,46 +27,36 @@ class NativeMailerHandlerTest extends TestCase
         $GLOBALS['mail'] = array();
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testConstructorHeaderInjection()
     {
+        $this->expectException('InvalidArgumentException');
         $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testSetterHeaderInjection()
     {
+        $this->expectException('InvalidArgumentException');
         $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
         $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testSetterArrayHeaderInjection()
     {
+        $this->expectException('InvalidArgumentException');
         $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
         $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testSetterContentTypeInjection()
     {
+        $this->expectException('InvalidArgumentException');
         $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
         $mailer->setContentType("text/html\r\nFrom: faked@attacker.org");
     }
 
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testSetterEncodingInjection()
     {
+        $this->expectException('InvalidArgumentException');
         $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
         $mailer->setEncoding("utf-8\r\nFrom: faked@attacker.org");
     }
diff --git a/tests/Monolog/Handler/NewRelicHandlerTest.php b/tests/Monolog/Handler/NewRelicHandlerTest.php
index 96bba32..76e3ffa 100644
--- a/tests/Monolog/Handler/NewRelicHandlerTest.php
+++ b/tests/Monolog/Handler/NewRelicHandlerTest.php
@@ -28,11 +28,9 @@ class NewRelicHandlerTest extends TestCase
         self::$transactionName = null;
     }
 
-    /**
-     * @expectedException Monolog\Handler\MissingExtensionException
-     */
     public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded()
     {
+        $this->expectException('Monolog\Handler\MissingExtensionException');
         $handler = new StubNewRelicHandlerWithoutExtension();
         $handler->handle($this->getRecord(Logger::ERROR));
     }
diff --git a/tests/Monolog/Handler/PHPConsoleHandlerTest.php b/tests/Monolog/Handler/PHPConsoleHandlerTest.php
index 10f3aee..4d8740f 100644
--- a/tests/Monolog/Handler/PHPConsoleHandlerTest.php
+++ b/tests/Monolog/Handler/PHPConsoleHandlerTest.php
@@ -187,11 +187,9 @@ class PHPConsoleHandlerTest extends TestCase
         );
     }
 
-    /**
-     * @expectedException Exception
-     */
     public function testWrongOptionsThrowsException()
     {
+        $this->expectException('Exception');
         new PHPConsoleHandler(array('xxx' => 1));
     }
 
diff --git a/tests/Monolog/Handler/RedisHandlerTest.php b/tests/Monolog/Handler/RedisHandlerTest.php
index 689d527..4e9a475 100644
--- a/tests/Monolog/Handler/RedisHandlerTest.php
+++ b/tests/Monolog/Handler/RedisHandlerTest.php
@@ -17,11 +17,9 @@ use Monolog\Formatter\LineFormatter;
 
 class RedisHandlerTest extends TestCase
 {
-    /**
-     * @expectedException InvalidArgumentException
-     */
     public function testConstructorShouldThrowExceptionForInvalidRedis()
     {
+        $this->expectException('InvalidArgumentException');
         new RedisHandler(new \stdClass(), 'key');
     }
 
diff --git a/tests/Monolog/Handler/SocketHandlerTest.php b/tests/Monolog/Handler/SocketHandlerTest.php
index 1da987c..8bf2138 100644
--- a/tests/Monolog/Handler/SocketHandlerTest.php
+++ b/tests/Monolog/Handler/SocketHandlerTest.php
@@ -29,20 +29,16 @@ class SocketHandlerTest extends TestCase
      */
     private $res;
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testInvalidHostname()
     {
+        $this->expectException('UnexpectedValueException');
         $this->createHandler('garbage://here');
         $this->writeRecord('data');
     }
 
-    /**
-     * @expectedException \InvalidArgumentException
-     */
     public function testBadConnectionTimeout()
     {
+        $this->expectException('\InvalidArgumentException');
         $this->createHandler('localhost:1234');
         $this->handler->setConnectionTimeout(-1);
     }
@@ -54,11 +50,9 @@ class SocketHandlerTest extends TestCase
         $this->assertEquals(10.1, $this->handler->getConnectionTimeout());
     }
 
-    /**
-     * @expectedException \InvalidArgumentException
-     */
     public function testBadTimeout()
     {
+        $this->expectException('\InvalidArgumentException');
         $this->createHandler('localhost:1234');
         $this->handler->setTimeout(-1);
     }
@@ -90,11 +84,9 @@ class SocketHandlerTest extends TestCase
         $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
     }
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testExceptionIsThrownOnFsockopenError()
     {
+        $this->expectException('UnexpectedValueException');
         $this->setMockHandler(array('fsockopen'));
         $this->handler->expects($this->once())
             ->method('fsockopen')
@@ -102,11 +94,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testExceptionIsThrownOnPfsockopenError()
     {
+        $this->expectException('UnexpectedValueException');
         $this->setMockHandler(array('pfsockopen'));
         $this->handler->expects($this->once())
             ->method('pfsockopen')
@@ -115,11 +105,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testExceptionIsThrownIfCannotSetTimeout()
     {
+        $this->expectException('UnexpectedValueException');
         $this->setMockHandler(array('streamSetTimeout'));
         $this->handler->expects($this->once())
             ->method('streamSetTimeout')
@@ -127,11 +115,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testExceptionIsThrownIfCannotSetChunkSize()
     {
+        $this->expectException('UnexpectedValueException');
         $this->setMockHandler(array('streamSetChunkSize'));
         $this->handler->setChunkSize(8192);
         $this->handler->expects($this->once())
@@ -140,11 +126,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testWriteFailsOnIfFwriteReturnsFalse()
     {
+        $this->expectException('RuntimeException');
         $this->setMockHandler(array('fwrite'));
 
         $callback = function ($arg) {
@@ -163,11 +147,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testWriteFailsIfStreamTimesOut()
     {
+        $this->expectException('RuntimeException');
         $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
 
         $callback = function ($arg) {
@@ -189,11 +171,9 @@ class SocketHandlerTest extends TestCase
         $this->writeRecord('Hello world');
     }
 
-    /**
-     * @expectedException RuntimeException
-     */
     public function testWriteFailsOnIncompleteWrite()
     {
+        $this->expectException('RuntimeException');
         $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
 
         $res = $this->res;
@@ -262,11 +242,9 @@ class SocketHandlerTest extends TestCase
         $this->assertTrue(is_resource($this->res));
     }
 
-    /**
-     * @expectedException \RuntimeException
-     */
     public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
     {
+        $this->expectException('RuntimeException');
         $this->setMockHandler(array('fwrite', 'streamGetMetadata'));
 
         $this->handler->expects($this->any())
diff --git a/tests/Monolog/Handler/StreamHandlerTest.php b/tests/Monolog/Handler/StreamHandlerTest.php
index 487030f..070b161 100644
--- a/tests/Monolog/Handler/StreamHandlerTest.php
+++ b/tests/Monolog/Handler/StreamHandlerTest.php
@@ -81,12 +81,12 @@ class StreamHandlerTest extends TestCase
     }
 
     /**
-     * @expectedException LogicException
      * @covers Monolog\Handler\StreamHandler::__construct
      * @covers Monolog\Handler\StreamHandler::write
      */
     public function testWriteMissingResource()
     {
+        $this->expectException('LogicException');
         $handler = new StreamHandler(null);
         $handler->handle($this->getRecord());
     }
@@ -102,32 +102,32 @@ class StreamHandlerTest extends TestCase
 
     /**
      * @dataProvider invalidArgumentProvider
-     * @expectedException InvalidArgumentException
      * @covers Monolog\Handler\StreamHandler::__construct
      */
     public function testWriteInvalidArgument($invalidArgument)
     {
+        $this->expectException('InvalidArgumentException');
         $handler = new StreamHandler($invalidArgument);
     }
 
     /**
-     * @expectedException UnexpectedValueException
      * @covers Monolog\Handler\StreamHandler::__construct
      * @covers Monolog\Handler\StreamHandler::write
      */
     public function testWriteInvalidResource()
     {
+        $this->expectException('UnexpectedValueException');
         $handler = new StreamHandler('bogus://url');
         $handler->handle($this->getRecord());
     }
 
     /**
-     * @expectedException UnexpectedValueException
      * @covers Monolog\Handler\StreamHandler::__construct
      * @covers Monolog\Handler\StreamHandler::write
      */
     public function testWriteNonExistingResource()
     {
+        $this->expectException('UnexpectedValueException');
         $handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000));
         $handler->handle($this->getRecord());
     }
@@ -153,13 +153,13 @@ class StreamHandlerTest extends TestCase
     }
 
     /**
-     * @expectedException Exception
-     * @expectedExceptionMessageRegExp /There is no existing directory at/
      * @covers Monolog\Handler\StreamHandler::__construct
      * @covers Monolog\Handler\StreamHandler::write
      */
     public function testWriteNonExistingAndNotCreatablePath()
     {
+        $this->expectException('Exception');
+        $this->expectExceptionMessageMatches('/There is no existing directory at/');
         if (defined('PHP_WINDOWS_VERSION_BUILD')) {
             $this->markTestSkipped('Permissions checks can not run on windows');
         }
@@ -168,13 +168,13 @@ class StreamHandlerTest extends TestCase
     }
 
     /**
-     * @expectedException Exception
-     * @expectedExceptionMessageRegExp /There is no existing directory at/
      * @covers Monolog\Handler\StreamHandler::__construct
      * @covers Monolog\Handler\StreamHandler::write
      */
     public function testWriteNonExistingAndNotCreatableFileResource()
     {
+        $this->expectException('Exception');
+        $this->expectExceptionMessageMatches('/There is no existing directory at/');
         if (defined('PHP_WINDOWS_VERSION_BUILD')) {
             $this->markTestSkipped('Permissions checks can not run on windows');
         }
diff --git a/tests/Monolog/Handler/SyslogHandlerTest.php b/tests/Monolog/Handler/SyslogHandlerTest.php
index 5efb1a9..99dd9c0 100644
--- a/tests/Monolog/Handler/SyslogHandlerTest.php
+++ b/tests/Monolog/Handler/SyslogHandlerTest.php
@@ -38,7 +38,7 @@ class SyslogHandlerTest extends \PHPUnit\Framework\TestCase
      */
     public function testConstructInvalidFacility()
     {
-        $this->setExpectedException('UnexpectedValueException');
+        $this->expectException('UnexpectedValueException');
         $handler = new SyslogHandler('test', 'unknown');
     }
 }
diff --git a/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/tests/Monolog/Handler/SyslogUdpHandlerTest.php
index a1ea9d0..5b902f9 100644
--- a/tests/Monolog/Handler/SyslogUdpHandlerTest.php
+++ b/tests/Monolog/Handler/SyslogUdpHandlerTest.php
@@ -18,11 +18,9 @@ use Monolog\TestCase;
  */
 class SyslogUdpHandlerTest extends TestCase
 {
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testWeValidateFacilities()
     {
+        $this->expectException('UnexpectedValueException');
         $handler = new SyslogUdpHandler("ip", null, "invalidFacility");
     }
 
diff --git a/tests/Monolog/Handler/UdpSocketTest.php b/tests/Monolog/Handler/UdpSocketTest.php
index fa524d0..9edaf51 100644
--- a/tests/Monolog/Handler/UdpSocketTest.php
+++ b/tests/Monolog/Handler/UdpSocketTest.php
@@ -52,11 +52,9 @@ class UdpSocketTest extends TestCase
         $socket->close();
     }
 
-    /**
-     * @expectedException LogicException
-     */
     public function testWriteAfterCloseErrors()
     {
+        $this->expectException('LogicException');
         $socket = new UdpSocket('127.0.0.1', 514);
         $socket->close();
         $socket->write('foo', "HEADER");
diff --git a/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php b/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
index 1eb3f55..ab4b302 100644
--- a/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
+++ b/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php
@@ -18,10 +18,10 @@ class WhatFailureGroupHandlerTest extends TestCase
 {
     /**
      * @covers Monolog\Handler\WhatFailureGroupHandler::__construct
-     * @expectedException InvalidArgumentException
      */
     public function testConstructorOnlyTakesHandler()
     {
+        $this->expectException('InvalidArgumentException');
         new WhatFailureGroupHandler(array(new TestHandler(), "foo"));
     }
 
diff --git a/tests/Monolog/LoggerTest.php b/tests/Monolog/LoggerTest.php
index 94d5ee8..ae71be5 100644
--- a/tests/Monolog/LoggerTest.php
+++ b/tests/Monolog/LoggerTest.php
@@ -63,10 +63,10 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
 
     /**
      * @covers Monolog\Logger::getLevelName
-     * @expectedException InvalidArgumentException
      */
     public function testGetLevelNameThrows()
     {
+        $this->expectException('InvalidArgumentException');
         Logger::getLevelName(5);
     }
 
@@ -136,10 +136,10 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
     /**
      * @covers Monolog\Logger::pushHandler
      * @covers Monolog\Logger::popHandler
-     * @expectedException LogicException
      */
     public function testPushPopHandler()
     {
+        $this->expectException('LogicException');
         $logger = new Logger(__METHOD__);
         $handler1 = new TestHandler;
         $handler2 = new TestHandler;
@@ -179,10 +179,10 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
     /**
      * @covers Monolog\Logger::pushProcessor
      * @covers Monolog\Logger::popProcessor
-     * @expectedException LogicException
      */
     public function testPushPopProcessor()
     {
+        $this->expectException('LogicException');
         $logger = new Logger(__METHOD__);
         $processor1 = new WebProcessor;
         $processor2 = new WebProcessor;
@@ -197,10 +197,10 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
 
     /**
      * @covers Monolog\Logger::pushProcessor
-     * @expectedException InvalidArgumentException
      */
     public function testPushProcessorWithNonCallable()
     {
+        $this->expectException('InvalidArgumentException');
         $logger = new Logger(__METHOD__);
 
         $logger->pushProcessor(new \stdClass());
@@ -561,20 +561,20 @@ class LoggerTest extends \PHPUnit\Framework\TestCase
 
     /**
      * @covers Monolog\Logger::setExceptionHandler
-     * @expectedException InvalidArgumentException
      */
     public function testBadExceptionHandlerType()
     {
+        $this->expectException('InvalidArgumentException');
         $logger = new Logger(__METHOD__);
         $logger->setExceptionHandler(false);
     }
 
     /**
      * @covers Monolog\Logger::handleException
-     * @expectedException Exception
      */
     public function testDefaultHandleException()
     {
+        $this->expectException('Exception');
         $logger = new Logger(__METHOD__);
         $handler = $this->getMock('Monolog\Handler\HandlerInterface');
         $handler->expects($this->any())
diff --git a/tests/Monolog/Processor/WebProcessorTest.php b/tests/Monolog/Processor/WebProcessorTest.php
index 3e4effb..1f518a9 100644
--- a/tests/Monolog/Processor/WebProcessorTest.php
+++ b/tests/Monolog/Processor/WebProcessorTest.php
@@ -116,11 +116,9 @@ class WebProcessorTest extends TestCase
         $this->assertSame(array('url' => 'B'), $record['extra']);
     }
 
-    /**
-     * @expectedException UnexpectedValueException
-     */
     public function testInvalidData()
     {
+        $this->expectException('UnexpectedValueException');
         new WebProcessor(new \stdClass);
     }
 }
diff --git a/tests/Monolog/RegistryTest.php b/tests/Monolog/RegistryTest.php
index 3742b63..7a7ff49 100644
--- a/tests/Monolog/RegistryTest.php
+++ b/tests/Monolog/RegistryTest.php
@@ -68,7 +68,7 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
         Registry::addLogger(new Logger('test1'), 'log');
         Registry::clear();
 
-        $this->setExpectedException('\InvalidArgumentException');
+        $this->expectException('\InvalidArgumentException');
         Registry::getInstance('log');
     }
 
@@ -82,7 +82,7 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
         Registry::addLogger($loggerToAdd);
         Registry::removeLogger($remove);
 
-        $this->setExpectedException('\InvalidArgumentException');
+        $this->expectException('\InvalidArgumentException');
         Registry::getInstance($loggerToAdd->getName());
     }
 
@@ -114,11 +114,11 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
     }
 
     /**
-     * @expectedException \InvalidArgumentException
      * @covers Monolog\Registry::getInstance
      */
     public function testFailsOnNonExistantLogger()
     {
+        $this->expectException('\InvalidArgumentException');
         Registry::getInstance('test1');
     }
 
@@ -138,11 +138,11 @@ class RegistryTest extends \PHPUnit\Framework\TestCase
     }
 
     /**
-     * @expectedException \InvalidArgumentException
      * @covers Monolog\Registry::addLogger
      */
     public function testFailsOnUnspecifiedReplacement()
     {
+        $this->expectException('\InvalidArgumentException');
         $log1 = new Logger('test1');
         $log2 = new Logger('test2');
 
diff --git a/tests/Monolog/UtilsTest.php b/tests/Monolog/UtilsTest.php
index 3188926..e68ec38 100644
--- a/tests/Monolog/UtilsTest.php
+++ b/tests/Monolog/UtilsTest.php
@@ -43,7 +43,7 @@ class UtilsTest extends \PHPUnit\Framework\TestCase
      */
     public function testHandleJsonErrorFailure($code, $msg)
     {
-        $this->setExpectedException('RuntimeException', $msg);
+        $this->expectException('RuntimeException', $msg);
         Utils::handleJsonError($code, 'faked');
     }
 
