-
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 #4 from IlicMiljan/add-cipher-exception-tests
Add Cipher Exceptions Unit Tests
- Loading branch information
Showing
16 changed files
with
178 additions
and
18 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
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
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
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
2 changes: 1 addition & 1 deletion
2
src/Cipher/Exception/FailedCalculatingInitializationVectorLength.php
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
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
tests/Cipher/Exception/FailedCalculatingInitializationVectorLengthTest.php
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\FailedCalculatingInitializationVectorLength; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FailedCalculatingInitializationVectorLengthTest extends TestCase | ||
{ | ||
private string $cipher; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->cipher = 'AES-256-GCM'; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new FailedCalculatingInitializationVectorLength($this->cipher); | ||
|
||
$this->assertInstanceOf(FailedCalculatingInitializationVectorLength::class, $exception); | ||
} | ||
|
||
public function testReturnsCipher(): void | ||
{ | ||
$exception = new FailedCalculatingInitializationVectorLength($this->cipher); | ||
|
||
$this->assertEquals($this->cipher, $exception->getCipher()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new LogicException('Previous exception'); | ||
$exception = new FailedCalculatingInitializationVectorLength($this->cipher, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsCipherExceptionInterface(): void | ||
{ | ||
$exception = new FailedCalculatingInitializationVectorLength($this->cipher); | ||
|
||
$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,33 @@ | ||
<?php | ||
|
||
namespace IlicMiljan\SecureProps\Tests\Cipher\Exception; | ||
|
||
use IlicMiljan\SecureProps\Cipher\Exception\CipherException; | ||
use IlicMiljan\SecureProps\Cipher\Exception\FailedDecryptingValue; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FailedDecryptingValueTest extends TestCase | ||
{ | ||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new FailedDecryptingValue(); | ||
|
||
$this->assertInstanceOf(FailedDecryptingValue::class, $exception); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new LogicException('Previous exception'); | ||
$exception = new FailedDecryptingValue($previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsCipherExceptionInterface(): void | ||
{ | ||
$exception = new FailedDecryptingValue(); | ||
|
||
$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,33 @@ | ||
<?php | ||
|
||
namespace IlicMiljan\SecureProps\Tests\Cipher\Exception; | ||
|
||
use IlicMiljan\SecureProps\Cipher\Exception\CipherException; | ||
use IlicMiljan\SecureProps\Cipher\Exception\FailedEncryptingValue; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FailedEncryptingValueTest extends TestCase | ||
{ | ||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new FailedEncryptingValue(); | ||
|
||
$this->assertInstanceOf(FailedEncryptingValue::class, $exception); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new LogicException('Previous exception'); | ||
$exception = new FailedEncryptingValue($previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsCipherExceptionInterface(): void | ||
{ | ||
$exception = new FailedEncryptingValue(); | ||
|
||
$this->assertInstanceOf(CipherException::class, $exception); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/Cipher/Exception/FailedGeneratingInitializationVectorTest.php
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\FailedGeneratingInitializationVector; | ||
use LogicException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FailedGeneratingInitializationVectorTest extends TestCase | ||
{ | ||
private int $length; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->length = 16; | ||
} | ||
|
||
public function testCanBeCreated(): void | ||
{ | ||
$exception = new FailedGeneratingInitializationVector($this->length); | ||
|
||
$this->assertInstanceOf(FailedGeneratingInitializationVector::class, $exception); | ||
} | ||
|
||
public function testReturnsLength(): void | ||
{ | ||
$exception = new FailedGeneratingInitializationVector($this->length); | ||
|
||
$this->assertEquals($this->length, $exception->getLength()); | ||
} | ||
|
||
public function testPreviousExceptionIsStored(): void | ||
{ | ||
$previous = new LogicException('Previous exception'); | ||
$exception = new FailedGeneratingInitializationVector($this->length, $previous); | ||
|
||
$this->assertSame($previous, $exception->getPrevious()); | ||
} | ||
|
||
public function testImplementsCipherExceptionInterface(): void | ||
{ | ||
$exception = new FailedGeneratingInitializationVector($this->length); | ||
|
||
$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
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