StorageTest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Stefan Weil <sw@weilnetz.de>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. * @author Vincent Petry <pvince81@owncloud.com>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. namespace OCA\Files_Trashbin\Tests;
  30. use OC\Files\Storage\Temporary;
  31. use OC\Files\Filesystem;
  32. use OCP\ILogger;
  33. /**
  34. * Class Storage
  35. *
  36. * @group DB
  37. *
  38. * @package OCA\Files_Trashbin\Tests
  39. */
  40. class StorageTest extends \Test\TestCase {
  41. /**
  42. * @var string
  43. */
  44. private $user;
  45. /**
  46. * @var \OC\Files\View
  47. */
  48. private $rootView;
  49. /**
  50. * @var \OC\Files\View
  51. */
  52. private $userView;
  53. protected function setUp() {
  54. parent::setUp();
  55. \OC_Hook::clear();
  56. \OCA\Files_Trashbin\Trashbin::registerHooks();
  57. $this->user = $this->getUniqueId('user');
  58. \OC::$server->getUserManager()->createUser($this->user, $this->user);
  59. // this will setup the FS
  60. $this->loginAsUser($this->user);
  61. \OCA\Files_Trashbin\Storage::setupStorage();
  62. $this->rootView = new \OC\Files\View('/');
  63. $this->userView = new \OC\Files\View('/' . $this->user . '/files/');
  64. $this->userView->file_put_contents('test.txt', 'foo');
  65. $this->userView->mkdir('folder');
  66. $this->userView->file_put_contents('folder/inside.txt', 'bar');
  67. }
  68. protected function tearDown() {
  69. \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
  70. $this->logout();
  71. $user = \OC::$server->getUserManager()->get($this->user);
  72. if ($user !== null) { $user->delete(); }
  73. \OC_Hook::clear();
  74. parent::tearDown();
  75. }
  76. /**
  77. * Test that deleting a file puts it into the trashbin.
  78. */
  79. public function testSingleStorageDeleteFile() {
  80. $this->assertTrue($this->userView->file_exists('test.txt'));
  81. $this->userView->unlink('test.txt');
  82. list($storage,) = $this->userView->resolvePath('test.txt');
  83. $storage->getScanner()->scan(''); // make sure we check the storage
  84. $this->assertFalse($this->userView->getFileInfo('test.txt'));
  85. // check if file is in trashbin
  86. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
  87. $this->assertEquals(1, count($results));
  88. $name = $results[0]->getName();
  89. $this->assertEquals('test.txt', substr($name, 0, strrpos($name, '.')));
  90. }
  91. /**
  92. * Test that deleting a folder puts it into the trashbin.
  93. */
  94. public function testSingleStorageDeleteFolder() {
  95. $this->assertTrue($this->userView->file_exists('folder/inside.txt'));
  96. $this->userView->rmdir('folder');
  97. list($storage,) = $this->userView->resolvePath('folder/inside.txt');
  98. $storage->getScanner()->scan(''); // make sure we check the storage
  99. $this->assertFalse($this->userView->getFileInfo('folder'));
  100. // check if folder is in trashbin
  101. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
  102. $this->assertEquals(1, count($results));
  103. $name = $results[0]->getName();
  104. $this->assertEquals('folder', substr($name, 0, strrpos($name, '.')));
  105. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/' . $name . '/');
  106. $this->assertEquals(1, count($results));
  107. $name = $results[0]->getName();
  108. $this->assertEquals('inside.txt', $name);
  109. }
  110. /**
  111. * Test that deleting a file from another mounted storage properly
  112. * lands in the trashbin. This is a cross-storage situation because
  113. * the trashbin folder is in the root storage while the mounted one
  114. * isn't.
  115. */
  116. public function testCrossStorageDeleteFile() {
  117. $storage2 = new Temporary(array());
  118. \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
  119. $this->userView->file_put_contents('substorage/subfile.txt', 'foo');
  120. $storage2->getScanner()->scan('');
  121. $this->assertTrue($storage2->file_exists('subfile.txt'));
  122. $this->userView->unlink('substorage/subfile.txt');
  123. $storage2->getScanner()->scan('');
  124. $this->assertFalse($this->userView->getFileInfo('substorage/subfile.txt'));
  125. $this->assertFalse($storage2->file_exists('subfile.txt'));
  126. // check if file is in trashbin
  127. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  128. $this->assertEquals(1, count($results));
  129. $name = $results[0]->getName();
  130. $this->assertEquals('subfile.txt', substr($name, 0, strrpos($name, '.')));
  131. }
  132. /**
  133. * Test that deleting a folder from another mounted storage properly
  134. * lands in the trashbin. This is a cross-storage situation because
  135. * the trashbin folder is in the root storage while the mounted one
  136. * isn't.
  137. */
  138. public function testCrossStorageDeleteFolder() {
  139. $storage2 = new Temporary(array());
  140. \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
  141. $this->userView->mkdir('substorage/folder');
  142. $this->userView->file_put_contents('substorage/folder/subfile.txt', 'bar');
  143. $storage2->getScanner()->scan('');
  144. $this->assertTrue($storage2->file_exists('folder/subfile.txt'));
  145. $this->userView->rmdir('substorage/folder');
  146. $storage2->getScanner()->scan('');
  147. $this->assertFalse($this->userView->getFileInfo('substorage/folder'));
  148. $this->assertFalse($storage2->file_exists('folder/subfile.txt'));
  149. // check if folder is in trashbin
  150. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  151. $this->assertEquals(1, count($results));
  152. $name = $results[0]->getName();
  153. $this->assertEquals('folder', substr($name, 0, strrpos($name, '.')));
  154. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/' . $name . '/');
  155. $this->assertEquals(1, count($results));
  156. $name = $results[0]->getName();
  157. $this->assertEquals('subfile.txt', $name);
  158. }
  159. /**
  160. * Test that deleted versions properly land in the trashbin.
  161. */
  162. public function testDeleteVersionsOfFile() {
  163. \OCA\Files_Versions\Hooks::connectHooks();
  164. // trigger a version (multiple would not work because of the expire logic)
  165. $this->userView->file_put_contents('test.txt', 'v1');
  166. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/');
  167. $this->assertEquals(1, count($results));
  168. $this->userView->unlink('test.txt');
  169. // rescan trash storage
  170. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  171. $rootStorage->getScanner()->scan('');
  172. // check if versions are in trashbin
  173. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions');
  174. $this->assertEquals(1, count($results));
  175. $name = $results[0]->getName();
  176. $this->assertEquals('test.txt.v', substr($name, 0, strlen('test.txt.v')));
  177. // versions deleted
  178. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/');
  179. $this->assertEquals(0, count($results));
  180. }
  181. /**
  182. * Test that deleted versions properly land in the trashbin.
  183. */
  184. public function testDeleteVersionsOfFolder() {
  185. \OCA\Files_Versions\Hooks::connectHooks();
  186. // trigger a version (multiple would not work because of the expire logic)
  187. $this->userView->file_put_contents('folder/inside.txt', 'v1');
  188. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/folder/');
  189. $this->assertEquals(1, count($results));
  190. $this->userView->rmdir('folder');
  191. // rescan trash storage
  192. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  193. $rootStorage->getScanner()->scan('');
  194. // check if versions are in trashbin
  195. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions');
  196. $this->assertEquals(1, count($results));
  197. $name = $results[0]->getName();
  198. $this->assertEquals('folder.d', substr($name, 0, strlen('folder.d')));
  199. // check if versions are in trashbin
  200. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/' . $name . '/');
  201. $this->assertEquals(1, count($results));
  202. $name = $results[0]->getName();
  203. $this->assertEquals('inside.txt.v', substr($name, 0, strlen('inside.txt.v')));
  204. // versions deleted
  205. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/folder/');
  206. $this->assertEquals(0, count($results));
  207. }
  208. /**
  209. * Test that deleted versions properly land in the trashbin when deleting as share recipient.
  210. */
  211. public function testDeleteVersionsOfFileAsRecipient() {
  212. \OCA\Files_Versions\Hooks::connectHooks();
  213. $this->userView->mkdir('share');
  214. // trigger a version (multiple would not work because of the expire logic)
  215. $this->userView->file_put_contents('share/test.txt', 'v1');
  216. $this->userView->file_put_contents('share/test.txt', 'v2');
  217. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/share/');
  218. $this->assertEquals(1, count($results));
  219. $recipientUser = $this->getUniqueId('recipient_');
  220. \OC::$server->getUserManager()->createUser($recipientUser, $recipientUser);
  221. $node = \OC::$server->getUserFolder($this->user)->get('share');
  222. $share = \OC::$server->getShareManager()->newShare();
  223. $share->setNode($node)
  224. ->setShareType(\OCP\Share::SHARE_TYPE_USER)
  225. ->setSharedBy($this->user)
  226. ->setSharedWith($recipientUser)
  227. ->setPermissions(\OCP\Constants::PERMISSION_ALL);
  228. \OC::$server->getShareManager()->createShare($share);
  229. $this->loginAsUser($recipientUser);
  230. // delete as recipient
  231. $recipientView = new \OC\Files\View('/' . $recipientUser . '/files');
  232. $recipientView->unlink('share/test.txt');
  233. // rescan trash storage for both users
  234. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  235. $rootStorage->getScanner()->scan('');
  236. // check if versions are in trashbin for both users
  237. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions');
  238. $this->assertEquals(1, count($results), 'Versions in owner\'s trashbin');
  239. $name = $results[0]->getName();
  240. $this->assertEquals('test.txt.v', substr($name, 0, strlen('test.txt.v')));
  241. $results = $this->rootView->getDirectoryContent($recipientUser . '/files_trashbin/versions');
  242. $this->assertEquals(1, count($results), 'Versions in recipient\'s trashbin');
  243. $name = $results[0]->getName();
  244. $this->assertEquals('test.txt.v', substr($name, 0, strlen('test.txt.v')));
  245. // versions deleted
  246. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/share/');
  247. $this->assertEquals(0, count($results));
  248. }
  249. /**
  250. * Test that deleted versions properly land in the trashbin when deleting as share recipient.
  251. */
  252. public function testDeleteVersionsOfFolderAsRecipient() {
  253. \OCA\Files_Versions\Hooks::connectHooks();
  254. $this->userView->mkdir('share');
  255. $this->userView->mkdir('share/folder');
  256. // trigger a version (multiple would not work because of the expire logic)
  257. $this->userView->file_put_contents('share/folder/test.txt', 'v1');
  258. $this->userView->file_put_contents('share/folder/test.txt', 'v2');
  259. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/share/folder/');
  260. $this->assertEquals(1, count($results));
  261. $recipientUser = $this->getUniqueId('recipient_');
  262. \OC::$server->getUserManager()->createUser($recipientUser, $recipientUser);
  263. $node = \OC::$server->getUserFolder($this->user)->get('share');
  264. $share = \OC::$server->getShareManager()->newShare();
  265. $share->setNode($node)
  266. ->setShareType(\OCP\Share::SHARE_TYPE_USER)
  267. ->setSharedBy($this->user)
  268. ->setSharedWith($recipientUser)
  269. ->setPermissions(\OCP\Constants::PERMISSION_ALL);
  270. \OC::$server->getShareManager()->createShare($share);
  271. $this->loginAsUser($recipientUser);
  272. // delete as recipient
  273. $recipientView = new \OC\Files\View('/' . $recipientUser . '/files');
  274. $recipientView->rmdir('share/folder');
  275. // rescan trash storage
  276. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  277. $rootStorage->getScanner()->scan('');
  278. // check if versions are in trashbin for owner
  279. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions');
  280. $this->assertEquals(1, count($results));
  281. $name = $results[0]->getName();
  282. $this->assertEquals('folder.d', substr($name, 0, strlen('folder.d')));
  283. // check if file versions are in trashbin for owner
  284. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/' . $name . '/');
  285. $this->assertEquals(1, count($results));
  286. $name = $results[0]->getName();
  287. $this->assertEquals('test.txt.v', substr($name, 0, strlen('test.txt.v')));
  288. // check if versions are in trashbin for recipient
  289. $results = $this->rootView->getDirectoryContent($recipientUser . '/files_trashbin/versions');
  290. $this->assertEquals(1, count($results));
  291. $name = $results[0]->getName();
  292. $this->assertEquals('folder.d', substr($name, 0, strlen('folder.d')));
  293. // check if file versions are in trashbin for recipient
  294. $results = $this->rootView->getDirectoryContent($recipientUser . '/files_trashbin/versions/' . $name . '/');
  295. $this->assertEquals(1, count($results));
  296. $name = $results[0]->getName();
  297. $this->assertEquals('test.txt.v', substr($name, 0, strlen('test.txt.v')));
  298. // versions deleted
  299. $results = $this->rootView->getDirectoryContent($recipientUser . '/files_versions/share/folder/');
  300. $this->assertEquals(0, count($results));
  301. }
  302. /**
  303. * Test that versions are not auto-trashed when moving a file between
  304. * storages. This is because rename() between storages would call
  305. * unlink() which should NOT trigger the version deletion logic.
  306. */
  307. public function testKeepFileAndVersionsWhenMovingFileBetweenStorages() {
  308. \OCA\Files_Versions\Hooks::connectHooks();
  309. $storage2 = new Temporary(array());
  310. \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
  311. // trigger a version (multiple would not work because of the expire logic)
  312. $this->userView->file_put_contents('test.txt', 'v1');
  313. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  314. $this->assertEquals(0, count($results));
  315. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/');
  316. $this->assertEquals(1, count($results));
  317. // move to another storage
  318. $this->userView->rename('test.txt', 'substorage/test.txt');
  319. $this->assertTrue($this->userView->file_exists('substorage/test.txt'));
  320. // rescan trash storage
  321. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  322. $rootStorage->getScanner()->scan('');
  323. // versions were moved too
  324. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/substorage');
  325. $this->assertEquals(1, count($results));
  326. // check that nothing got trashed by the rename's unlink() call
  327. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  328. $this->assertEquals(0, count($results));
  329. // check that versions were moved and not trashed
  330. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/');
  331. $this->assertEquals(0, count($results));
  332. }
  333. /**
  334. * Test that versions are not auto-trashed when moving a file between
  335. * storages. This is because rename() between storages would call
  336. * unlink() which should NOT trigger the version deletion logic.
  337. */
  338. public function testKeepFileAndVersionsWhenMovingFolderBetweenStorages() {
  339. \OCA\Files_Versions\Hooks::connectHooks();
  340. $storage2 = new Temporary(array());
  341. \OC\Files\Filesystem::mount($storage2, array(), $this->user . '/files/substorage');
  342. // trigger a version (multiple would not work because of the expire logic)
  343. $this->userView->file_put_contents('folder/inside.txt', 'v1');
  344. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  345. $this->assertEquals(0, count($results));
  346. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/folder/');
  347. $this->assertEquals(1, count($results));
  348. // move to another storage
  349. $this->userView->rename('folder', 'substorage/folder');
  350. $this->assertTrue($this->userView->file_exists('substorage/folder/inside.txt'));
  351. // rescan trash storage
  352. list($rootStorage,) = $this->rootView->resolvePath($this->user . '/files_trashbin');
  353. $rootStorage->getScanner()->scan('');
  354. // versions were moved too
  355. $results = $this->rootView->getDirectoryContent($this->user . '/files_versions/substorage/folder/');
  356. $this->assertEquals(1, count($results));
  357. // check that nothing got trashed by the rename's unlink() call
  358. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files');
  359. $this->assertEquals(0, count($results));
  360. // check that versions were moved and not trashed
  361. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/versions/');
  362. $this->assertEquals(0, count($results));
  363. }
  364. /**
  365. * Delete should fail if the source file can't be deleted.
  366. */
  367. public function testSingleStorageDeleteFileFail() {
  368. /**
  369. * @var \OC\Files\Storage\Temporary | \PHPUnit_Framework_MockObject_MockObject $storage
  370. */
  371. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  372. ->setConstructorArgs([[]])
  373. ->setMethods(['rename', 'unlink', 'moveFromStorage'])
  374. ->getMock();
  375. $storage->expects($this->any())
  376. ->method('rename')
  377. ->will($this->returnValue(false));
  378. $storage->expects($this->any())
  379. ->method('moveFromStorage')
  380. ->will($this->returnValue(false));
  381. $storage->expects($this->any())
  382. ->method('unlink')
  383. ->will($this->returnValue(false));
  384. $cache = $storage->getCache();
  385. Filesystem::mount($storage, [], '/' . $this->user);
  386. $storage->mkdir('files');
  387. $this->userView->file_put_contents('test.txt', 'foo');
  388. $this->assertTrue($storage->file_exists('files/test.txt'));
  389. $this->assertFalse($this->userView->unlink('test.txt'));
  390. $this->assertTrue($storage->file_exists('files/test.txt'));
  391. $this->assertTrue($cache->inCache('files/test.txt'));
  392. // file should not be in the trashbin
  393. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
  394. $this->assertEquals(0, count($results));
  395. }
  396. /**
  397. * Delete should fail if the source folder can't be deleted.
  398. */
  399. public function testSingleStorageDeleteFolderFail() {
  400. /**
  401. * @var \OC\Files\Storage\Temporary | \PHPUnit_Framework_MockObject_MockObject $storage
  402. */
  403. $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  404. ->setConstructorArgs([[]])
  405. ->setMethods(['rename', 'unlink', 'rmdir'])
  406. ->getMock();
  407. $storage->expects($this->any())
  408. ->method('rmdir')
  409. ->will($this->returnValue(false));
  410. $cache = $storage->getCache();
  411. Filesystem::mount($storage, [], '/' . $this->user);
  412. $storage->mkdir('files');
  413. $this->userView->mkdir('folder');
  414. $this->userView->file_put_contents('folder/test.txt', 'foo');
  415. $this->assertTrue($storage->file_exists('files/folder/test.txt'));
  416. $this->assertFalse($this->userView->rmdir('files/folder'));
  417. $this->assertTrue($storage->file_exists('files/folder'));
  418. $this->assertTrue($storage->file_exists('files/folder/test.txt'));
  419. $this->assertTrue($cache->inCache('files/folder'));
  420. $this->assertTrue($cache->inCache('files/folder/test.txt'));
  421. // file should not be in the trashbin
  422. $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/');
  423. $this->assertEquals(0, count($results));
  424. }
  425. /**
  426. * @dataProvider dataTestShouldMoveToTrash
  427. */
  428. public function testShouldMoveToTrash($mountPoint, $path, $userExists, $expected) {
  429. $tmpStorage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
  430. ->disableOriginalConstructor()->getMock();
  431. $userManager = $this->getMockBuilder('OCP\IUserManager')
  432. ->disableOriginalConstructor()->getMock();
  433. $userManager->expects($this->any())
  434. ->method('userExists')->willReturn($userExists);
  435. $logger = $this->getMockBuilder(ILogger::class)->getMock();
  436. $storage = new \OCA\Files_Trashbin\Storage(
  437. ['mountPoint' => $mountPoint, 'storage' => $tmpStorage],
  438. $userManager,
  439. $logger
  440. );
  441. $this->assertSame($expected,
  442. $this->invokePrivate($storage, 'shouldMoveToTrash', [$path])
  443. );
  444. }
  445. public function dataTestShouldMoveToTrash() {
  446. return [
  447. ['/schiesbn/', '/files/test.txt', true, true],
  448. ['/schiesbn/', '/files/test.txt', false, false],
  449. ['/schiesbn/', '/test.txt', true, false],
  450. ['/schiesbn/', '/test.txt', false, false],
  451. ];
  452. }
  453. /**
  454. * Test that deleting a file doesn't error when nobody is logged in
  455. */
  456. public function testSingleStorageDeleteFileLoggedOut() {
  457. $this->logout();
  458. if (!$this->userView->file_exists('test.txt')) {
  459. $this->markTestSkipped('Skipping since the current home storage backend requires the user to logged in');
  460. } else {
  461. $this->userView->unlink('test.txt');
  462. }
  463. }
  464. }