2727use OCA \Files_Versions \Sabre \VersionFile ;
2828use OCA \Files_Versions \Versions \IVersion ;
2929use OCP \Files \File ;
30+ use OCP \Files \Folder ;
3031use OCP \Files \Storage \IStorage ;
32+ use OCP \IUser ;
3133use OCP \Share \IAttributes ;
3234use OCP \Share \IShare ;
33- use Psr \Log \LoggerInterface ;
3435use Sabre \DAV \Server ;
3536use Sabre \DAV \Tree ;
3637use Sabre \HTTP \RequestInterface ;
@@ -43,10 +44,13 @@ class ViewOnlyPluginTest extends TestCase {
4344 private $ tree ;
4445 /** @var RequestInterface | \PHPUnit\Framework\MockObject\MockObject */
4546 private $ request ;
47+ /** @var Folder | \PHPUnit\Framework\MockObject\MockObject */
48+ private $ userFolder ;
4649
4750 public function setUp (): void {
51+ $ this ->userFolder = $ this ->createMock (Folder::class);
4852 $ this ->plugin = new ViewOnlyPlugin (
49- $ this ->createMock (LoggerInterface::class)
53+ $ this ->userFolder ,
5054 );
5155 $ this ->request = $ this ->createMock (RequestInterface::class);
5256 $ this ->tree = $ this ->createMock (Tree::class);
@@ -111,6 +115,26 @@ public function testCanGet(bool $isVersion, ?bool $attrEnabled, bool $expectCanD
111115 $ davNode ->expects ($ this ->once ())
112116 ->method ('getVersion ' )
113117 ->willReturn ($ version );
118+
119+ $ currentUser = $ this ->createMock (IUser::class);
120+ $ currentUser ->expects ($ this ->once ())
121+ ->method ('getUID ' )
122+ ->willReturn ('alice ' );
123+ $ nodeInfo ->expects ($ this ->once ())
124+ ->method ('getOwner ' )
125+ ->willReturn ($ currentUser );
126+
127+ $ nodeInfo = $ this ->createMock (File::class);
128+ $ owner = $ this ->createMock (IUser::class);
129+ $ owner ->expects ($ this ->once ())
130+ ->method ('getUID ' )
131+ ->willReturn ('bob ' );
132+ $ this ->userFolder ->expects ($ this ->once ())
133+ ->method ('getById ' )
134+ ->willReturn ([$ nodeInfo ]);
135+ $ this ->userFolder ->expects ($ this ->once ())
136+ ->method ('getOwner ' )
137+ ->willReturn ($ owner );
114138 } else {
115139 $ davPath = 'files/path/to/file.odt ' ;
116140 $ davNode = $ this ->createMock (DavFile::class);
0 commit comments