2727
2828use OC \User \Manager ;
2929use OCA \Files_Versions \Command \CleanUp ;
30+ use OCP \Files \Cache \ICache ;
31+ use OCP \Files \Folder ;
3032use OCP \Files \IRootFolder ;
33+ use OCP \Files \Storage \IStorage ;
3134use Test \TestCase ;
3235
3336/**
@@ -48,16 +51,20 @@ class CleanupTest extends TestCase {
4851 /** @var \PHPUnit\Framework\MockObject\MockObject | IRootFolder */
4952 protected $ rootFolder ;
5053
54+ /** @var \PHPUnit\Framework\MockObject\MockObject | VersionsMapper */
55+ protected $ versionMapper ;
56+
5157 protected function setUp (): void {
5258 parent ::setUp ();
5359
5460 $ this ->rootFolder = $ this ->getMockBuilder ('OCP\Files\IRootFolder ' )
5561 ->disableOriginalConstructor ()->getMock ();
5662 $ this ->userManager = $ this ->getMockBuilder ('OC\User\Manager ' )
5763 ->disableOriginalConstructor ()->getMock ();
64+ $ this ->versionMapper = $ this ->getMockBuilder ('OCA\Files_Versions\Db\VersionsMapper ' )
65+ ->disableOriginalConstructor ()->getMock ();
5866
59-
60- $ this ->cleanup = new CleanUp ($ this ->rootFolder , $ this ->userManager );
67+ $ this ->cleanup = new CleanUp ($ this ->rootFolder , $ this ->userManager , $ this ->versionMapper );
6168 }
6269
6370 /**
@@ -70,6 +77,21 @@ public function testDeleteVersions($nodeExists) {
7077 ->with ('/testUser/files_versions ' )
7178 ->willReturn ($ nodeExists );
7279
80+ $ userFolder = $ this ->createMock (Folder::class);
81+ $ userHomeStorage = $ this ->createMock (IStorage::class);
82+ $ userHomeStorageCache = $ this ->createMock (ICache::class);
83+ $ this ->rootFolder ->expects ($ this ->once ())
84+ ->method ('getUserFolder ' )
85+ ->willReturn ($ userFolder );
86+ $ userFolder ->expects ($ this ->once ())
87+ ->method ('getStorage ' )
88+ ->willReturn ($ userHomeStorage );
89+ $ userHomeStorage ->expects ($ this ->once ())
90+ ->method ('getCache ' )
91+ ->willReturn ($ userHomeStorageCache );
92+ $ userHomeStorageCache ->expects ($ this ->once ())
93+ ->method ('getNumericStorageId ' )
94+ ->willReturn (1 );
7395
7496 if ($ nodeExists ) {
7597 $ this ->rootFolder ->expects ($ this ->once ())
@@ -104,7 +126,7 @@ public function testExecuteDeleteListOfUsers() {
104126
105127 $ instance = $ this ->getMockBuilder ('OCA\Files_Versions\Command\CleanUp ' )
106128 ->setMethods (['deleteVersions ' ])
107- ->setConstructorArgs ([$ this ->rootFolder , $ this ->userManager ])
129+ ->setConstructorArgs ([$ this ->rootFolder , $ this ->userManager , $ this -> versionMapper ])
108130 ->getMock ();
109131 $ instance ->expects ($ this ->exactly (count ($ userIds )))
110132 ->method ('deleteVersions ' )
@@ -136,7 +158,7 @@ public function testExecuteAllUsers() {
136158
137159 $ instance = $ this ->getMockBuilder ('OCA\Files_Versions\Command\CleanUp ' )
138160 ->setMethods (['deleteVersions ' ])
139- ->setConstructorArgs ([$ this ->rootFolder , $ this ->userManager ])
161+ ->setConstructorArgs ([$ this ->rootFolder , $ this ->userManager , $ this -> versionMapper ])
140162 ->getMock ();
141163
142164 $ backend = $ this ->getMockBuilder (\OCP \UserInterface::class)
0 commit comments