diff --git a/core/Command/Encryption/ChangeKeyStorageRoot.php b/core/Command/Encryption/ChangeKeyStorageRoot.php index 4ab4e6ecdeb1..7340df6bab63 100644 --- a/core/Command/Encryption/ChangeKeyStorageRoot.php +++ b/core/Command/Encryption/ChangeKeyStorageRoot.php @@ -136,7 +136,8 @@ protected function moveAllKeys($oldRoot, $newRoot, OutputInterface $output) { * @throws \Exception */ protected function prepareNewRoot($newRoot) { - if ($this->rootView->is_dir($newRoot) === false) { + $validateNewRootDir = $this->rootView->is_dir($newRoot); + if (($validateNewRootDir === false) or ($validateNewRootDir === null)) { throw new \Exception("New root folder doesn't exist. Please create the folder or check the permissions and try again."); } @@ -151,7 +152,6 @@ protected function prepareNewRoot($newRoot) { } - /** * move system key folder * diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index d08e5a356866..ad384ec755e8 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -200,6 +200,24 @@ public function dataTestPrepareNewRootException() { ]; } + public function nulldir() { + return [ + [null] + ]; + } + + /** + * @dataProvider nulldir + * @expectedException \Exception + * @expectedExceptionMessage New root folder doesn't exist. Please create the folder or check the permissions and try again. + * @param $dirExists + */ + public function testPrepareNewRootExceptionForNullDir($dirExists) { + $this->view->expects($this->once())->method('is_dir')->with('../../newRoot') + ->willReturn($dirExists); + $this->invokePrivate($this->changeKeyStorageRoot, 'prepareNewRoot', ['../../newRoot']); + } + /** * @dataProvider dataTestMoveSystemKeys *