Example #1
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("ninkaSched" . time());
     $this->dbManager = $this->testDb->getDbManager();
     $this->licenseDao = new LicenseDao($this->dbManager);
     $logger = new Logger("NinkaSchedulerTest");
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
 }
Example #2
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("monkBulk");
     $this->dbManager = $this->testDb->getDbManager();
     $this->licenseDao = new LicenseDao($this->dbManager);
     $logger = new Logger("MonkBulkTest");
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
     $this->highlightDao = new HighlightDao($this->dbManager);
     $this->clearingDao = new ClearingDao($this->dbManager, $this->uploadDao);
 }
 public function testAccessibilityViaPublicForQualifiedUser()
 {
     $this->testDb->createPlainTables(array('perm_upload', 'groups'));
     $this->testDb->insertData(array('groups'));
     $_SESSION[Auth::USER_LEVEL] = Auth::PERM_READ;
     $accessibilityByNone = $this->uploadPermissionDao->isAccessible($uploadId = 2, $groupId = 2);
     assertThat($accessibilityByNone, equalTo(false));
     $this->uploadPermissionDao->setPublicPermission($uploadId, Auth::PERM_READ);
     $accessibilityByPublic = $this->uploadPermissionDao->isAccessible($uploadId, $groupId);
     assertThat($accessibilityByPublic, equalTo(true));
 }
Example #4
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("monkSched");
     $this->dbManager = $this->testDb->getDbManager();
     $this->licenseDao = new LicenseDao($this->dbManager);
     $logger = new Logger("SchedulerTest");
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
     $this->highlightDao = new HighlightDao($this->dbManager);
     $this->clearingDao = new ClearingDao($this->dbManager, $this->uploadDao);
     $this->agentDir = dirname(dirname(__DIR__));
 }
Example #5
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("reuserSched");
     $this->dbManager = $this->testDb->getDbManager();
     $this->licenseDao = new LicenseDao($this->dbManager);
     $logger = new Logger("ReuserSchedulerTest");
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
     $this->highlightDao = new HighlightDao($this->dbManager);
     $this->clearingDecisionFilter = new ClearingDecisionFilter();
     $this->clearingDao = new ClearingDao($this->dbManager, $this->uploadDao);
     $this->treeDao = \Mockery::mock(TreeDao::classname());
     $agentDao = new AgentDao($this->dbManager, $logger);
     $this->runnerMock = new SchedulerTestRunnerMock($this->dbManager, $agentDao, $this->clearingDao, $this->uploadDao, $this->clearingDecisionFilter, $this->treeDao);
     $this->runnerCli = new SchedulerTestRunnerCli($this->testDb);
 }
Example #6
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("deciderJobSched" . time());
     $this->dbManager = $this->testDb->getDbManager();
     $logger = M::mock('Monolog\\Logger');
     $this->licenseDao = new LicenseDao($this->dbManager);
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
     $this->highlightDao = new HighlightDao($this->dbManager);
     $agentDao = new AgentDao($this->dbManager, $logger);
     $this->agentLicenseEventProcessor = new AgentLicenseEventProcessor($this->licenseDao, $agentDao);
     $clearingEventProcessor = new ClearingEventProcessor();
     $this->clearingDao = new ClearingDao($this->dbManager, $this->uploadDao);
     $this->clearingDecisionProcessor = new ClearingDecisionProcessor($this->clearingDao, $this->agentLicenseEventProcessor, $clearingEventProcessor, $this->dbManager);
     $this->runnerMock = new SchedulerTestRunnerMock($this->dbManager, $agentDao, $this->clearingDao, $this->uploadDao, $this->highlightDao, $this->clearingDecisionProcessor, $this->agentLicenseEventProcessor);
     $this->runnerCli = new SchedulerTestRunnerCli($this->testDb);
 }
Example #7
0
 protected function setUp()
 {
     $this->testDb = new TestPgDb("deciderSched");
     $this->dbManager = $this->testDb->getDbManager();
     $this->licenseDao = new LicenseDao($this->dbManager);
     $logger = M::mock('Monolog\\Logger');
     $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
     $this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
     $this->highlightDao = new HighlightDao($this->dbManager);
     $agentDao = new AgentDao($this->dbManager, $logger);
     $this->agentLicenseEventProcessor = new AgentLicenseEventProcessor($this->licenseDao, $agentDao);
     $clearingEventProcessor = new ClearingEventProcessor();
     $this->clearingDao = new ClearingDao($this->dbManager, $this->uploadDao);
     $this->clearingDecisionProcessor = new ClearingDecisionProcessor($this->clearingDao, $this->agentLicenseEventProcessor, $clearingEventProcessor, $this->dbManager);
     global $container;
     $container = M::mock('ContainerBuilder');
     $container->shouldReceive('get')->withArgs(array('db.manager'))->andReturn($this->dbManager);
     $this->runnerMock = new SchedulerTestRunnerMock($this->dbManager, $agentDao, $this->clearingDao, $this->uploadDao, $this->highlightDao, $this->clearingDecisionProcessor, $this->agentLicenseEventProcessor);
     $this->runnerCli = new SchedulerTestRunnerCli($this->testDb);
 }
 private function insertPermission($groupId, $uploadId, $permission, $uploadList)
 {
     $fileName = false;
     foreach ($uploadList as $uploadEntry) {
         if ($uploadEntry['upload_pk']) {
             $fileName = $uploadEntry['name'];
         }
     }
     if (empty($fileName)) {
         throw new \Exception('This upload is missing or inaccessible');
     }
     $reuseBit = $permission & self::MOD_REUSE;
     if ($reuseBit) {
         $jobId = \JobAddJob(Auth::getUserId(), $groupId, $fileName, $uploadId);
         $reuserAgent = \plugin_find('agent_reuser');
         $request = new Request(array('uploadToReuse' => "{$uploadId}," . Auth::getGroupId(), 'groupId' => $groupId));
         $reuserAgent->scheduleAgent($jobId, $uploadId, $errorMsg, $request);
         if (!empty($errorMsg)) {
             throw new Exception($errorMsg);
         }
         $permission ^= $reuseBit;
     }
     $this->uploadPermDao->insertPermission($uploadId, $groupId, $permission);
 }
Example #9
0
 public function makeAccessibleToAllGroupsOf($uploadId, $userId, $perm = null)
 {
     $this->permissionDao->makeAccessibleToAllGroupsOf($uploadId, $userId, $perm);
 }