コード例 #1
0
 public function testBeforeControllerWithSharingEnabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(true));
     $this->config->expects($this->at(0))->method('getAppValue')->with('core', 'shareapi_enabled', 'yes')->will($this->returnValue('yes'));
     $this->config->expects($this->at(1))->method('getAppValue')->with('core', 'shareapi_allow_links', 'yes')->will($this->returnValue('yes'));
     $this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
 }
コード例 #2
0
 public function testSetException()
 {
     $this->config->expects($this->once())->method('setUserValue')->with('JohnDoe', 'contacts', 'keyValue', 'valueValue')->will($this->throwException(new \Exception()));
     $expected = new JSONResponse();
     $expected->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
     $this->assertEquals($expected, $this->controller->set('keyValue', 'valueValue'));
 }
コード例 #3
0
 public function testIsTwoFactorAuthenticated()
 {
     $this->prepareProviders();
     $this->user->expects($this->once())->method('getUID')->will($this->returnValue('user123'));
     $this->config->expects($this->once())->method('getUserValue')->with('user123', 'core', 'two_factor_auth_disabled', 0)->will($this->returnValue(0));
     $this->assertTrue($this->manager->isTwoFactorAuthenticated($this->user));
 }
コード例 #4
0
ファイル: mailer.php プロジェクト: ninjasilicon/core
	public function testGetInstanceSendmail() {
		$this->config
			->expects($this->any())
			->method('getSystemValue')
			->will($this->returnValue('sendmail'));

		$this->assertInstanceOf('\Swift_SendmailTransport', self::invokePrivate($this->mailer, 'getInstance'));
	}
コード例 #5
0
 /**
  * @dataProvider newAndAlternateDesktopClientProvider
  * @param string $userAgent
  */
 public function testBeforeHandlerSuccess($userAgent)
 {
     /** @var \Sabre\HTTP\RequestInterface $request */
     $request = $this->getMock('\\Sabre\\HTTP\\RequestInterface');
     $request->expects($this->once())->method('getHeader')->with('User-Agent')->will($this->returnValue($userAgent));
     $this->config->expects($this->once())->method('getSystemValue')->with('minimum.supported.desktop.version', '1.7.0')->will($this->returnValue('1.7.0'));
     $this->blockLegacyClientVersionPlugin->beforeHandler($request);
 }
コード例 #6
0
 public function testRunWithExpiredToken()
 {
     $this->timeFactory->expects($this->at(0))->method('getTime')->willReturn(1455131633);
     $this->timeFactory->expects($this->at(1))->method('getTime')->willReturn(1455045234);
     $this->config->expects($this->once())->method('getAppValue')->with('core', 'updater.secret.created', 1455045234);
     $this->config->expects($this->once())->method('deleteSystemValue')->with('updater.secret');
     $this->invokePrivate($this->resetTokenBackgroundJob, 'run', ['']);
 }
コード例 #7
0
	/**
	 * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
	 * @expectedExceptionMessage System in single user mode.
	 */
	public function testMaintenanceMode() {
		$this->config
			->expects($this->exactly(1))
			->method('getSystemValue')
			->will($this->onConsecutiveCalls([false, true]));

		$this->maintenancePlugin->checkMaintenanceMode();
	}
コード例 #8
0
ファイル: ScanFilesTest.php プロジェクト: gmurayama/core
 public function testRunWithUsersAndOffsetAtEndOfUserList()
 {
     $this->config->expects($this->at(0))->method('getAppValue')->with('files', 'cronjob_scan_files', 0)->will($this->returnValue(50));
     $this->userManager->expects($this->at(0))->method('search')->with('', 500, 50)->will($this->returnValue([]));
     $this->userManager->expects($this->at(1))->method('search')->with('', 500)->will($this->returnValue([]));
     $this->config->expects($this->at(1))->method('setAppValue')->with('files', 'cronjob_scan_files', 500);
     $this->scanFiles->expects($this->never())->method('runScanner');
     $this->invokePrivate($this->scanFiles, 'run', [[]]);
 }
コード例 #9
0
 public function testCreateCredentials()
 {
     $this->jobList->expects($this->once())->method('add')->with('OCA\\UpdateNotification\\ResetTokenBackgroundJob');
     $this->secureRandom->expects($this->once())->method('generate')->with(64)->willReturn('MyGeneratedToken');
     $this->config->expects($this->once())->method('setSystemValue')->with('updater.secret');
     $this->timeFactory->expects($this->once())->method('getTime')->willReturn(12345);
     $this->config->expects($this->once())->method('setAppValue')->with('core', 'updater.secret.created', 12345);
     $expected = new DataResponse('MyGeneratedToken');
     $this->assertEquals($expected, $this->adminController->createCredentials());
 }
