Skip to content

Commit

Permalink
Adapt test to modern getMount()
Browse files Browse the repository at this point in the history
MountManager->getMount() is not throwing an error instead of returning
null.

This commit makes sure that we handle properly the cases of un-existing
mount.

Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed May 11, 2023
1 parent dcb12e4 commit c9c7545
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,12 @@ protected function shareNotificationForOriginalOwners($currentOwner, $subject, $
* Get the sharee who shared the item with the currentUser
*/
$this->view->chroot('/' . $currentOwner . '/files');
$mount = $this->view->getMount($path);
if (!($mount instanceof IMountPoint)) {

try {
$mount = $this->view->getMount($path);
} catch (OCP\Files\NotFoundException $ex) {
return;
} catch (Exception $ex) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/FilesHooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ public function testShareNotificationForOriginalOwners(bool $validMountPoint, bo
$this->view->expects($this->once())
->method('getMount')
->with('/path')
->willReturn(null);
->willThrowException(new \OCP\Files\NotFoundException());
}

self::invokePrivate($filesHooks, 'shareNotificationForOriginalOwners', ['current', 'subject', 'with', 42, 'type']);
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
define('PHPUNIT_RUN', 1);
}

require_once __DIR__.'/../../../lib/base.php';
require_once __DIR__.'/../../../instances/server1/lib/base.php';

// Fix for "Autoload path not allowed: .../tests/lib/testcase.php"
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
Expand Down

0 comments on commit c9c7545

Please sign in to comment.