@@ 117-131 (lines=15) @@ | ||
114 | /** |
|
115 | * @throws \Mes\Security\CryptoBundle\Exception\CryptoException |
|
116 | */ |
|
117 | public function testEncryptWithKeyFileEncryptsFile() |
|
118 | { |
|
119 | $this->encryption->expects($this->once()) |
|
120 | ->method('encryptFileWithKey') |
|
121 | ->will($this->returnCallback(function ($input, $output) { |
|
122 | $fs = new Filesystem(); |
|
123 | $fs->dumpFile($output, ''); |
|
124 | })); |
|
125 | ||
126 | $this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
|
127 | ||
128 | $this->assertFileExists(__DIR__.'/file.crypto'); |
|
129 | ||
130 | unlink(__DIR__.'/file.crypto'); |
|
131 | } |
|
132 | ||
133 | /** |
|
134 | * @throws \Mes\Security\CryptoBundle\Exception\CryptoException |
|
@@ 243-257 (lines=15) @@ | ||
240 | $this->wrapper->decryptWithPassword('ThisIsACipherText', 'SuperSecretPa$$word'); |
|
241 | } |
|
242 | ||
243 | public function testEncryptFileWithPasswordEncryptsFile() |
|
244 | { |
|
245 | $this->encryption->expects($this->once()) |
|
246 | ->method('encryptFileWithPassword') |
|
247 | ->will($this->returnCallback(function ($input, $output, $password) { |
|
248 | $fs = new Filesystem(); |
|
249 | $fs->dumpFile($output, ''); |
|
250 | })); |
|
251 | ||
252 | $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
|
253 | ||
254 | $this->assertFileExists(__DIR__.'/file.crypto'); |
|
255 | ||
256 | unlink(__DIR__.'/file.crypto'); |
|
257 | } |
|
258 | ||
259 | /** |
|
260 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |