/** * Test exception during final rename in simple upload mode */ public function testSimplePutFailsMoveFromStorage() { $view = new \OC\Files\View('/' . $this->user . '/files'); // simulate situation where the target file is locked $view->lockFile('/test.txt', ILockingProvider::LOCK_EXCLUSIVE); $info = new \OC\Files\FileInfo('/' . $this->user . '/files/test.txt', null, null, array('permissions' => \OCP\Constants::PERMISSION_ALL), null); $file = new \OCA\DAV\Connector\Sabre\File($view, $info); // action $thrown = false; try { // beforeMethod locks $view->lockFile($info->getPath(), ILockingProvider::LOCK_SHARED); $file->put($this->getStream('test data')); // afterMethod unlocks $view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED); } catch (\OCA\DAV\Connector\Sabre\Exception\FileLocked $e) { $thrown = true; } $this->assertTrue($thrown); $this->assertEmpty($this->listPartFiles($view, ''), 'No stray part files'); }