コード例 #10
0
ファイル: backendservicetest.php プロジェクト: rosarion/core
 public function testUserMountingBackends()
 {
     $this->config->expects($this->exactly(2))->method('getAppValue')->will($this->returnValueMap([['files_external', 'allow_user_mounting', 'yes', 'yes'], ['files_external', 'user_mounting_backends', '', 'identifier:\\User\\Mount\\Allowed,identifier_alias']]));
     $service = new BackendService($this->config, $this->l10n);
     $backendAllowed = $this->getBackendMock('\\User\\Mount\\Allowed');
     $backendAllowed->expects($this->never())->method('removeVisibility');
     $backendNotAllowed = $this->getBackendMock('\\User\\Mount\\NotAllowed');
     $backendNotAllowed->expects($this->once())->method('removeVisibility')->with(BackendService::VISIBILITY_PERSONAL);
     $backendAlias = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Backend\\Backend')->disableOriginalConstructor()->getMock();
     $backendAlias->method('getIdentifierAliases')->willReturn(['identifier_real', 'identifier_alias']);
     $backendAlias->expects($this->never())->method('removeVisibility');
     $service->registerBackend($backendAllowed);
     $service->registerBackend($backendNotAllowed);
     $service->registerBackend($backendAlias);
 }
コード例 #11
0
ファイル: ocsclienttest.php プロジェクト: evanjt/core
    public function testGetApplicationDownloadUrlSuccessful()
    {
        $this->config->expects($this->at(0))->method('getSystemValue')->with('appstoreenabled', true)->will($this->returnValue(true));
        $this->config->expects($this->at(1))->method('getSystemValue')->with('appstoreurl', 'https://api.owncloud.com/v1')->will($this->returnValue('https://api.owncloud.com/v1'));
        $response = $this->getMock('\\OCP\\Http\\Client\\IResponse');
        $response->expects($this->once())->method('getBody')->will($this->returnValue('<?xml version="1.0"?>
				<ocs>
				 <meta>
				  <status>ok</status>
				  <statuscode>100</statuscode>
				  <message></message>
				 </meta>
				 <data>
				  <content details="download">
				   <downloadlink>https://apps.owncloud.com/CONTENT/content-files/166052-files_trashbin.zip</downloadlink>
				   <mimetype>application/zip</mimetype>
				   <gpgfingerprint></gpgfingerprint>
				   <gpgsignature></gpgsignature>
				   <packagename></packagename>
				   <repository></repository>
				  </content>
				 </data>
				</ocs>
				'));
        $client = $this->getMock('\\OCP\\Http\\Client\\IClient');
        $client->expects($this->once())->method('get')->with('https://api.owncloud.com/v1/content/download/MyId/1', ['timeout' => 5, 'query' => ['version' => '8x1x0x7']])->will($this->returnValue($response));
        $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
        $expected = ['downloadlink' => 'https://apps.owncloud.com/CONTENT/content-files/166052-files_trashbin.zip'];
        $this->assertSame($expected, $this->ocsClient->getApplicationDownload('MyId', [8, 1, 0, 7]));
    }
コード例 #12
0
ファイル: principal.php プロジェクト: ninjasilicon/core
	public function testGetGroupMembership() {
		$fooUser = $this->getMockBuilder('\OC\User\User')
			->disableOriginalConstructor()->getMock();
		$fooUser
			->expects($this->exactly(3))
			->method('getUID')
			->will($this->returnValue('foo'));
		$this->userManager
			->expects($this->once())
			->method('get')
			->with('foo')
			->will($this->returnValue($fooUser));
		$this->config
			->expects($this->once())
			->method('getUserValue')
			->with('foo', 'settings', 'email')
			->will($this->returnValue('*****@*****.**'));

		$expectedResponse = [
			'principals/foo/calendar-proxy-read',
			'principals/foo/calendar-proxy-write'
		];
		$response = $this->connector->getGroupMembership('principals/foo');
		$this->assertSame($expectedResponse, $response);
	}
コード例 #13
0
 protected function mockRSSToken($requestToken, $userToken, $users)
 {
     if ($requestToken !== null) {
         $this->request->expects($this->any())->method('getParam')->with('token', '')->willReturn($requestToken);
     }
     $this->config->expects($this->any())->method('getUsersForUserValue')->with('activity', 'rsstoken', $userToken)->willReturn($users);
 }
コード例 #14
0
ファイル: RequestTest.php プロジェクト: ninjasilicon/core
	public function testGetRequestUriWithOverwrite() {
		$this->config
			->expects($this->at(0))
			->method('getSystemValue')
			->with('overwritewebroot')
			->will($this->returnValue('/owncloud/'));
		$this->config
			->expects($this->at(1))
			->method('getSystemValue')
			->with('overwritecondaddr')
			->will($this->returnValue(''));

		$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
			->setMethods(['getScriptName'])
			->setConstructorArgs([
				[
					'server' => [
						'REQUEST_URI' => '/test.php/some/PathInfo',
						'SCRIPT_NAME' => '/test.php',
					]
				],
				$this->secureRandom,
				$this->config,
				$this->stream
			])
			->getMock();
		$request
			->expects($this->once())
			->method('getScriptName')
			->will($this->returnValue('/scriptname.php'));

		$this->assertSame('/scriptname.php/some/PathInfo', $request->getRequestUri());
	}
コード例 #15
0
ファイル: factorytest.php プロジェクト: matt407/core
 /**
  * @dataProvider dataFindLanguage
  *
  * @param string|null $app
  * @param string|null $user
  * @param int $existsCalls
  * @param string $storedRequestLang
  * @param bool $srlExists
  * @param string|null $userLang
  * @param bool $ulExists
  * @param string|false $defaultLang
  * @param bool $dlExists
  * @param string|null $requestLang
  * @param string $expected
  */
 public function testFindLanguage($app, $user, $existsCalls, $storedRequestLang, $srlExists, $userLang, $ulExists, $defaultLang, $dlExists, $requestLang, $expected)
 {
     $factory = $this->getFactory(['languageExists', 'setLanguageFromRequest']);
     $session = $this->getMockBuilder('OCP\\ISession')->disableOriginalConstructor()->getMock();
     $session->expects($this->any())->method('get')->with('user_id')->willReturn($user);
     $userSession = $this->getMockBuilder('OC\\User\\Session')->disableOriginalConstructor()->getMock();
     $userSession->expects($this->any())->method('getSession')->willReturn($session);
     $this->invokePrivate($factory, 'requestLanguage', [$storedRequestLang]);
     $factory->expects($this->exactly($existsCalls))->method('languageExists')->willReturnMap([[$app, $storedRequestLang, $srlExists], [$app, $userLang, $ulExists], [$app, $defaultLang, $dlExists]]);
     $factory->expects($requestLang !== null ? $this->once() : $this->never())->method('setLanguageFromRequest')->willReturn($requestLang);
     $this->config->expects($userLang !== null ? $this->any() : $this->never())->method('getUserValue')->with($this->anything(), 'core', 'lang')->willReturn($userLang);
     $this->config->expects($defaultLang !== null ? $this->once() : $this->never())->method('getSystemValue')->with('default_language', false)->willReturn($defaultLang);
     $this->overwriteService('UserSession', $userSession);
     $this->assertSame($expected, $factory->findLanguage($app));
     $this->restoreService('UserSession');
 }
コード例 #16
0
ファイル: checkertest.php プロジェクト: farukuzun/core-1
 /**
  * @param string $channel
  * @dataProvider channelDataProvider
  */
 public function testIsCodeCheckEnforcedWithDisabledConfigSwitch($channel)
 {
     $this->environmentHelper->expects($this->once())->method('getChannel')->will($this->returnValue($channel));
     $this->config->expects($this->any())->method('getSystemValue')->with('integrity.check.disabled', false)->will($this->returnValue(true));
     $result = $this->invokePrivate($this->checker, 'isCodeCheckEnforced');
     $this->assertSame(false, $result);
 }
コード例 #17
0
 public function testBeforeControllerWithShareControllerWithSharingEnabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(true));
     $this->config->expects($this->at(0))->method('getAppValue')->with('core', 'shareapi_enabled', 'yes')->will($this->returnValue('yes'));
     $this->config->expects($this->at(1))->method('getAppValue')->with('core', 'shareapi_allow_links', 'yes')->will($this->returnValue('yes'));
     $controller = $this->getMockBuilder('\\OCA\\Files_Sharing\\Controllers\\ShareController')->disableOriginalConstructor()->getMock();
     $this->sharingCheckMiddleware->beforeController($controller, 'myMethod');
 }
コード例 #18
0
 public function testShowHiddenFiles()
 {
     $show = false;
     $this->config->expects($this->once())->method('setUserValue')->with($this->user->getUID(), 'files', 'show_hidden', $show);
     $expected = new Http\Response();
     $actual = $this->apiController->showHiddenFiles($show);
     $this->assertEquals($expected, $actual);
 }
コード例 #19
0
 public function testFindAvailableLanguagesWithThemes()
 {
     $this->serverRoot .= '/tests/data';
     $app = 'files';
     $factory = $this->getFactory(['findL10nDir']);
     $factory->expects($this->once())->method('findL10nDir')->with($app)->willReturn($this->serverRoot . '/apps/files/l10n/');
     $this->config->expects($this->once())->method('getSystemValue')->with('theme')->willReturn('abc');
     $this->assertEquals(['en', 'zz'], $factory->findAvailableLanguages($app), '', 0.0, 10, true);
 }
コード例 #20
0
 public function testIndexWithRegularBrowser()
 {
     $this->request->expects($this->once())->method('isUserAgent')->with(['/MSIE 8.0/'])->will($this->returnValue(false));
     $this->viewController->expects($this->once())->method('getStorageInfo')->will($this->returnValue(['relative' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName']));
     $this->config->expects($this->any())->method('getAppValue')->will($this->returnArgument(2));
     $nav = new Template('files', 'appnavigation');
     $nav->assign('navigationItems', [0 => ['id' => 'files', 'appname' => 'files', 'script' => 'list.php', 'order' => 0, 'name' => new \OC_L10N_String(new \OC_L10N('files'), 'All files', []), 'active' => false, 'icon' => ''], 1 => ['id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => null, 'active' => false, 'icon' => ''], 2 => ['id' => 'sharingin', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 10, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with you', []), 'active' => false, 'icon' => ''], 3 => ['id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 15, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with others', []), 'active' => false, 'icon' => ''], 4 => ['id' => 'sharinglinks', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 20, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared by link', []), 'active' => false, 'icon' => ''], 5 => ['id' => 'trashbin', 'appname' => 'files_trashbin', 'script' => 'list.php', 'order' => 50, 'name' => new \OC_L10N_String(new \OC_L10N('files_trashbin'), 'Deleted files', []), 'active' => false, 'icon' => '']]);
     $expected = new Http\TemplateResponse('files', 'index', ['usedSpacePercent' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName', 'isPublic' => false, 'mailNotificationEnabled' => 'no', 'mailPublicNotificationEnabled' => 'no', 'allowShareWithLink' => 'yes', 'appNavigation' => $nav, 'appContents' => [0 => ['id' => 'files', 'content' => null], 1 => ['id' => 'favorites', 'content' => null], 2 => ['id' => 'sharingin', 'content' => null], 3 => ['id' => 'sharingout', 'content' => null], 4 => ['id' => 'sharinglinks', 'content' => null], 5 => ['id' => 'trashbin', 'content' => null]]]);
     $this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
 }
コード例 #21
0
ファイル: userformattertest.php プロジェクト: ynott/activity
 /**
  * @dataProvider dataFormat
  *
  * @param string $parameter
  * @param null|\OCP\IUser $user
  * @param bool $avatarsEnabled
  * @param bool $allowHtml
  * @param bool $verbose
  * @param string $expected
  */
 public function testFormat($parameter, $user, $avatarsEnabled, $allowHtml, $verbose, $expected)
 {
     /** @var \OCP\Activity\IEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $this->l->expects($this->never())->method('t');
     $this->userManager->expects($this->once())->method('get')->with($parameter)->willReturn($user);
     $this->config->expects($this->any())->method('getSystemValue')->with('enable_avatars', true)->willReturn($avatarsEnabled);
     $formatter = $this->getFormatter();
     $this->assertSame($expected, $formatter->format($event, $parameter, $allowHtml, $verbose));
 }
コード例 #22
0
 public function testShowLoginFormForUserNamedNull()
 {
     $this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(false);
     $this->config->expects($this->once())->method('getSystemValue')->with('lost_password_link')->willReturn(false);
     $user = $this->getMock('\\OCP\\IUser');
     $user->expects($this->once())->method('canChangePassword')->willReturn(false);
     $this->userManager->expects($this->once())->method('get')->with('0')->willReturn($user);
     $expectedResponse = new TemplateResponse('core', 'login', ['messages' => [], 'loginName' => '0', 'user_autofocus' => false, 'canResetPassword' => false, 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0], 'guest');
     $this->assertEquals($expectedResponse, $this->loginController->showLoginForm('0', '', ''));
 }
コード例 #23
0
 public function testViewAppsNotEnabled()
 {
     $this->config->expects($this->once())->method('getSystemValue')->with('appstore.experimental.enabled', false);
     $this->navigationManager->expects($this->once())->method('setActiveEntry')->with('core_apps');
     $policy = new ContentSecurityPolicy();
     $policy->addAllowedImageDomain('https://apps.owncloud.com');
     $expected = new TemplateResponse('settings', 'apps', ['experimentalEnabled' => false, 'category' => 'disabled'], 'user');
     $expected->setContentSecurityPolicy($policy);
     $this->assertEquals($expected, $this->appSettingsController->viewApps('disabled'));
 }
コード例 #24
0
ファイル: updater.php プロジェクト: kenwi/core
 public function testCheckWithEmptyInvalidXmlResponse()
 {
     $expectedResult = [];
     $this->config->expects($this->at(0))->method('getAppValue')->with('core', 'lastupdatedat')->will($this->returnValue(0));
     $this->config->expects($this->at(1))->method('setAppValue')->with('core', 'lastupdatedat', $this->isType('integer'));
     $this->config->expects($this->at(3))->method('getAppValue')->with('core', 'installedat')->will($this->returnValue('installedat'));
     $this->config->expects($this->at(4))->method('getAppValue')->with('core', 'lastupdatedat')->will($this->returnValue('lastupdatedat'));
     $this->config->expects($this->at(5))->method('setAppValue')->with('core', 'lastupdateResult', json_encode($expectedResult));
     $updateXml = '';
     $this->httpHelper->expects($this->once())->method('getUrlContent')->with($this->buildUpdateUrl('https://updates.owncloud.com/server/'))->will($this->returnValue($updateXml));
     $this->assertSame($expectedResult, $this->updater->check());
 }
コード例 #25
0
 public function testLogClientInNoTokenPasswordNo2fa()
 {
     $manager = $this->getMockBuilder('\\OC\\User\\Manager')->disableOriginalConstructor()->getMock();
     $session = $this->getMock('\\OCP\\ISession');
     $user = $this->getMock('\\OCP\\IUser');
     $request = $this->getMock('\\OCP\\IRequest');
     /** @var \OC\User\Session $userSession */
     $userSession = $this->getMockBuilder('\\OC\\User\\Session')->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config])->setMethods(['login', 'isTwoFactorEnforced'])->getMock();
     $this->tokenProvider->expects($this->once())->method('getToken')->with('doe')->will($this->throwException(new \OC\Authentication\Exceptions\InvalidTokenException()));
     $this->config->expects($this->once())->method('getSystemValue')->with('token_auth_enforced', false)->will($this->returnValue(false));
     $userSession->expects($this->once())->method('isTwoFactorEnforced')->with('john')->will($this->returnValue(true));
     $this->assertFalse($userSession->logClientIn('john', 'doe', $request));
 }
コード例 #26
0
 public function testIsBuggyNss400()
 {
     $this->config->expects($this->once())->method('getSystemValue')->with('appstoreenabled', true)->will($this->returnValue(true));
     $this->checkSetupController->expects($this->once())->method('getCurlVersion')->will($this->returnValue(['ssl_version' => 'NSS/1.0.2b']));
     $client = $this->getMockBuilder('\\OCP\\Http\\Client\\IClient')->disableOriginalConstructor()->getMock();
     $exception = $this->getMockBuilder('\\GuzzleHttp\\Exception\\ClientException')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('\\GuzzleHttp\\Message\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('getStatusCode')->will($this->returnValue(400));
     $exception->expects($this->once())->method('getResponse')->will($this->returnValue($response));
     $client->expects($this->at(0))->method('get')->with('https://www.owncloud.org/', [])->will($this->throwException($exception));
     $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
     $this->assertSame('cURL is using an outdated NSS version (NSS/1.0.2b). Please update your operating system or features such as installing and updating apps via the app store or Federated Cloud Sharing will not work reliably.', $this->invokePrivate($this->checkSetupController, 'isUsedTlsLibOutdated'));
 }
コード例 #27
0
 public function testCheck()
 {
     $this->config->expects($this->at(0))->method('getSystemValue')->with('has_internet_connection', true)->will($this->returnValue(true));
     $this->config->expects($this->at(1))->method('getSystemValue')->with('memcache.local', null)->will($this->returnValue('SomeProvider'));
     $client = $this->getMockBuilder('\\OCP\\Http\\Client\\IClient')->disableOriginalConstructor()->getMock();
     $client->expects($this->at(0))->method('get')->with('https://www.owncloud.org/', []);
     $client->expects($this->at(1))->method('get')->with('http://www.owncloud.org/', [])->will($this->throwException(new \Exception()));
     $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
     $this->util->expects($this->once())->method('isHtaccessWorking')->will($this->returnValue(true));
     $this->urlGenerator->expects($this->once())->method('linkToDocs')->with('admin-performance')->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance');
     $expected = new DataResponse(['serverHasInternetConnection' => false, 'dataDirectoryProtected' => true, 'isMemcacheConfigured' => true, 'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance']);
     $this->assertEquals($expected, $this->checkSetupController->check());
 }
コード例 #28
0
 /**
  * @dataProvider dataIsSharingDisabledForUser
  *
  * @param string $excludeGroups
  * @param string $groupList
  * @param string $setList
  * @param string[] $groupIds
  * @param bool $expected
  */
 public function testIsSharingDisabledForUser($excludeGroups, $groupList, $setList, $groupIds, $expected)
 {
     $user = $this->getMock('\\OCP\\IUser');
     $this->config->method('getAppValue')->will($this->returnValueMap([['core', 'shareapi_exclude_groups', 'no', $excludeGroups], ['core', 'shareapi_exclude_groups_list', '', $groupList]]));
     if ($setList !== null) {
         $this->config->expects($this->once())->method('setAppValue')->with('core', 'shareapi_exclude_groups_list', $setList);
     } else {
         $this->config->expects($this->never())->method('setAppValue');
     }
     $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groupIds);
     $res = $this->manager->sharingDisabledForUser($user);
     $this->assertEquals($expected, $res);
 }
コード例 #29
0
ファイル: activitytest.php プロジェクト: evanjt/core
 /**
  * @dataProvider queryForFilterData
  *
  * @param mixed $will
  * @param string $query
  * @param array $parameters
  */
 public function testQueryForFilter($will, $query, $parameters)
 {
     $this->mockUserSession('test');
     $this->config->expects($this->any())->method('getUserValue')->willReturnMap([['test', 'activity', 'notify_stream_' . Activity::TYPE_FAVORITES, false, true]]);
     if (is_array($will)) {
         $this->activityHelper->expects($this->any())->method('getFavoriteFilePaths')->with('test')->willReturn($will);
     } else {
         $this->activityHelper->expects($this->any())->method('getFavoriteFilePaths')->with('test')->willThrowException($will);
     }
     $result = $this->activityExtension->getQueryForFilter('all');
     $this->assertEquals([$query, $parameters], $result);
     $this->executeQueryForFilter($result);
 }
コード例 #30
0
ファイル: userstest.php プロジェクト: rajeshpillai/core
 public function testEditUserSubadminUserAccessible()
 {
     $loggedInUser = $this->getMock('\\OCP\\IUser');
     $loggedInUser->expects($this->any())->method('getUID')->will($this->returnValue('subadmin'));
     $targetUser = $this->getMock('\\OCP\\IUser');
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser));
     $this->userManager->expects($this->once())->method('get')->with('UserToEdit')->will($this->returnValue($targetUser));
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $subAdminManager->expects($this->once())->method('isUserAccessible')->with($loggedInUser, $targetUser)->will($this->returnValue(true));
     $this->groupManager->expects($this->once())->method('getSubAdmin')->will($this->returnValue($subAdminManager));
     $this->config->expects($this->once())->method('setUserValue')->with('UserToEdit', 'files', 'quota', '2.9 MB');
     $expected = new \OC_OCS_Result(null, 100);
     $this->assertEquals($expected, $this->api->editUser(['userid' => 'UserToEdit', '_put' => ['key' => 'quota', 'value' => '3042824']]));
 }