| @@ 70-84 (lines=15) @@ | ||
| 67 | $this->encryption->encrypt('myvalue'); |
|
| 68 | } |
|
| 69 | ||
| 70 | public function testEncrypt() |
|
| 71 | { |
|
| 72 | $unencryptedValue = 'unencrypted_value'; |
|
| 73 | $encryptedValue = 'encrypted_value'; |
|
| 74 | $privateKey = 'private_key'; |
|
| 75 | ||
| 76 | $this->encryption->setPrivateKey($privateKey); |
|
| 77 | ||
| 78 | $this->algorithm->expects($this->once()) |
|
| 79 | ->method('sign') |
|
| 80 | ->with($unencryptedValue, $privateKey) |
|
| 81 | ->will($this->returnValue($encryptedValue)); |
|
| 82 | ||
| 83 | $this->assertSame($encryptedValue, $this->encryption->encrypt($unencryptedValue)); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * @expectedException \RuntimeException |
|
| @@ 98-113 (lines=16) @@ | ||
| 95 | $this->encryption->verify('value', 'signature'); |
|
| 96 | } |
|
| 97 | ||
| 98 | public function testVerify() |
|
| 99 | { |
|
| 100 | $value = 'value'; |
|
| 101 | $signature = 'signature'; |
|
| 102 | $publicKey = 'public_key'; |
|
| 103 | $encryptedValue = 'encrypted_value'; |
|
| 104 | ||
| 105 | $this->encryption->setPublicKey($publicKey); |
|
| 106 | ||
| 107 | $this->algorithm->expects($this->once()) |
|
| 108 | ->method('verify') |
|
| 109 | ->with($value, $signature, $publicKey) |
|
| 110 | ->will($this->returnValue($encryptedValue)); |
|
| 111 | ||
| 112 | $this->encryption->verify($value, $signature); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||