--- /dev/null
+<?php
+/**
+ * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Command;
+
+use OCP\IUser;
+
+trait FileAccess {
+ protected function getUserFolder(IUser $user) {
+ \OC_Util::setupFS($user->getUID());
+ return \OC::$server->getUserFolder($user->getUID());
+ }
+}
namespace Test\Command;
+use OC\Command\FileAccess;
use OCP\Command\ICommand;
use Test\BackgroundJob\DummyJobList;
use Test\TestCase;
}
}
+class FilesystemCommand implements ICommand {
+ use FileAccess;
+
+ public function handle() {
+ AsyncBus::$lastCommand = 'FileAccess';
+ }
+}
+
function basicFunction() {
AsyncBus::$lastCommand = 'function';
}
$this->assertEquals('closure-bar', self::$lastCommand);
}
+ public function testFileFileAccessCommand() {
+ $this->bus->push(new FilesystemCommand());
+ $this->assertEquals('', self::$lastCommand);
+ $this->runJobs();
+ $this->assertEquals('FileAccess', self::$lastCommand);
+ }
+
+ public function testFileFileAccessCommandSync() {
+ $this->bus->requireSync('\OC\Command\FileAccess');
+ $this->bus->push(new FilesystemCommand());
+ $this->assertEquals('FileAccess', self::$lastCommand);
+ self::$lastCommand = '';
+ $this->runJobs();
+ $this->assertEquals('', self::$lastCommand);
+ }
+
private function runJobs() {
$jobs = $this->jobList->getAll();