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 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
|
From: James Valleroy <jvalleroy@mailbox.org>
Date: Tue, 16 Jun 2020 13:06:32 -0400
Subject: Modify tests for phpunit >= 6
Forwarded: not-needed
---
tests/AppTest.php | 21 +++++++++++----------
tests/CallableResolverTest.php | 19 +++++++++++--------
tests/CollectionTest.php | 6 +++---
tests/ContainerTest.php | 6 +++---
tests/DeferredCallableTest.php | 4 ++--
tests/Handlers/AbstractHandlerTest.php | 4 ++--
tests/Handlers/ErrorTest.php | 6 +++---
tests/Handlers/NotAllowedTest.php | 6 +++---
tests/Handlers/NotFoundTest.php | 6 +++---
tests/Handlers/PhpErrorTest.php | 6 +++---
tests/Http/BodyTest.php | 18 +++++++++---------
tests/Http/CookiesTest.php | 6 +++---
tests/Http/EnvironmentTest.php | 6 +++---
tests/Http/HeadersTest.php | 4 ++--
tests/Http/MessageTest.php | 4 ++--
tests/Http/NonBufferedBodyTest.php | 18 +++++++++++++-----
tests/Http/RequestBodyTest.php | 22 +++++++++++-----------
tests/Http/RequestTest.php | 4 ++--
tests/Http/ResponseTest.php | 4 ++--
tests/Http/StreamTest.php | 6 +++---
tests/Http/UploadedFilesTest.php | 14 +++++++-------
tests/Http/UriTest.php | 4 ++--
tests/MiddlewareAwareTest.php | 8 ++++----
tests/RouteTest.php | 8 ++++----
tests/RouterTest.php | 20 +++++++++++++-------
25 files changed, 124 insertions(+), 106 deletions(-)
diff --git a/tests/AppTest.php b/tests/AppTest.php
index 99ae8af..1dda3d6 100644
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -10,7 +10,7 @@ namespace Slim\Tests;
use BadMethodCallException;
use Error;
use Exception;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
@@ -44,32 +44,33 @@ function header($value, $replace = true)
\Slim\header($value, $replace);
}
-class AppTest extends PHPUnit_Framework_TestCase
+class AppTest extends PHPUnit\Framework\TestCase
{
- public function setUp()
+ protected function setUp(): void
{
HeaderStack::reset();
}
- public function tearDown()
+ protected function tearDown(): void
{
HeaderStack::reset();
}
- public static function setupBeforeClass()
+ public static function setUpBeforeClass(): void
{
// ini_set('log_errors', 0);
ini_set('error_log', tempnam(sys_get_temp_dir(), 'slim'));
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
// ini_set('log_errors', 1);
}
public function testContainerInterfaceException()
{
- $this->setExpectedException('InvalidArgumentException', 'Expected a ContainerInterface');
+ $this->expectException('InvalidArgumentException');
+ $this->expectExceptionMessage('Expected a ContainerInterface');
$app = new App('');
}
@@ -1040,7 +1041,7 @@ class AppTest extends PHPUnit_Framework_TestCase
// now test that exception is raised if the handler isn't registered
unset($app->getContainer()['notAllowedHandler']);
- $this->setExpectedException('Slim\Exception\MethodNotAllowedException');
+ $this->expectException('Slim\Exception\MethodNotAllowedException');
$app($req, $res);
}
@@ -1250,7 +1251,7 @@ class AppTest extends PHPUnit_Framework_TestCase
// now test that exception is raised if the handler isn't registered
unset($app->getContainer()['notFoundHandler']);
- $this->setExpectedException('Slim\Exception\NotFoundException');
+ $this->expectException('Slim\Exception\NotFoundException');
$app($req, $res);
}
@@ -1317,7 +1318,7 @@ class AppTest extends PHPUnit_Framework_TestCase
$app->get('/foo', 'foo:bar');
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
// Invoke app
$app($req, $res);
diff --git a/tests/CallableResolverTest.php b/tests/CallableResolverTest.php
index f3ac94d..6a2a2fb 100644
--- a/tests/CallableResolverTest.php
+++ b/tests/CallableResolverTest.php
@@ -7,20 +7,20 @@
namespace Slim\Tests;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\CallableResolver;
use Slim\Container;
use Slim\Tests\Mocks\CallableTest;
use Slim\Tests\Mocks\InvokableTest;
-class CallableResolverTest extends PHPUnit_Framework_TestCase
+class CallableResolverTest extends PHPUnit\Framework\TestCase
{
/**
* @var Container
*/
private $container;
- public function setUp()
+ protected function setUp(): void
{
CallableTest::$CalledCount = 0;
InvokableTest::$CalledCount = 0;
@@ -111,35 +111,38 @@ class CallableResolverTest extends PHPUnit_Framework_TestCase
{
$this->container['callable_service'] = new CallableTest();
$resolver = new CallableResolver($this->container);
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$resolver->resolve('callable_service:noFound');
}
public function testFunctionNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$resolver->resolve('noFound');
}
public function testClassNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
- $this->setExpectedException('\RuntimeException', 'Callable Unknown does not exist');
+ $this->expectException('\RuntimeException');
+ $this->expectExceptionMessage('Callable Unknown does not exist');
$resolver->resolve('Unknown:notFound');
}
public function testCallableClassNotFoundThrowException()
{
$resolver = new CallableResolver($this->container);
- $this->setExpectedException('\RuntimeException', 'is not resolvable');
+ $this->expectException('\RuntimeException');
+ $this->expectExceptionMessage('is not resolvable');
$resolver->resolve(['Unknown', 'notFound']);
}
public function testCallableInvalidTypeThrowException()
{
$resolver = new CallableResolver($this->container);
- $this->setExpectedException('\RuntimeException', 'is not resolvable');
+ $this->expectException('\RuntimeException');
+ $this->expectExceptionMessage('is not resolvable');
$resolver->resolve(__LINE__);
}
}
diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php
index 7c21c66..b4feff6 100644
--- a/tests/CollectionTest.php
+++ b/tests/CollectionTest.php
@@ -7,11 +7,11 @@
namespace Slim\Tests;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionProperty;
use Slim\Collection;
-class CollectionTest extends PHPUnit_Framework_TestCase
+class CollectionTest extends PHPUnit\Framework\TestCase
{
/**
* @var Collection
@@ -23,7 +23,7 @@ class CollectionTest extends PHPUnit_Framework_TestCase
*/
protected $property;
- public function setUp()
+ protected function setUp(): void
{
$this->bag = new Collection();
$this->property = new ReflectionProperty($this->bag, 'data');
diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php
index b989bb2..a4e3b6d 100644
--- a/tests/ContainerTest.php
+++ b/tests/ContainerTest.php
@@ -8,18 +8,18 @@
namespace Slim\Tests;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Psr\Container\ContainerInterface;
use Slim\Container;
-class ContainerTest extends PHPUnit_Framework_TestCase
+class ContainerTest extends PHPUnit\Framework\TestCase
{
/**
* @var Container
*/
protected $container;
- public function setUp()
+ protected function setUp(): void
{
$this->container = new Container;
}
diff --git a/tests/DeferredCallableTest.php b/tests/DeferredCallableTest.php
index eb83383..453d482 100644
--- a/tests/DeferredCallableTest.php
+++ b/tests/DeferredCallableTest.php
@@ -7,12 +7,12 @@
namespace Slim\Tests;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Container;
use Slim\DeferredCallable;
use Slim\Tests\Mocks\CallableTest;
-class DeferredCallableTest extends PHPUnit_Framework_TestCase
+class DeferredCallableTest extends PHPUnit\Framework\TestCase
{
public function testItResolvesCallable()
{
diff --git a/tests/Handlers/AbstractHandlerTest.php b/tests/Handlers/AbstractHandlerTest.php
index aa7d08c..2e173e5 100644
--- a/tests/Handlers/AbstractHandlerTest.php
+++ b/tests/Handlers/AbstractHandlerTest.php
@@ -7,11 +7,11 @@
namespace Slim\Tests\Handlers;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionClass;
use Slim\Handlers\AbstractHandler;
-class AbstractHandlerTest extends PHPUnit_Framework_TestCase
+class AbstractHandlerTest extends PHPUnit\Framework\TestCase
{
public function testHalfValidContentType()
{
diff --git a/tests/Handlers/ErrorTest.php b/tests/Handlers/ErrorTest.php
index d82c9a8..747c8bc 100644
--- a/tests/Handlers/ErrorTest.php
+++ b/tests/Handlers/ErrorTest.php
@@ -9,7 +9,7 @@ namespace Slim\Tests\Handlers;
use Exception;
use PHPUnit_Framework_MockObject_MockObject;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionClass;
use RuntimeException;
use Slim\Handlers\Error;
@@ -17,7 +17,7 @@ use Slim\Http\Request;
use Slim\Http\Response;
use UnexpectedValueException;
-class ErrorTest extends PHPUnit_Framework_TestCase
+class ErrorTest extends PHPUnit\Framework\TestCase
{
public function errorProvider()
{
@@ -113,7 +113,7 @@ class ErrorTest extends PHPUnit_Framework_TestCase
$renderHtmlExceptionorError = $class->getMethod('renderHtmlExceptionOrError');
$renderHtmlExceptionorError->setAccessible(true);
- $this->setExpectedException(RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$error = new Error();
$renderHtmlExceptionorError->invokeArgs($error, ['foo']);
diff --git a/tests/Handlers/NotAllowedTest.php b/tests/Handlers/NotAllowedTest.php
index 49935b4..6c50b2f 100644
--- a/tests/Handlers/NotAllowedTest.php
+++ b/tests/Handlers/NotAllowedTest.php
@@ -8,12 +8,12 @@
namespace Slim\Tests\Handlers;
use PHPUnit_Framework_MockObject_MockObject;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Handlers\NotAllowed;
use Slim\Http\Request;
use Slim\Http\Response;
-class NotAllowedTest extends PHPUnit_Framework_TestCase
+class NotAllowedTest extends PHPUnit\Framework\TestCase
{
public function invalidMethodProvider()
{
@@ -64,7 +64,7 @@ class NotAllowedTest extends PHPUnit_Framework_TestCase
$errorMock->method('determineContentType')
->will($this->returnValue('unknown/type'));
- $this->setExpectedException('\UnexpectedValueException');
+ $this->expectException('\UnexpectedValueException');
$errorMock->__invoke($this->getRequest('GET', 'unknown/type'), new Response(), ['POST']);
}
diff --git a/tests/Handlers/NotFoundTest.php b/tests/Handlers/NotFoundTest.php
index 13351b2..9e4c652 100644
--- a/tests/Handlers/NotFoundTest.php
+++ b/tests/Handlers/NotFoundTest.php
@@ -8,13 +8,13 @@
namespace Slim\Tests\Handlers;
use PHPUnit_Framework_MockObject_MockObject;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Handlers\NotFound;
use Slim\Http\Request;
use Slim\Http\Response;
use Slim\Http\Uri;
-class NotFoundTest extends PHPUnit_Framework_TestCase
+class NotFoundTest extends PHPUnit\Framework\TestCase
{
public function notFoundProvider()
{
@@ -53,7 +53,7 @@ class NotFoundTest extends PHPUnit_Framework_TestCase
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
- $this->setExpectedException('\UnexpectedValueException');
+ $this->expectException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), ['POST']);
}
diff --git a/tests/Handlers/PhpErrorTest.php b/tests/Handlers/PhpErrorTest.php
index 864495e..405b88b 100644
--- a/tests/Handlers/PhpErrorTest.php
+++ b/tests/Handlers/PhpErrorTest.php
@@ -9,14 +9,14 @@ namespace Slim\Tests\Handlers;
use Exception;
use PHPUnit_Framework_MockObject_MockObject;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Handlers\PhpError;
use Slim\Http\Request;
use Slim\Http\Response;
use Throwable;
use UnexpectedValueException;
-class PhpErrorTest extends PHPUnit_Framework_TestCase
+class PhpErrorTest extends PHPUnit\Framework\TestCase
{
public function phpErrorProvider()
{
@@ -79,7 +79,7 @@ class PhpErrorTest extends PHPUnit_Framework_TestCase
$req = $this->getMockBuilder('Slim\Http\Request')->disableOriginalConstructor()->getMock();
- $this->setExpectedException('\UnexpectedValueException');
+ $this->expectException('\UnexpectedValueException');
$errorMock->__invoke($req, new Response(), new Exception());
}
diff --git a/tests/Http/BodyTest.php b/tests/Http/BodyTest.php
index d14a6b8..8dbe09d 100644
--- a/tests/Http/BodyTest.php
+++ b/tests/Http/BodyTest.php
@@ -8,11 +8,11 @@
namespace Slim\Tests\Http;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionProperty;
use Slim\Http\Body;
-class BodyTest extends PHPUnit_Framework_TestCase
+class BodyTest extends PHPUnit\Framework\TestCase
{
/**
* @var string
@@ -25,7 +25,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
*/
protected $stream;
- protected function tearDown()
+ protected function tearDown(): void
{
if (is_resource($this->stream) === true) {
fclose($this->stream);
@@ -198,7 +198,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$bodyStream->setAccessible(true);
$bodyStream->setValue($body, null);
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->tell();
}
@@ -319,7 +319,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$body = new Body($this->stream);
$body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->seek(10);
}
@@ -339,7 +339,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$body = new Body($this->stream);
$body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->rewind();
}
@@ -357,7 +357,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$body = new Body($this->stream);
$body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->read(10);
}
@@ -379,7 +379,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$body = new Body($this->stream);
$body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->write('foo');
}
@@ -398,7 +398,7 @@ class BodyTest extends PHPUnit_Framework_TestCase
$body = new Body($this->stream);
$body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$body->getContents();
}
}
diff --git a/tests/Http/CookiesTest.php b/tests/Http/CookiesTest.php
index 9370b73..962cb09 100644
--- a/tests/Http/CookiesTest.php
+++ b/tests/Http/CookiesTest.php
@@ -8,13 +8,13 @@
namespace Slim\Tests\Http;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionClass;
use ReflectionProperty;
use Slim\Http\Cookies;
use stdClass;
-class CookiesTest extends PHPUnit_Framework_TestCase
+class CookiesTest extends PHPUnit\Framework\TestCase
{
public function testConstructor()
{
@@ -269,7 +269,7 @@ class CookiesTest extends PHPUnit_Framework_TestCase
public function testParseHeaderException()
{
- $this->setExpectedException(InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
Cookies::parseHeader(new stdClass);
}
}
diff --git a/tests/Http/EnvironmentTest.php b/tests/Http/EnvironmentTest.php
index c0d8a54..4270e2a 100644
--- a/tests/Http/EnvironmentTest.php
+++ b/tests/Http/EnvironmentTest.php
@@ -7,16 +7,16 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Http\Environment;
-class EnvironmentTest extends PHPUnit_Framework_TestCase
+class EnvironmentTest extends PHPUnit\Framework\TestCase
{
/**
* Server settings for the default HTTP request
* used by this script's tests.
*/
- public function setUp()
+ protected function setUp(): void
{
$_SERVER['DOCUMENT_ROOT'] = '/var/www';
$_SERVER['SCRIPT_NAME'] = '/foo/index.php';
diff --git a/tests/Http/HeadersTest.php b/tests/Http/HeadersTest.php
index c64de5b..3c664e4 100644
--- a/tests/Http/HeadersTest.php
+++ b/tests/Http/HeadersTest.php
@@ -7,12 +7,12 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionProperty;
use Slim\Http\Environment;
use Slim\Http\Headers;
-class HeadersTest extends PHPUnit_Framework_TestCase
+class HeadersTest extends PHPUnit\Framework\TestCase
{
public function testCreateFromEnvironment()
{
diff --git a/tests/Http/MessageTest.php b/tests/Http/MessageTest.php
index 654fecd..ef73a5f 100644
--- a/tests/Http/MessageTest.php
+++ b/tests/Http/MessageTest.php
@@ -9,12 +9,12 @@ namespace Slim\Tests\Http;
use InvalidArgumentException;
use PHPUnit_Framework_MockObject_MockObject;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Http\Body;
use Slim\Http\Headers;
use Slim\Tests\Mocks\MessageStub;
-class MessageTest extends PHPUnit_Framework_TestCase
+class MessageTest extends PHPUnit\Framework\TestCase
{
public function testGetProtocolVersion()
{
diff --git a/tests/Http/NonBufferedBodyTest.php b/tests/Http/NonBufferedBodyTest.php
index 537612a..894b5f0 100644
--- a/tests/Http/NonBufferedBodyTest.php
+++ b/tests/Http/NonBufferedBodyTest.php
@@ -7,19 +7,19 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Http\NonBufferedBody;
use Slim\Http\Response;
use Slim\Tests\Assets\HeaderStack;
-class NonBufferedBodyTest extends PHPUnit_Framework_TestCase
+class NonBufferedBodyTest extends PHPUnit\Framework\TestCase
{
- protected function setUp()
+ protected function setUp(): void
{
HeaderStack::reset();
}
- protected function tearDown()
+ protected function tearDown(): void
{
HeaderStack::reset();
}
@@ -75,6 +75,9 @@ class NonBufferedBodyTest extends PHPUnit_Framework_TestCase
$this->assertEquals('buffer content: hello world', $contents);
}
+ /**
+ * @runInSeparateProcess
+ */
public function testWithHeader()
{
(new Response())
@@ -90,6 +93,9 @@ class NonBufferedBodyTest extends PHPUnit_Framework_TestCase
], HeaderStack::stack());
}
+ /**
+ * @runInSeparateProcess
+ */
public function testWithAddedHeader()
{
(new Response())
@@ -111,7 +117,9 @@ class NonBufferedBodyTest extends PHPUnit_Framework_TestCase
], HeaderStack::stack());
}
-
+ /**
+ * @runInSeparateProcess
+ */
public function testWithoutHeader()
{
(new Response())
diff --git a/tests/Http/RequestBodyTest.php b/tests/Http/RequestBodyTest.php
index 07f3b74..480f7d2 100644
--- a/tests/Http/RequestBodyTest.php
+++ b/tests/Http/RequestBodyTest.php
@@ -7,11 +7,11 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionProperty;
use Slim\Http\RequestBody;
-class RequestBodyTest extends PHPUnit_Framework_TestCase
+class RequestBodyTest extends PHPUnit\Framework\TestCase
{
/** @var string */
// @codingStandardsIgnoreStart
@@ -26,14 +26,14 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*/
- protected function setUp()
+ protected function setUp(): void
{
$this->body = new RequestBody();
$this->body->write($this->text);
$this->body->rewind();
}
- protected function tearDown()
+ protected function tearDown(): void
{
if (is_resource($this->stream) === true) {
fclose($this->stream);
@@ -147,7 +147,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
$this->assertFalse($this->body->isWritable());
$this->assertEquals('', (string)$this->body);
- $this->setExpectedException('RuntimeException');
+ $this->expectException('RuntimeException');
$this->body->tell();
}
@@ -178,7 +178,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
$bodyStream->setAccessible(true);
$bodyStream->setValue($this->body, null);
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->tell();
}
@@ -256,7 +256,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
{
$this->body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->seek(10);
}
@@ -272,7 +272,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
{
$this->body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->rewind();
}
@@ -285,7 +285,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
{
$this->body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->read(10);
}
@@ -303,7 +303,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
{
$this->body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->write('foo');
}
@@ -318,7 +318,7 @@ class RequestBodyTest extends PHPUnit_Framework_TestCase
{
$this->body->detach();
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$this->body->getContents();
}
}
diff --git a/tests/Http/RequestTest.php b/tests/Http/RequestTest.php
index 2ec7429..e19ac41 100644
--- a/tests/Http/RequestTest.php
+++ b/tests/Http/RequestTest.php
@@ -8,7 +8,7 @@
namespace Slim\Tests\Http;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Prophecy\Argument;
use Prophecy\Prophecy\MethodProphecy;
use Psr\Http\Message\UriInterface;
@@ -22,7 +22,7 @@ use Slim\Http\RequestBody;
use Slim\Http\UploadedFile;
use Slim\Http\Uri;
-class RequestTest extends PHPUnit_Framework_TestCase
+class RequestTest extends PHPUnit\Framework\TestCase
{
public function requestFactory($envData = [])
{
diff --git a/tests/Http/ResponseTest.php b/tests/Http/ResponseTest.php
index faaaa3b..5e456aa 100755
--- a/tests/Http/ResponseTest.php
+++ b/tests/Http/ResponseTest.php
@@ -8,14 +8,14 @@
namespace Slim\Tests\Http;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionProperty;
use RuntimeException;
use Slim\Http\Body;
use Slim\Http\Headers;
use Slim\Http\Response;
-class ResponseTest extends PHPUnit_Framework_TestCase
+class ResponseTest extends PHPUnit\Framework\TestCase
{
public function testConstructorWithDefaultArgs()
{
diff --git a/tests/Http/StreamTest.php b/tests/Http/StreamTest.php
index 1c5bbbe..6d0f030 100644
--- a/tests/Http/StreamTest.php
+++ b/tests/Http/StreamTest.php
@@ -7,11 +7,11 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use RuntimeException;
use Slim\Http\Stream;
-class StreamTest extends PHPUnit_Framework_TestCase
+class StreamTest extends PHPUnit\Framework\TestCase
{
/**
* @var resource pipe stream file handle
@@ -23,7 +23,7 @@ class StreamTest extends PHPUnit_Framework_TestCase
*/
private $pipeStream;
- public function tearDown()
+ protected function tearDown(): void
{
if ($this->pipeFh != null) {
stream_get_contents($this->pipeFh); // prevent broken pipe error message
diff --git a/tests/Http/UploadedFilesTest.php b/tests/Http/UploadedFilesTest.php
index 71246d1..7869335 100644
--- a/tests/Http/UploadedFilesTest.php
+++ b/tests/Http/UploadedFilesTest.php
@@ -7,7 +7,7 @@
namespace Slim\Tests\Http;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use RuntimeException;
use Slim\Http\Environment;
use Slim\Http\Headers;
@@ -17,20 +17,20 @@ use Slim\Http\Stream;
use Slim\Http\UploadedFile;
use Slim\Http\Uri;
-class UploadedFilesTest extends PHPUnit_Framework_TestCase
+class UploadedFilesTest extends PHPUnit\Framework\TestCase
{
static private $filename = './phpUxcOty';
static private $tmpFiles = ['./phpUxcOty'];
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
$fh = fopen(self::$filename, "w");
fwrite($fh, "12345678");
fclose($fh);
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
foreach (self::$tmpFiles as $filename) {
if (file_exists($filename)) {
@@ -147,7 +147,7 @@ class UploadedFilesTest extends PHPUnit_Framework_TestCase
{
$tempName = uniqid('file-');
$path = 'some_random_dir' . DIRECTORY_SEPARATOR . $tempName;
- $this->setExpectedException('\InvalidArgumentException');
+ $this->expectException('\InvalidArgumentException');
$uploadedFile->moveTo($path);
}
@@ -198,7 +198,7 @@ class UploadedFilesTest extends PHPUnit_Framework_TestCase
*/
public function testMoveToAgain(UploadedFile $uploadedFile)
{
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$tempName = uniqid('file-');
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tempName;
@@ -214,7 +214,7 @@ class UploadedFilesTest extends PHPUnit_Framework_TestCase
*/
public function testMovedStream($uploadedFile)
{
- $this->setExpectedException('\RuntimeException');
+ $this->expectException('\RuntimeException');
$uploadedFile->getStream();
}
diff --git a/tests/Http/UriTest.php b/tests/Http/UriTest.php
index c8dd090..9198f3b 100644
--- a/tests/Http/UriTest.php
+++ b/tests/Http/UriTest.php
@@ -8,11 +8,11 @@
namespace Slim\Tests\Http;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Http\Environment;
use Slim\Http\Uri;
-class UriTest extends PHPUnit_Framework_TestCase
+class UriTest extends PHPUnit\Framework\TestCase
{
protected $uri;
diff --git a/tests/MiddlewareAwareTest.php b/tests/MiddlewareAwareTest.php
index b206f0f..70721ce 100644
--- a/tests/MiddlewareAwareTest.php
+++ b/tests/MiddlewareAwareTest.php
@@ -7,7 +7,7 @@
namespace Slim\Tests;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use RuntimeException;
use Slim\Http\Body;
use Slim\Http\Headers;
@@ -16,7 +16,7 @@ use Slim\Http\Response;
use Slim\Http\Uri;
use Slim\Tests\Mocks\Stackable;
-class MiddlewareAwareTest extends PHPUnit_Framework_TestCase
+class MiddlewareAwareTest extends PHPUnit\Framework\TestCase
{
public function testSeedsMiddlewareStack()
{
@@ -160,7 +160,7 @@ class MiddlewareAwareTest extends PHPUnit_Framework_TestCase
});
return $resp;
});
- $this->setExpectedException('RuntimeException');
+ $this->expectException('RuntimeException');
$stack->callMiddlewareStack(
$this->getMockBuilder('Psr\Http\Message\ServerRequestInterface')->disableOriginalConstructor()->getMock(),
$this->getMockBuilder('Psr\Http\Message\ResponseInterface')->disableOriginalConstructor()->getMock()
@@ -171,7 +171,7 @@ class MiddlewareAwareTest extends PHPUnit_Framework_TestCase
{
$stack = new Stackable;
$stack->alternativeSeed();
- $this->setExpectedException('RuntimeException');
+ $this->expectException('RuntimeException');
$stack->alternativeSeed();
}
}
diff --git a/tests/RouteTest.php b/tests/RouteTest.php
index 5e2527d..c894b2a 100644
--- a/tests/RouteTest.php
+++ b/tests/RouteTest.php
@@ -8,7 +8,7 @@
namespace Slim\Tests;
use Exception;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use Slim\Container;
use Slim\DeferredCallable;
use Slim\Http\Body;
@@ -22,7 +22,7 @@ use Slim\Tests\Mocks\CallableTest;
use Slim\Tests\Mocks\InvocationStrategyTest;
use Slim\Tests\Mocks\MiddlewareStub;
-class RouteTest extends PHPUnit_Framework_TestCase
+class RouteTest extends PHPUnit\Framework\TestCase
{
public function routeFactory()
{
@@ -176,7 +176,7 @@ class RouteTest extends PHPUnit_Framework_TestCase
{
$route = $this->routeFactory();
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException('InvalidArgumentException');
$route->setName(false);
}
@@ -201,7 +201,7 @@ class RouteTest extends PHPUnit_Framework_TestCase
{
$route = $this->routeFactory();
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException('InvalidArgumentException');
$route->setOutputBuffering('invalid');
}
diff --git a/tests/RouterTest.php b/tests/RouterTest.php
index d825d5c..8234166 100644
--- a/tests/RouterTest.php
+++ b/tests/RouterTest.php
@@ -8,13 +8,13 @@
namespace Slim\Tests;
use InvalidArgumentException;
-use PHPUnit_Framework_TestCase;
+use PHPUnit;
use ReflectionClass;
use RuntimeException;
use Slim\Http\Uri;
use Slim\Router;
-class RouterTest extends PHPUnit_Framework_TestCase
+class RouterTest extends PHPUnit\Framework\TestCase
{
/**
* @var Router
@@ -26,12 +26,12 @@ class RouterTest extends PHPUnit_Framework_TestCase
*/
protected $cacheFile;
- public function setUp()
+ protected function setUp(): void
{
$this->router = new Router;
}
- public function tearDown()
+ protected function tearDown(): void
{
if (file_exists($this->cacheFile)) {
unlink($this->cacheFile);
@@ -354,8 +354,10 @@ class RouterTest extends PHPUnit_Framework_TestCase
public function testSettingInvalidCacheFileValue()
{
- $this->setExpectedException(
+ $this->expectException(
'\InvalidArgumentException',
+ );
+ $this->expectExceptionMessage(
'Router cache file must be a string'
);
$this->router->setCacheFile(['invalid']);
@@ -366,8 +368,10 @@ class RouterTest extends PHPUnit_Framework_TestCase
$this->cacheFile = __DIR__ . '/non-readable.cache';
file_put_contents($this->cacheFile, '<?php return []; ?>');
- $this->setExpectedException(
+ $this->expectException(
'\RuntimeException',
+ );
+ $this->expectExceptionMessage(
sprintf('Router cache file `%s` is not readable', $this->cacheFile)
);
@@ -378,8 +382,10 @@ class RouterTest extends PHPUnit_Framework_TestCase
{
$cacheFile = __DIR__ . '/non-writable-directory/router.cache';
- $this->setExpectedException(
+ $this->expectException(
'\RuntimeException',
+ );
+ $this->expectExceptionMessage(
sprintf('Router cache file directory `%s` is not writable', dirname($cacheFile))
);
|