Skip to content

Commit fd6d71b

Browse files
committed
Add Reader Unit Tests
1 parent abc66f6 commit fd6d71b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace IlicMiljan\SecureProps\Tests\Reader\Exception;
4+
5+
use IlicMiljan\SecureProps\Reader\Exception\ObjectPropertyNotFound;
6+
use IlicMiljan\SecureProps\Reader\Exception\ReaderException;
7+
use PHPUnit\Framework\TestCase;
8+
use RuntimeException;
9+
10+
class ObjectPropertyNotFoundTest extends TestCase
11+
{
12+
private string $className;
13+
14+
protected function setUp(): void
15+
{
16+
$this->className = 'TestClass';
17+
}
18+
19+
public function testCanBeCreated(): void
20+
{
21+
$exception = new ObjectPropertyNotFound($this->className);
22+
23+
$this->assertInstanceOf(ObjectPropertyNotFound::class, $exception);
24+
}
25+
26+
public function testReturnsClassName(): void
27+
{
28+
$exception = new ObjectPropertyNotFound($this->className);
29+
30+
$this->assertEquals($this->className, $exception->getClassName());
31+
}
32+
33+
public function testPreviousExceptionIsStored(): void
34+
{
35+
$previous = new RuntimeException('Previous exception');
36+
$exception = new ObjectPropertyNotFound($this->className, $previous);
37+
38+
$this->assertSame($previous, $exception->getPrevious());
39+
}
40+
41+
public function testImplementsReaderExceptionInterface(): void
42+
{
43+
$exception = new ObjectPropertyNotFound($this->className);
44+
45+
$this->assertInstanceOf(ReaderException::class, $exception);
46+
}
47+
}

0 commit comments

Comments
 (0)