Example #1
0
	public function __construct($params) {
		$this->appName = 'contacts';
		parent::__construct($this->appName, $params);
		$this->container = $this->getContainer();
		$this->server = $this->container->getServer();
		$this->app = new App($this->container->query('API')->getUserId());
		$this->registerServices();
		$this->container->registerMiddleware('HttpMiddleware');
	}
Example #2
0
 /**
  * Test set up
  */
 public function setUp()
 {
     parent::setUp();
     $app = new Application();
     $this->container = $app->getContainer();
     $this->rootFolder = $this->container->getServer()->getRootFolder();
     $this->userManager = $this->getMockBuilder('\\OCP\\IUserManager')->disableOriginalConstructor()->getMock();
     $this->serverContainer = $this->getMockBuilder('OCP\\IServerContainer')->disableOriginalConstructor()->getMock();
     $this->logger = $this->getMockBuilder('\\OCP\\ILogger')->disableOriginalConstructor()->getMock();
 }
Example #3
0
 public function __construct($params)
 {
     $this->appName = 'contacts';
     parent::__construct($this->appName, $params);
     $this->container = $this->getContainer();
     $this->server = $this->container->getServer();
     $userId = \OC::$server->getUserSession()->getUser()->getUID();
     $this->app = new App($userId);
     $this->registerServices();
     $this->container->registerMiddleware('HttpMiddleware');
 }
 public function __construct($params)
 {
     $this->appName = 'contacts';
     parent::__construct($this->appName, $params);
     $this->container = $this->getContainer();
     $this->server = $this->container->getServer();
     $user = \OC::$server->getUserSession()->getUser();
     if (is_null($user)) {
         \OC_Util::redirectToDefaultPage();
     }
     $userId = $user->getUID();
     $this->app = new App($userId);
     $this->registerServices();
     $this->container->registerMiddleware('HttpMiddleware');
 }
 public function __construct(IAppContainer $container, App $app)
 {
     $this->api = $container->query('API');
     $this->request = $container->query('Request');
     $this->server = $container->getServer();
     $this->app = $app;
 }
 /**
  * Runs before each test (public method)
  *
  * It's important to recreate the app for every test, as if the user had just logged in
  *
  * @fixme Or just create the app once for each type of env and run all tests. For that to work,
  *     I think I would need to switch to Cepts
  */
 protected function _before()
 {
     $this->coreTestCase->setUp();
     $app = new Gallery();
     $this->container = $app->getContainer();
     $this->server = $this->container->getServer();
     $setupData = $this->getModule('\\Helper\\DataSetup');
     $this->userId = $setupData->userId;
     $this->sharerUserId = $setupData->sharerUserId;
     $this->sharedFolder = $setupData->sharedFolder;
     $this->sharedFolderName = $this->sharedFolder->getName();
     $this->sharedFile = $setupData->sharedFile;
     $this->sharedFileName = $this->sharedFile->getName();
     $this->sharedFolderToken = $setupData->sharedFolderToken;
     $this->sharedFileToken = $setupData->sharedFileToken;
     $this->passwordForFolderShare = $setupData->passwordForFolderShare;
 }
 /**
  * If an SecurityException is being caught, ajax requests return a JSON error
  * response and non ajax requests redirect to the index
  * @param Controller $controller the controller that is being called
  * @param string $methodName the name of the method that will be called on
  *                           the controller
  * @param \Exception $exception the thrown exception
  * @throws \Exception the passed in exception if it cant handle it
  * @return Response a Response object or null in case that the exception could not be handled
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     if ($exception instanceof SecurityException) {
         if (stripos($this->request->getHeader('Accept'), 'html') === false) {
             $response = new JSONResponse(array('message' => $exception->getMessage()), $exception->getCode());
             $this->app->log($exception->getMessage(), 'debug');
         } else {
             // TODO: replace with link to route
             $url = $this->app->getServer()->getURLGenerator()->getAbsoluteURL('index.php');
             $response = new RedirectResponse($url);
             $this->app->log($exception->getMessage(), 'debug');
         }
         return $response;
     }
     throw $exception;
 }
 /**
  * Called before executing all tests in a suite
  *
  * If the module is injected, you need to use _initialize()
  *
  * @param array $settings
  */
 public function _beforeSuite($settings = [])
 {
     $this->coreTestCase = new CoreTestCase();
     $app = new App('gallery-test-setup');
     $this->container = $app->getContainer();
     $this->server = $this->container->getServer();
     $this->rootFolder = $this->server->getRootFolder();
     $this->userManager = $this->server->getUserManager();
     /**
      * Logging hooks are missing at the moment, so we need to disable encryption
      *
      * @link https://github.com/owncloud/core/issues/18085#issuecomment-128093797
      */
     $this->server->getConfig()->setAppValue('core', 'encryption_enabled', 'no');
     // This is because the filesystem is not properly cleaned up sometimes
     $this->server->getAppManager()->disableApp('files_trashbin');
     $this->setPreviewProviders();
     $this->createTestSetup($this->userId, $this->userPassword);
     $this->createTestSetup($this->sharerUserId, $this->sharerPassword);
     $this->createShares();
 }
 /**
  * @param IAppContainer $c
  */
 public function registerBackends(IAppContainer $c)
 {
     $l10n = $c->getServer()->getL10N($c->getAppName());
     // Local backend: Default database backend
     $this->backends->queue(function () use($c, $l10n) {
         return $this->backendFactory->createBackend('org.ownCloud.local', $this->backends, function () use($l10n) {
             return new Calendar\Backend\Local\Backend($l10n);
         }, function (Calendar\IBackend $backend) use($c) {
             $db = $c->getServer()->getDatabaseConnection();
             $factory = $c->query('CalendarFactory');
             return new Calendar\Backend\Local\Calendar($db, $backend, $factory);
         }, function (Calendar\ICalendar $calendar) use($c) {
             $db = $c->getServer()->getDatabaseConnection();
             $factory = $c->query('ObjectFactory');
             return new Calendar\Backend\Local\Object($db, $calendar, $factory);
         });
     });
     // Contacts backend: show contact's birthdays and anniversaries
     $contactsManager = $c->getServer()->getContactsManager();
     $this->backends->queue(function () use($c, $l10n, $contactsManager) {
         return $this->backendFactory->createBackend('org.ownCloud.contact', $this->backends, function () use($c, $contactsManager) {
             $appManager = $c->getServer()->getAppManager();
             return new Calendar\Backend\Contact\Backend($contactsManager, $appManager);
         }, function (Calendar\IBackend $backend) use($c, $contactsManager) {
             $l10n = $c->getServer()->getL10N('calendar');
             $calendarFactory = $c->query('CalendarFactory');
             return new Calendar\Backend\Contact\Calendar($contactsManager, $backend, $l10n, $calendarFactory);
         }, function (Calendar\ICalendar $calendar) use($c, $contactsManager) {
             $l10n = $c->getServer()->getL10N('calendar');
             $objectFactory = $c->query('ObjectFactory');
             return new Calendar\Backend\Contact\Object($contactsManager, $calendar, $l10n, $objectFactory);
         });
     });
     // Sharing backend: Enabling users to share calendars
     if (Share::isEnabled() && false) {
         $this->backends->queue(function () use($c, $l10n) {
             return $this->backendFactory->createBackend('org.ownCloud.sharing', $this->backends, function () {
                 return new Calendar\Backend\Sharing\Backend();
             }, function (Calendar\IBackend $backend) {
                 return new Calendar\Backend\Sharing\Calendar($backend);
             }, function (Calendar\ICalendar $calendar) {
                 return new Calendar\Backend\Sharing\Object($calendar);
             });
         });
     }
     // Webcal Backend: Show ICS files on the net
     if (function_exists('curl_init')) {
         $this->backends->queue(function () use($c, $l10n) {
             return $this->backendFactory->createBackend('org.ownCloud.webcal', $this->backends, function () use($c, $l10n) {
                 $subscriptions = $c->query('SubscriptionBusinessLayer');
                 $cacheFactory = $c->getServer()->getMemCacheFactory();
                 return new Calendar\Backend\WebCal\Backend($subscriptions, $l10n, $cacheFactory);
             }, function (Calendar\IBackend $backend) use($c, $l10n) {
                 $subscriptions = $c->query('SubscriptionBusinessLayer');
                 $cacheFactory = $c->getServer()->getMemCacheFactory();
                 $calendarFactory = $c->query('CalendarFactory');
                 return new Calendar\Backend\WebCal\Calendar($subscriptions, $l10n, $cacheFactory, $backend, $calendarFactory);
             }, function (Calendar\ICalendar $calendar) use($c, $l10n) {
                 $subscriptions = $c->query('SubscriptionBusinessLayer');
                 $cacheFactory = $c->getServer()->getMemCacheFactory();
                 $objectFactory = $c->query('ObjectFactory');
                 return new Calendar\Backend\WebCal\Object($subscriptions, $l10n, $cacheFactory, $calendar, $objectFactory);
             });
         });
     }
 }