1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
|
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');
}
|