@@ 76-88 (lines=13) @@ | ||
73 | /** |
|
74 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
75 | */ |
|
76 | public function testEncryptWithKeyEncryptsPlaintextThrowsException() |
|
77 | { |
|
78 | try { |
|
79 | $this->encryption->expects($this->once()) |
|
80 | ->method('encryptWithKey') |
|
81 | ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
|
82 | ->getMock()) |
|
83 | ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
84 | } catch (EnvironmentIsBrokenException $e) { |
|
85 | $this->throwException(new CryptoException()); |
|
86 | } |
|
87 | ||
88 | $this->wrapper->encryptWithKey('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
|
89 | ->getMock()); |
|
90 | } |
|
91 | ||
@@ 112-124 (lines=13) @@ | ||
109 | /** |
|
110 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
111 | */ |
|
112 | public function testDecryptWithKeyDecryptsCiphertextThrowsException() |
|
113 | { |
|
114 | try { |
|
115 | $this->encryption->expects($this->once()) |
|
116 | ->method('decryptWithKey') |
|
117 | ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
|
118 | ->getMock()) |
|
119 | ->will($this->throwException(new BaseCryptoException())); |
|
120 | } catch (BaseCryptoException $e) { |
|
121 | $this->throwException(new CryptoException()); |
|
122 | } |
|
123 | ||
124 | $this->wrapper->decryptWithKey('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
|
125 | ->getMock()); |
|
126 | } |
|
127 |