本文整理汇总了PHP中OC_User::setUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::setUserId方法的具体用法?PHP OC_User::setUserId怎么用?PHP OC_User::setUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::setUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable on travis');
}
\OC_App::disable('files_sharing');
\OC_App::disable('files_versions');
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
\OC_User::deleteUser($userName);
\OC_User::createUser($userName, $userName);
}
// main test user
$userName = 'test';
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$testContainer = 'oc-test-container-' . substr(md5(rand()), 0, 7);
$params = array('username' => 'facebook100000330192569', 'password' => 'Dbdj1sXnRSHxIGc4', 'container' => $testContainer, 'autocreate' => true, 'region' => 'RegionOne', 'url' => 'http://8.21.28.222:5000/v2.0', 'tenantName' => 'facebook100000330192569', 'serviceName' => 'swift', 'user' => \OC_User::getManager()->get($userName));
$this->objectStorage = new ObjectStoreToTest($params);
$params['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($params);
}
示例2: testGet
/**
* @dataProvider getData
*/
public function testGet($user, $start, $count, $expected)
{
$_GET['start'] = $start;
$_GET['count'] = $count;
\OC_User::setUserId($user);
$sessionUser = \OC::$server->getUserSession()->getUser();
$this->assertInstanceOf('OCP\\IUser', $sessionUser);
$this->assertEquals($user, $sessionUser->getUID());
$activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
$activityManager->registerExtension(function () {
return new Extension(\OCP\Util::getL10N('activity', 'en'), $this->getMock('\\OCP\\IURLGenerator'));
});
$this->overwriteService('ActivityManager', $activityManager);
$result = \OCA\Activity\Api::get(array('_route' => 'get_cloud_activity'));
$this->restoreService('ActivityManager');
$this->assertEquals(100, $result->getStatusCode());
$data = $result->getData();
$this->assertEquals(sizeof($expected), sizeof($data));
while (!empty($expected)) {
$assertExpected = array_shift($expected);
$assertData = array_shift($data);
foreach ($assertExpected as $key => $value) {
$this->assertArrayHasKey($key, $assertData);
if ($value !== null) {
$this->assertEquals($value, $assertData[$key]);
}
}
}
}
示例3: setUp
protected function setUp()
{
parent::setUp();
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable in some environments');
}
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
\OC_User::deleteUser($userName);
\OC_User::createUser($userName, $userName);
}
// main test user
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
$this->objectStorage = new ObjectStoreToTest($config['arguments']);
$config['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($config);
}
示例4: testBasic
function testBasic()
{
$uid = uniqid();
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
OC_User::setUserId($uid);
$calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 1);
$this->assertEquals($all[0]['id'], $calId1);
$this->assertEquals($all[0]['displayname'], 'test');
$this->assertEquals($all[0]['uri'], 'test');
$this->assertEquals($uid, $all[0]['userid']);
$calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$this->assertNotEquals($calId1, $calId2);
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 2);
$this->assertEquals($all[1]['id'], $calId2);
$this->assertEquals($all[1]['displayname'], 'test');
$this->assertEquals($all[1]['uri'], 'test1');
//$cal1=OC_Calendar_Calendar::find($calId1);
//$this->assertEquals($cal1,$all[0]);
OC_Calendar_Calendar::deleteCalendar($calId1);
OC_Calendar_Calendar::deleteCalendar($calId2);
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
}
示例5: setUp
public function setUp()
{
// remember files_encryption state
$this->stateFilesEncryption = \OC_App::isEnabled('files_encryption');
// we want to tests with the encryption app disabled
\OC_App::disable('files_encryption');
$this->storage = new \OC\Files\Storage\Temporary(array());
$textData = "dummy file data\n";
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
$this->storage->mkdir('folder');
$this->storage->file_put_contents('foo.txt', $textData);
$this->storage->file_put_contents('foo.png', $imgData);
$this->storage->file_put_contents('folder/bar.txt', $textData);
$this->storage->file_put_contents('folder/bar2.txt', $textData);
$this->scanner = $this->storage->getScanner();
$this->scanner->scan('');
$this->cache = $this->storage->getCache();
\OC\Files\Filesystem::tearDown();
if (!self::$user) {
self::$user = uniqid();
}
\OC_User::createUser(self::$user, 'password');
\OC_User::setUserId(self::$user);
\OC\Files\Filesystem::init(self::$user, '/' . self::$user . '/files');
Filesystem::clearMounts();
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
\OC_Hook::clear('OC_Filesystem');
}
示例6: tearDown
protected function tearDown()
{
\OC_User::setUserId('');
$user = \OC::$server->getUserManager()->get($this->user);
if ($user !== null) {
$user->delete();
}
}
示例7: tearDown
protected function tearDown()
{
\OC_User::setIncognitoMode(false);
// Set old user
\OC_User::setUserId($this->oldUser);
\OC_Util::setupFS($this->oldUser);
parent::tearDown();
}
示例8: tearDown
protected function tearDown()
{
\OC_User::setUserId($this->user);
\OC_Config::setValue('cachedirectory', $this->datadir);
// Restore the original mount point
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->storage, array(), '/');
parent::tearDown();
}
示例9: setUp
public function setUp()
{
OC_User::clearBackends();
OC_User::useBackend('dummy');
$this->user = uniqid('user_');
$this->objectType = uniqid('type_');
OC_User::createUser($this->user, 'pass');
OC_User::setUserId($this->user);
}
示例10: tearDown
protected function tearDown()
{
$this->instance->remove('hack', 'hack');
\OC_User::setUserId($this->user);
\OC::$server->getConfig()->setSystemValue('cachedirectory', $this->datadir);
// Restore the original mount point
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->storage, array(), '/');
parent::tearDown();
}
示例11: tearDown
protected function tearDown()
{
foreach ($this->tmpDirs as $dir) {
\OC_Helper::rmdirr($dir);
}
\OC\Files\Filesystem::clearMounts();
\OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
\OC_User::setUserId('');
parent::tearDown();
}
示例12: testGetApps
public function testGetApps()
{
$user = $this->generateUsers();
\OC_Group::addToGroup($user, 'admin');
\OC_User::setUserId($user);
$result = \OCA\provisioning_API\Apps::getApps(array());
$this->assertTrue($result->succeeded());
$data = $result->getData();
$this->assertEquals(count(\OC_App::listAllApps()), count($data['apps']));
}
示例13: setUp
protected function setUp()
{
parent::setUp();
$this->username = $this->getUniqueID('', 20);
OC_User::createUser($this->username, $this->getUniqueID('', 20));
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($this->username);
$this->certificateManager = new CertificateManager($this->username, new \OC\Files\View());
}
示例14: testUserOtherExport
public function testUserOtherExport()
{
$user = $this->generateUser();
$user2 = $this->generateUser();
\OC_User::setUserId($user2);
$export = \OC_Migrate::export($user);
// Check it succeeded and exists
$this->assertTrue(json_decode($export)->success);
// Validate the export
$this->validateUserExport($user2, $user, json_decode($export)->data);
}
示例15: setUp
public function setUp()
{
OCA_mozilla_sync\Utils::setTestState();
// Create ownCloud Test User
OC_User::createUser($this->userName, $this->password);
OC_User::setUserId($this->userName);
\OC::$server->getConfig()->setUserValue($this->userName, 'settings', 'email', $this->email);
OCA_mozilla_sync\OutputData::$outputFlag = OCA_mozilla_sync\OutputData::ConstOutputBuffer;
OCA_mozilla_sync\Utils::setTestState();
$this->urlParser = new OCA_mozilla_sync\UrlParser('/1.0/' . $this->userHash);
}