|
|
|
|
@ -311,7 +311,10 @@ class DecryptAllTest extends TestCase { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDecryptFile() { |
|
|
|
|
/** |
|
|
|
|
* @dataProvider dataTrueFalse |
|
|
|
|
*/ |
|
|
|
|
public function testDecryptFile($isEncrypted) { |
|
|
|
|
|
|
|
|
|
$path = 'test.txt'; |
|
|
|
|
|
|
|
|
|
@ -327,15 +330,26 @@ class DecryptAllTest extends TestCase { |
|
|
|
|
->setMethods(['getTimestamp']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$instance->expects($this->any())->method('getTimestamp')->willReturn(42); |
|
|
|
|
|
|
|
|
|
$this->view->expects($this->once()) |
|
|
|
|
->method('copy') |
|
|
|
|
->with($path, $path . '.decrypted.42'); |
|
|
|
|
$this->view->expects($this->once()) |
|
|
|
|
->method('rename') |
|
|
|
|
->with($path . '.decrypted.42', $path); |
|
|
|
|
|
|
|
|
|
$fileInfo = $this->createMock(FileInfo::class); |
|
|
|
|
$fileInfo->expects($this->any())->method('isEncrypted') |
|
|
|
|
->willReturn($isEncrypted); |
|
|
|
|
$this->view->expects($this->any())->method('getFileInfo') |
|
|
|
|
->willReturn($fileInfo); |
|
|
|
|
|
|
|
|
|
if ($isEncrypted) { |
|
|
|
|
$instance->expects($this->any())->method('getTimestamp')->willReturn(42); |
|
|
|
|
|
|
|
|
|
$this->view->expects($this->once()) |
|
|
|
|
->method('copy') |
|
|
|
|
->with($path, $path . '.decrypted.42'); |
|
|
|
|
$this->view->expects($this->once()) |
|
|
|
|
->method('rename') |
|
|
|
|
->with($path . '.decrypted.42', $path); |
|
|
|
|
} else { |
|
|
|
|
$instance->expects($this->never())->method('getTimestamp'); |
|
|
|
|
$this->view->expects($this->never())->method('copy'); |
|
|
|
|
$this->view->expects($this->never())->method('rename'); |
|
|
|
|
} |
|
|
|
|
$this->assertTrue( |
|
|
|
|
$this->invokePrivate($instance, 'decryptFile', [$path]) |
|
|
|
|
); |
|
|
|
|
@ -356,6 +370,13 @@ class DecryptAllTest extends TestCase { |
|
|
|
|
->setMethods(['getTimestamp']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fileInfo = $this->createMock(FileInfo::class); |
|
|
|
|
$fileInfo->expects($this->any())->method('isEncrypted') |
|
|
|
|
->willReturn(true); |
|
|
|
|
$this->view->expects($this->any())->method('getFileInfo') |
|
|
|
|
->willReturn($fileInfo); |
|
|
|
|
|
|
|
|
|
$instance->expects($this->any())->method('getTimestamp')->willReturn(42); |
|
|
|
|
|
|
|
|
|
$this->view->expects($this->once()) |
|
|
|
|
|