|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace Remorhaz\JSON\Pointer\Test\Query\Exception; |
| 5 | + |
| 6 | +use Exception; |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Remorhaz\JSON\Pointer\Query\Exception\LastReferenceNotFoundException; |
| 9 | + |
| 10 | +/** |
| 11 | + * @covers \Remorhaz\JSON\Pointer\Query\Exception\LastReferenceNotFoundException |
| 12 | + */ |
| 13 | +class LastReferenceNotFoundExceptionTest extends TestCase |
| 14 | +{ |
| 15 | + |
| 16 | + public function testGetMessage_Constructed_ReturnsMatchingValue(): void |
| 17 | + { |
| 18 | + $exception = new LastReferenceNotFoundException('a'); |
| 19 | + self::assertSame('Query \'a\' selected no last reference', $exception->getMessage()); |
| 20 | + } |
| 21 | + |
| 22 | + public function testGetSource_ConstructedWithSource_ReturnsSameValue(): void |
| 23 | + { |
| 24 | + $exception = new LastReferenceNotFoundException('a'); |
| 25 | + self::assertSame('a', $exception->getSource()); |
| 26 | + } |
| 27 | + |
| 28 | + public function testGetCode_Always_ReturnsZero(): void |
| 29 | + { |
| 30 | + $exception = new LastReferenceNotFoundException('a'); |
| 31 | + self::assertSame(0, $exception->getCode()); |
| 32 | + } |
| 33 | + |
| 34 | + public function testGetPrevious_ConstructedWithoutPrevious_ReturnsNull(): void |
| 35 | + { |
| 36 | + $exception = new LastReferenceNotFoundException('a'); |
| 37 | + self::assertNull($exception->getPrevious()); |
| 38 | + } |
| 39 | + |
| 40 | + public function testGetPrevious_ConstructedWithPrevious_ReturnsSameInstance(): void |
| 41 | + { |
| 42 | + $previous = new Exception; |
| 43 | + $exception = new LastReferenceNotFoundException('a', $previous); |
| 44 | + self::assertSame($previous, $exception->getPrevious()); |
| 45 | + } |
| 46 | +} |
0 commit comments