@@ 136-151 (lines=16) @@ | ||
133 | /** |
|
134 | * @throws \Mes\Security\CryptoBundle\Exception\CryptoException |
|
135 | */ |
|
136 | public function testDecryptWithKeyFileDecryptsEncryptedFile() |
|
137 | { |
|
138 | $this->encryption->expects($this->once()) |
|
139 | ->method('decryptFileWithKey') |
|
140 | ->will($this->returnCallback(function ($input, $output) { |
|
141 | $fs = new Filesystem(); |
|
142 | $fs->dumpFile($output, 'Plain text'); |
|
143 | })); |
|
144 | ||
145 | $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
|
146 | ||
147 | $this->assertFileExists(__DIR__.'/file.txt'); |
|
148 | $this->assertContains('Plain text', file_get_contents(__DIR__.'/file.txt')); |
|
149 | ||
150 | unlink(__DIR__.'/file.txt'); |
|
151 | } |
|
152 | ||
153 | /** |
|
154 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
@@ 275-290 (lines=16) @@ | ||
272 | $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
|
273 | } |
|
274 | ||
275 | public function testDecryptFileWithPasswordDecryptsEncryptedFile() |
|
276 | { |
|
277 | $this->encryption->expects($this->once()) |
|
278 | ->method('decryptFileWithPassword') |
|
279 | ->will($this->returnCallback(function ($input, $output, $password) { |
|
280 | $fs = new Filesystem(); |
|
281 | $fs->dumpFile($output, 'Plain text'); |
|
282 | })); |
|
283 | ||
284 | $this->wrapper->decryptFileWithPassword(__DIR__.'/file.crypto', __DIR__.'/file.txt', 'SuperSecretPa$$word'); |
|
285 | ||
286 | $this->assertFileExists(__DIR__.'/file.txt'); |
|
287 | $this->assertContains('Plain text', file_get_contents(__DIR__.'/file.txt')); |
|
288 | ||
289 | unlink(__DIR__.'/file.txt'); |
|
290 | } |
|
291 | ||
292 | /** |
|
293 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |