-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from IlicMiljan/add-cache-and-reader-tests
Add `Cache` and `Reader` Unit Tests
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace IlicMiljan\SecureProps\Tests\Cache\Exception; | ||
|
||
use IlicMiljan\SecureProps\Cache\Exception\InvalidCacheKey; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class InvalidCacheKeyTest extends TestCase | ||
{ | ||
private string $cacheKey; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->cacheKey = 'invalidKey'; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new InvalidCacheKey($this->cacheKey); | ||
|
||
$this->assertInstanceOf(InvalidCacheKey::class, $exception); | ||
} | ||
|
||
public function testReturnsCacheKey(): void | ||
{ | ||
$exception = new InvalidCacheKey($this->cacheKey); | ||
|
||
$this->assertEquals($this->cacheKey, $exception->getCacheKey()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new LogicException('Previous exception'); | ||
$exception = new InvalidCacheKey($this->cacheKey, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace IlicMiljan\SecureProps\Tests\Reader\Exception; | ||
|
||
use IlicMiljan\SecureProps\Reader\Exception\ObjectPropertyNotFound; | ||
use IlicMiljan\SecureProps\Reader\Exception\ReaderException; | ||
use PHPUnit\Framework\TestCase; | ||
use RuntimeException; | ||
|
||
class ObjectPropertyNotFoundTest extends TestCase | ||
{ | ||
private string $className; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->className = 'TestClass'; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new ObjectPropertyNotFound($this->className); | ||
|
||
$this->assertInstanceOf(ObjectPropertyNotFound::class, $exception); | ||
} | ||
|
||
public function testReturnsClassName(): void | ||
{ | ||
$exception = new ObjectPropertyNotFound($this->className); | ||
|
||
$this->assertEquals($this->className, $exception->getClassName()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new RuntimeException('Previous exception'); | ||
$exception = new ObjectPropertyNotFound($this->className, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsReaderExceptionInterface(): void | ||
{ | ||
$exception = new ObjectPropertyNotFound($this->className); | ||
|
||
$this->assertInstanceOf(ReaderException::class, $exception); | ||
} | ||
} |