public function testChangeExperimentalConfigStateFalse() {
		$this->config
			->expects($this->once())
			->method('setSystemValue')
			->with('appstore.experimental.enabled', false);
		$this->appManager
			->expects($this->once())
			->method('clearAppsCache');
		$this->assertEquals(new DataResponse(), $this->appSettingsController->changeExperimentalConfigState(false));
	}
예제 #2
0
 /**
  * @dataProvider dataCheckAppUpdates
  *
  * @param string[] $apps
  * @param array $isUpdateAvailable
  * @param array $notifications
  */
 public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array $notifications)
 {
     $job = $this->getJob(['isUpdateAvailable', 'createNotifications']);
     $this->appManager->expects($this->once())->method('getInstalledApps')->willReturn($apps);
     $job->expects($this->exactly(sizeof($apps)))->method('isUpdateAvailable')->willReturnMap($isUpdateAvailable);
     $this->urlGenerator->expects($this->exactly(sizeof($notifications)))->method('linkToRouteAbsolute')->with('settings.AppSettings.viewApps')->willReturn('apps-url');
     $mockedMethod = $job->expects($this->exactly(sizeof($notifications)))->method('createNotifications');
     call_user_func_array([$mockedMethod, 'withConsecutive'], $notifications);
     $this->invokePrivate($job, 'checkAppUpdates');
 }
예제 #3
0
	public function testBuildProviderListWithEverythingEnabled() {
		$this->appManager
			->expects($this->any())
			->method('isEnabledForUser')
			->will($this->returnValue(true));

		$expected = new \OCP\AppFramework\Http\JSONResponse(
			[
				'version' => 2,
				'PRIVATE_DATA' => [
					'version' => 1,
					'endpoints' => [
						'store' => '/ocs/v1.php/privatedata/setattribute',
						'read' => '/ocs/v1.php/privatedata/getattribute',
						'delete' => '/ocs/v1.php/privatedata/deleteattribute',
					],
				],
				'FEDERATED_SHARING' => [
					'version' => 1,
					'endpoints' => [
						'share' => '/ocs/v1.php/cloud/shares',
						'webdav' => '/public.php/webdav/',
					],
				],
				'SHARING' => [
					'version' => 1,
					'endpoints' => [
						'share' => '/ocs/v1.php/apps/files_sharing/api/v1/shares',
					],
				],
				'ACTIVITY' => [
					'version' => 1,
					'endpoints' => [
						'list' => '/ocs/v1.php/cloud/activity',
					],
				],
				'PROVISIONING' => [
					'version' => 1,
					'endpoints' => [
						'user' => '/ocs/v1.php/cloud/users',
						'groups' => '/ocs/v1.php/cloud/groups',
						'apps' => '/ocs/v1.php/cloud/apps',
					],
				],
			]
		);

		$this->assertEquals($expected, $this->ocsProvider->buildProviderList());
	}
예제 #4
0
 public function testGetIncompatibleApps()
 {
     $this->manager = $this->getMockBuilder('\\OC\\App\\AppManager')->setConstructorArgs([$this->userSession, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher])->setMethods(['getAppInfo'])->getMock();
     $appInfos = ['dav' => ['id' => 'dav'], 'files' => ['id' => 'files'], 'federatedfilesharing' => ['id' => 'federatedfilesharing'], 'test1' => ['id' => 'test1', 'version' => '1.0.1', 'requiremax' => '8.0.0'], 'test2' => ['id' => 'test2', 'version' => '1.0.0', 'requiremin' => '8.2.0'], 'test3' => ['id' => 'test3', 'version' => '1.2.4', 'requiremin' => '9.0.0'], 'testnoversion' => ['id' => 'testnoversion', 'requiremin' => '8.2.0']];
     $this->manager->expects($this->any())->method('getAppInfo')->will($this->returnCallback(function ($appId) use($appInfos) {
         return $appInfos[$appId];
     }));
     $this->appConfig->setValue('test1', 'enabled', 'yes');
     $this->appConfig->setValue('test2', 'enabled', 'yes');
     $this->appConfig->setValue('test3', 'enabled', 'yes');
     $apps = $this->manager->getIncompatibleApps('8.2.0');
     $this->assertCount(2, $apps);
     $this->assertEquals('test1', $apps[0]['id']);
     $this->assertEquals('test3', $apps[1]['id']);
 }
예제 #5
0
파일: checkertest.php 프로젝트: evanjt/core
 public function testRunInstanceVerification()
 {
     $this->checker = $this->getMockBuilder('\\OC\\IntegrityCheck\\Checker')->setConstructorArgs([$this->environmentHelper, $this->fileAccessHelper, $this->appLocator, $this->config, $this->cacheFactory, $this->appManager])->setMethods(['verifyCoreSignature', 'verifyAppSignature'])->getMock();
     $this->checker->expects($this->at(0))->method('verifyCoreSignature');
     $this->appLocator->expects($this->at(0))->Method('getAllApps')->will($this->returnValue(['files', 'calendar', 'contacts', 'dav']));
     $this->appManager->expects($this->at(0))->method('isShipped')->with('files')->will($this->returnValue(true));
     $this->checker->expects($this->at(1))->method('verifyAppSignature')->with('files');
     $this->appManager->expects($this->at(1))->method('isShipped')->with('calendar')->will($this->returnValue(false));
     $this->appLocator->expects($this->at(1))->method('getAppPath')->with('calendar')->will($this->returnValue('/apps/calendar'));
     $this->fileAccessHelper->expects($this->at(0))->method('file_exists')->with('/apps/calendar/appinfo/signature.json')->will($this->returnValue(true));
     $this->checker->expects($this->at(2))->method('verifyAppSignature')->with('calendar');
     $this->appManager->expects($this->at(2))->method('isShipped')->with('contacts')->will($this->returnValue(false));
     $this->appLocator->expects($this->at(2))->method('getAppPath')->with('contacts')->will($this->returnValue('/apps/contacts'));
     $this->fileAccessHelper->expects($this->at(1))->method('file_exists')->with('/apps/contacts/appinfo/signature.json')->will($this->returnValue(false));
     $this->appManager->expects($this->at(3))->method('isShipped')->with('dav')->will($this->returnValue(true));
     $this->checker->expects($this->at(3))->method('verifyAppSignature')->with('dav');
     $this->checker->runInstanceVerification();
 }
예제 #6
0
 /**
  * @dataProvider showFileMethodProvider
  */
 public function testShowFileRouteWithTrashedFile($useShowFile)
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_trashbin')->will($this->returnValue(true));
     $parentNode = $this->getMock('\\OCP\\Files\\Folder');
     $parentNode->expects($this->once())->method('getPath')->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
     $baseFolderFiles = $this->getMock('\\OCP\\Files\\Folder');
     $baseFolderTrash = $this->getMock('\\OCP\\Files\\Folder');
     $this->rootFolder->expects($this->at(0))->method('get')->with('testuser1/files/')->will($this->returnValue($baseFolderFiles));
     $this->rootFolder->expects($this->at(1))->method('get')->with('testuser1/files_trashbin/files/')->will($this->returnValue($baseFolderTrash));
     $baseFolderFiles->expects($this->once())->method('getById')->with(123)->will($this->returnValue([]));
     $node = $this->getMock('\\OCP\\Files\\File');
     $node->expects($this->once())->method('getParent')->will($this->returnValue($parentNode));
     $node->expects($this->once())->method('getName')->will($this->returnValue('somefile.txt'));
     $baseFolderTrash->expects($this->at(0))->method('getById')->with(123)->will($this->returnValue([$node]));
     $baseFolderTrash->expects($this->at(1))->method('getRelativePath')->with('testuser1/files_trashbin/files/test.d1462861890/sub')->will($this->returnValue('/test.d1462861890/sub'));
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files.view.index', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'scrollto' => 'somefile.txt'])->will($this->returnValue('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt'));
     $expected = new Http\RedirectResponse('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt');
     if ($useShowFile) {
         $this->assertEquals($expected, $this->viewController->showFile(123));
     } else {
         $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
     }
 }
 /**
  * @expectedException \OCP\Files\NotFoundException
  * @expectedExceptionMessage Sharing is disabled.
  */
 public function testBeforeControllerWithSharingDisabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(false));
     $this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
 }
 public function testIsSharingEnabledWithSharingDisabled()
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_sharing')->will($this->returnValue(true));
     $this->config->expects($this->once())->method('getAppValue')->with('core', 'shareapi_allow_links', 'yes')->will($this->returnValue('no'));
     $this->assertFalse(\Test_Helper::invokePrivate($this->sharingCheckMiddleware, 'isSharingEnabled'));
 }
예제 #9
0
 private function mockBadAppEnabled($app)
 {
     $this->appManager->expects($this->once())->method('isInstalled')->with($app)->willReturn(true);
 }