-
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.
- Loading branch information
1 parent
b4ef7f9
commit f7db4ad
Showing
3 changed files
with
141 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,47 @@ | ||
<?php | ||
|
||
namespace IlicMiljan\SecureProps\Tests\Cipher\Exception; | ||
|
||
use IlicMiljan\SecureProps\Cipher\Exception\CipherException; | ||
use IlicMiljan\SecureProps\Cipher\Exception\InvalidKeyLength; | ||
use PHPUnit\Framework\TestCase; | ||
use RuntimeException; | ||
|
||
class InvalidKeyLengthTest extends TestCase | ||
{ | ||
private int $expectedLength; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->expectedLength = 32; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new InvalidKeyLength($this->expectedLength); | ||
|
||
$this->assertInstanceOf(InvalidKeyLength::class, $exception); | ||
} | ||
|
||
public function testReturnsExpectedLength(): void | ||
{ | ||
$exception = new InvalidKeyLength($this->expectedLength); | ||
|
||
$this->assertEquals($this->expectedLength, $exception->getExpectedLength()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new RuntimeException('Previous exception'); | ||
$exception = new InvalidKeyLength($this->expectedLength, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsCipherExceptionInterface(): void | ||
{ | ||
$exception = new InvalidKeyLength($this->expectedLength); | ||
|
||
$this->assertInstanceOf(CipherException::class, $exception); | ||
} | ||
} |
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\Exception; | ||
|
||
use IlicMiljan\SecureProps\Exception\EncryptionServiceException; | ||
use IlicMiljan\SecureProps\Exception\ValueMustBeObject; | ||
use PHPUnit\Framework\TestCase; | ||
use RuntimeException; | ||
|
||
class ValueMustBeObjectTest extends TestCase | ||
{ | ||
private string $type; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->type = 'string'; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new ValueMustBeObject($this->type); | ||
|
||
$this->assertInstanceOf(ValueMustBeObject::class, $exception); | ||
} | ||
|
||
public function testReturnsType(): void | ||
{ | ||
$exception = new ValueMustBeObject($this->type); | ||
|
||
$this->assertEquals($this->type, $exception->getType()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new RuntimeException('Previous exception'); | ||
$exception = new ValueMustBeObject($this->type, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsEncryptionServiceExceptionInterface(): void | ||
{ | ||
$exception = new ValueMustBeObject($this->type); | ||
|
||
$this->assertInstanceOf(EncryptionServiceException::class, $exception); | ||
} | ||
} |
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\Exception; | ||
|
||
use IlicMiljan\SecureProps\Exception\EncryptionServiceException; | ||
use IlicMiljan\SecureProps\Exception\ValueMustBeString; | ||
use PHPUnit\Framework\TestCase; | ||
use RuntimeException; | ||
|
||
class ValueMustBeStringTest extends TestCase | ||
{ | ||
private string $type; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->type = 'object'; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new ValueMustBeString($this->type); | ||
|
||
$this->assertInstanceOf(ValueMustBeString::class, $exception); | ||
} | ||
|
||
public function testReturnsType(): void | ||
{ | ||
$exception = new ValueMustBeString($this->type); | ||
|
||
$this->assertEquals($this->type, $exception->getType()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new RuntimeException('Previous exception'); | ||
$exception = new ValueMustBeString($this->type, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsEncryptionServiceExceptionInterface(): void | ||
{ | ||
$exception = new ValueMustBeString($this->type); | ||
|
||
$this->assertInstanceOf(EncryptionServiceException::class, $exception); | ||
} | ||
} |