|
@@ 138-152 (lines=15) @@
|
| 135 |
|
/** |
| 136 |
|
* @throws CryptoException |
| 137 |
|
*/ |
| 138 |
|
public function testEncryptFileWithKeyEncryptsFile() |
| 139 |
|
{ |
| 140 |
|
$this->encryption->expects($this->once()) |
| 141 |
|
->method('encryptFileWithKey') |
| 142 |
|
->will($this->returnCallback(function ($input, $output) { |
| 143 |
|
$fs = new Filesystem(); |
| 144 |
|
$fs->dumpFile($output, ''); |
| 145 |
|
})); |
| 146 |
|
|
| 147 |
|
$this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface') |
| 148 |
|
->getMock()); |
| 149 |
|
|
| 150 |
|
$this->assertFileExists(__DIR__.'/file.crypto'); |
| 151 |
|
|
| 152 |
|
unlink(__DIR__.'/file.crypto'); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
/** |
|
@@ 282-296 (lines=15) @@
|
| 279 |
|
* ============================================ |
| 280 |
|
*/ |
| 281 |
|
|
| 282 |
|
public function testEncryptFileWithPasswordEncryptsFile() |
| 283 |
|
{ |
| 284 |
|
$this->encryption->expects($this->once()) |
| 285 |
|
->method('encryptFileWithPassword') |
| 286 |
|
->will($this->returnCallback(function ($input, $output, $password) { |
| 287 |
|
$fs = new Filesystem(); |
| 288 |
|
$fs->dumpFile($output, ''); |
| 289 |
|
})); |
| 290 |
|
|
| 291 |
|
$this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
| 292 |
|
|
| 293 |
|
$this->assertFileExists(__DIR__.'/file.crypto'); |
| 294 |
|
|
| 295 |
|
unlink(__DIR__.'/file.crypto'); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
/** |
| 299 |
|
* @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |