@@ 158-173 (lines=16) @@ | ||
155 | /** |
|
156 | * @throws CryptoException |
|
157 | */ |
|
158 | public function testDecryptFileWithKeyDecryptsEncryptedFile() |
|
159 | { |
|
160 | $this->encryption->expects($this->once()) |
|
161 | ->method('decryptFileWithKey') |
|
162 | ->will($this->returnCallback(function ($input, $output) { |
|
163 | $fs = new Filesystem(); |
|
164 | $fs->dumpFile($output, 'Plain text'); |
|
165 | })); |
|
166 | ||
167 | $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
|
168 | ->getMock()); |
|
169 | ||
170 | $this->assertFileExists(__DIR__.'/file.txt'); |
|
171 | $this->assertContains('Plain text', file_get_contents(__DIR__.'/file.txt')); |
|
172 | ||
173 | unlink(__DIR__.'/file.txt'); |
|
174 | } |
|
175 | ||
176 | /** |
|
@@ 314-329 (lines=16) @@ | ||
311 | $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
|
312 | } |
|
313 | ||
314 | public function testDecryptFileWithPasswordDecryptsEncryptedFile() |
|
315 | { |
|
316 | $this->encryption->expects($this->once()) |
|
317 | ->method('decryptFileWithPassword') |
|
318 | ->will($this->returnCallback(function ($input, $output, $password) { |
|
319 | $fs = new Filesystem(); |
|
320 | $fs->dumpFile($output, 'Plain text'); |
|
321 | })); |
|
322 | ||
323 | $this->wrapper->decryptFileWithPassword(__DIR__.'/file.crypto', __DIR__.'/file.txt', 'SuperSecretPa$$word'); |
|
324 | ||
325 | $this->assertFileExists(__DIR__.'/file.txt'); |
|
326 | $this->assertContains('Plain text', file_get_contents(__DIR__.'/file.txt')); |
|
327 | ||
328 | unlink(__DIR__.'/file.txt'); |
|
329 | } |
|
330 | ||
331 | /** |
|
332 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |