|
6 | 6 | use Illuminate\Contracts\Support\Htmlable; |
7 | 7 | use Illuminate\Support\Env; |
8 | 8 | use Illuminate\Support\Optional; |
| 9 | +use LogicException; |
9 | 10 | use Mockery as m; |
10 | 11 | use PHPUnit\Framework\TestCase; |
11 | 12 | use RuntimeException; |
@@ -362,10 +363,63 @@ public function testTap() |
362 | 363 | } |
363 | 364 |
|
364 | 365 | public function testThrow() |
| 366 | + { |
| 367 | + $this->expectException(LogicException::class); |
| 368 | + |
| 369 | + throw_if(true, new LogicException); |
| 370 | + } |
| 371 | + |
| 372 | + public function testThrowDefaultException() |
| 373 | + { |
| 374 | + $this->expectException(RuntimeException::class); |
| 375 | + |
| 376 | + throw_if(true); |
| 377 | + } |
| 378 | + |
| 379 | + public function testThrowExceptionWithMessage() |
365 | 380 | { |
366 | 381 | $this->expectException(RuntimeException::class); |
| 382 | + $this->expectExceptionMessage('test'); |
| 383 | + |
| 384 | + throw_if(true, 'test'); |
| 385 | + } |
| 386 | + |
| 387 | + public function testThrowExceptionAsStringWithMessage() |
| 388 | + { |
| 389 | + $this->expectException(LogicException::class); |
| 390 | + $this->expectExceptionMessage('test'); |
| 391 | + |
| 392 | + throw_if(true, LogicException::class, 'test'); |
| 393 | + } |
| 394 | + |
| 395 | + public function testThrowUnless() |
| 396 | + { |
| 397 | + $this->expectException(LogicException::class); |
| 398 | + |
| 399 | + throw_unless(false, new LogicException); |
| 400 | + } |
| 401 | + |
| 402 | + public function testThrowUnlessDefaultException() |
| 403 | + { |
| 404 | + $this->expectException(RuntimeException::class); |
| 405 | + |
| 406 | + throw_unless(false); |
| 407 | + } |
| 408 | + |
| 409 | + public function testThrowUnlessExceptionWithMessage() |
| 410 | + { |
| 411 | + $this->expectException(RuntimeException::class); |
| 412 | + $this->expectExceptionMessage('test'); |
| 413 | + |
| 414 | + throw_unless(false, 'test'); |
| 415 | + } |
| 416 | + |
| 417 | + public function testThrowUnlessExceptionAsStringWithMessage() |
| 418 | + { |
| 419 | + $this->expectException(LogicException::class); |
| 420 | + $this->expectExceptionMessage('test'); |
367 | 421 |
|
368 | | - throw_if(true, new RuntimeException); |
| 422 | + throw_unless(false, LogicException::class, 'test'); |
369 | 423 | } |
370 | 424 |
|
371 | 425 | public function testThrowReturnIfNotThrown() |
|
0 commit comments