本文整理汇总了PHP中OCP\IConfig::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP IConfig::expects方法的具体用法?PHP IConfig::expects怎么用?PHP IConfig::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IConfig
的用法示例。
在下文中一共展示了IConfig::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBeforeControllerWithSharingEnabled
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: testSetException
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: testIsTwoFactorAuthenticated
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: testGetInstanceSendmail
public function testGetInstanceSendmail() {
$this->config
->expects($this->any())
->method('getSystemValue')
->will($this->returnValue('sendmail'));
$this->assertInstanceOf('\Swift_SendmailTransport', self::invokePrivate($this->mailer, 'getInstance'));
}
示例5: testBeforeHandlerSuccess
/**
* @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: testRunWithExpiredToken
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: testMaintenanceMode
/**
* @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: testRunWithUsersAndOffsetAtEndOfUserList
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: testCreateCredentials
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: testUserMountingBackends
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: testGetApplicationDownloadUrlSuccessful
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: testGetGroupMembership
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('foo@owncloud.org'));
$expectedResponse = [
'principals/foo/calendar-proxy-read',
'principals/foo/calendar-proxy-write'
];
$response = $this->connector->getGroupMembership('principals/foo');
$this->assertSame($expectedResponse, $response);
}
示例13: mockRSSToken
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: testGetRequestUriWithOverwrite
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: testFindLanguage
/**
* @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');
}