Пример #1
0
 function testGetTopLevelLicenseRefs()
 {
     $licenseMap = new LicenseMap($this->dbManager, $this->groupId, LicenseMap::CONCLUSION);
     $topLevelLicenses = $licenseMap->getTopLevelLicenseRefs();
     assertThat($topLevelLicenses, hasItemInArray(new LicenseRef(1, 'One', 'One-1')));
     assertThat($topLevelLicenses, not(hasKeyInArray(2)));
 }
 public function testResolve()
 {
     $items = array('item1' => array('deps' => null, 'id' => 'item1'), 'item2' => array('deps' => null, 'id' => 'item2'), 'item3' => array('deps' => array('item2'), 'id' => 'item3'), 'item4' => array('deps' => array('item1', 'item3'), 'id' => 'item4'), 'item5' => array('deps' => array('item4', 'item6'), 'id' => 'item5'), 'item6' => array('deps' => array('item2'), 'id' => 'item6'), 'item7' => array('deps' => array('something-odd'), 'id' => 'item7'), 'item9' => array('deps' => array('item6', 'item5', 'item4'), 'id' => 'item9'), 'item10' => array('deps' => array('item9'), 'id' => 'item10'), 'item11' => array('deps' => array('item1', 'item2', 'item10'), 'id' => 'item11'));
     $expected = array('item1', 'item2', 'item3', 'item4', 'item6', 'item5', 'item9', 'item10', 'item11');
     $resolver = new DependencyResolver();
     $resolved = $resolver->register($items)->resolveAll();
     foreach ($expected as $index => $id) {
         assertThat($resolved, hasKeyInArray($index));
         assertThat($resolved[$index]['id'], is(equalTo($id)));
     }
 }
Пример #3
0
 public function testMountControllerWithBaseRoute()
 {
     $patternBuilder = \Mockery::mock('Rootr\\PatternBuilder');
     $router = new Router($patternBuilder);
     $controllerRouter = \Mockery::mock('Rootr\\Router');
     $controllerRouter->shouldReceive('getStaticRoutes')->andReturn(['' => ['GET' => ['Rootr\\ProductController', 'indexAction']]]);
     $controllerRouter->shouldReceive('getVariableRoutes')->andReturn(['/(\\d+)' => ['GET' => [['Rootr\\ProductController', 'showAction'], ['id']]]]);
     $controller = \Mockery::mock(['getRouter' => $controllerRouter]);
     $router->mountController('/products', $controller);
     assertThat($router->getStaticRoutes(), arrayWithSize(1));
     assertThat($router->getStaticRoutes(), hasKeyInArray('/products'));
     assertThat($router->getVariableRoutes(), arrayWithSize(1));
     assertThat($router->getVariableRoutes(), hasKeyInArray('/products/(\\d+)'));
 }
Пример #4
0
 /** @group Functional */
 public function testRunMonkBulkScanWithAShortSearch()
 {
     $this->setUpTables();
     $this->setUpRepo();
     $userId = 2;
     $groupId = 2;
     $uploadTreeId = 1;
     $licenseId = 225;
     $removing = false;
     $refText = "The GNU";
     $bulkId = $this->licenseDao->insertBulkLicense($userId, $groupId, $uploadTreeId, array($licenseId => $removing), $refText);
     $this->assertGreaterThan($expected = 0, $bulkId);
     $jobId = 64;
     list($output, $retCode) = $this->runBulkMonk($userId, $groupId, $jobId, $bulkId);
     $this->rmRepo();
     $this->assertEquals($retCode, 0, 'monk bulk failed: ' . $output);
     $bounds6 = new ItemTreeBounds(6, 'uploadtree_a', 1, 17, 18);
     $bounds7 = new ItemTreeBounds(7, 'uploadtree_a', 1, 15, 16);
     $relevantDecisionsItem6 = $this->clearingDao->getRelevantClearingEvents($bounds6, $groupId);
     $relevantDecisionsItem7 = $this->clearingDao->getRelevantClearingEvents($bounds7, $groupId);
     assertThat(count($relevantDecisionsItem6), is(equalTo(1)));
     assertThat(count($relevantDecisionsItem7), is(equalTo(1)));
     $rfForACE = 225;
     assertThat($relevantDecisionsItem6, hasKeyInArray($rfForACE));
     /** @var ClearingEvent $clearingEvent */
     $clearingEvent = $relevantDecisionsItem6[$rfForACE];
     $eventId = $clearingEvent->getEventId();
     $bulkHighlights = $this->highlightDao->getHighlightBulk(6, $eventId);
     $this->assertEquals(1, count($bulkHighlights));
     /** @var Highlight $bulkHighlight */
     $bulkHighlight = $bulkHighlights[0];
     $this->assertEquals($licenseId, $bulkHighlight->getLicenseId());
     $this->assertEquals(Highlight::BULK, $bulkHighlight->getType());
     $this->assertEquals(3, $bulkHighlight->getStart());
     $this->assertEquals(10, $bulkHighlight->getEnd());
     $bulkHighlights = $this->highlightDao->getHighlightBulk(6);
     $this->assertEquals(1, count($bulkHighlights));
     $this->assertEquals($bulkHighlight, $bulkHighlights[0]);
 }
Пример #5
0
 public function testRelevantClearingEvents()
 {
     $groupId = 701;
     $this->buildProposals(array(array(301, 1, $groupId, 401, false, -99), array(301, 2, $groupId, 402, true, -98), array(301, 2, $groupId, 401, true, -97)), $firstEventId = 0);
     $this->buildDecisions(array(array(301, 1, $groupId, DecisionTypes::IDENTIFIED, -90, DecisionScopes::REPO, array($firstEventId, $firstEventId + 1, $firstEventId + 2))));
     $itemTreeBounds = M::mock(ItemTreeBounds::classname());
     $itemTreeBounds->shouldReceive('getItemId')->andReturn(301);
     $itemTreeBounds->shouldReceive('getUploadTreeTableName')->andReturn('uploadtree');
     $itemTreeBounds->shouldReceive('containsFiles')->andReturn(false);
     $itemTreeBounds->shouldReceive('getUploadId')->andReturn($this->items[301][0]);
     $itemTreeBounds->shouldReceive('getLeft')->andReturn($this->items[301][4]);
     $itemTreeBounds->shouldReceive('getRight')->andReturn($this->items[301][5]);
     $events1 = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $groupId);
     assertThat($events1, arrayWithSize(2));
     assertThat($events1, hasKeyInArray(401));
     assertThat($events1, hasKeyInArray(402));
     assertThat($events1[401], is(anInstanceOf(ClearingEvent::classname())));
     assertThat($events1[402]->getEventId(), is($firstEventId + 1));
     assertThat($events1[401]->getEventId(), is($firstEventId + 2));
 }
 function testHighlightQueryOnBoost()
 {
     $serviceMock = $this->getServiceMock();
     Phockito::when($serviceMock)->search(anything(), anything(), anything(), anything(), anything())->return($this->getFakeRawSolrResponse());
     $index = new SolrIndexTest_FakeIndex();
     $index->setService($serviceMock);
     // Search without highlighting
     $query = new SearchQuery();
     $query->search('term', null, array('Field1' => 1.5, 'HasOneObject_Field1' => 3));
     $index->search($query);
     Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)', anything(), anything(), not(hasKeyInArray('hl.q')), anything());
     // Search with highlighting
     $query = new SearchQuery();
     $query->search('term', null, array('Field1' => 1.5, 'HasOneObject_Field1' => 3));
     $index->search($query, -1, -1, array('hl' => true));
     Phockito::verify($serviceMock)->search('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)', anything(), anything(), hasKeyInArray('hl.q'), anything());
 }