예제 #1
0
 /**
  * Sets job arguments
  */
 protected function setArgs()
 {
     $subject = new \Tripod\Mongo\ImpactedSubject(array(_ID_RESOURCE => 'http://example.com/resources/foo', _ID_CONTEXT => 'http://talisaspire.com/'), OP_VIEWS, 'tripod_php_testing', 'CBD_testing');
     $this->args = array('tripodConfig' => \Tripod\Mongo\Config::getConfig(), 'subjects' => array($subject->toArray()), 'statsConfig' => $this->getStatsDConfig());
 }
예제 #2
0
 public function testTableRowsGenerateWhenDefinedPredicateChanges()
 {
     foreach (\Tripod\Mongo\Config::getInstance()->getTableSpecifications($this->tripod->getStoreName()) as $specId => $spec) {
         $this->generateTableRows($specId);
     }
     $uri = "http://talisaspire.com/resources/3SplCtWGPqEyXcDiyhHQpA-2";
     /** @var PHPUnit_Framework_MockObject_MockObject|\Tripod\Mongo\Driver $tripod */
     $tripod = $this->getMock('\\Tripod\\Mongo\\Driver', array('getComposite'), array($this->defaultPodName, $this->defaultStoreName, array('defaultContext' => $this->defaultContext, 'async' => array(OP_VIEWS => true, OP_TABLES => false, OP_SEARCH => true))));
     $labeller = new \Tripod\Mongo\Labeller();
     $subjectsAndPredicatesOfChange = array($labeller->uri_to_alias($uri) => array("dct:title"));
     /** @var \Tripod\Mongo\Composites\Tables|PHPUnit_Framework_MockObject_MockObject $mockTables */
     $tables = $this->getMock('\\Tripod\\Mongo\\Composites\\Tables', array('generateTableRows'), array($tripod->getStoreName(), $this->getTripodCollection($tripod), "http://talisaspire.com/"));
     $tables->expects($this->exactly(2))->method('generateTableRows')->withConsecutive(array($this->equalTo('t_distinct'), $this->equalTo($uri), $this->equalTo($this->defaultContext)), array($this->equalTo('t_join_source_count_regex'), $this->equalTo($uri), $this->equalTo($this->defaultContext)));
     $tripod->expects($this->once())->method('getComposite')->with(OP_TABLES)->will($this->returnValue($tables));
     // Walk through the processSyncOperations process manually for tables
     /** @var \Tripod\Mongo\Composites\Tables $table */
     $table = $tripod->getComposite(OP_TABLES);
     $this->assertInstanceOf('\\Tripod\\Mongo\\Composites\\Tables', $table);
     $expectedImpactedSubject = new \Tripod\Mongo\ImpactedSubject(array(_ID_RESOURCE => $labeller->uri_to_alias($uri), _ID_CONTEXT => $this->defaultContext), OP_TABLES, $this->defaultStoreName, $this->defaultPodName, array("t_distinct", "t_join_source_count_regex"));
     $impactedSubjects = $table->getImpactedSubjects($subjectsAndPredicatesOfChange, $this->defaultContext);
     $impactedSubject = $impactedSubjects[0];
     $this->assertEquals($expectedImpactedSubject->getResourceId(), $impactedSubject->getResourceId());
     $this->assertEquals($expectedImpactedSubject->getOperation(), $impactedSubject->getOperation());
     $this->assertEquals($expectedImpactedSubject->getStoreName(), $impactedSubject->getStoreName());
     $this->assertEquals($expectedImpactedSubject->getPodName(), $impactedSubject->getPodName());
     // Order of these doesn't matter - so sort the spec types for matching
     $expectedSpecTypes = $expectedImpactedSubject->getSpecTypes();
     sort($expectedSpecTypes);
     $specTypes = $impactedSubject->getSpecTypes();
     sort($specTypes);
     $this->assertEquals($expectedSpecTypes, $specTypes);
     foreach ($impactedSubjects as $subject) {
         $table->update($subject);
     }
     // This should be 0, because we mocked the actual adding of the regenerated table.  If it's zero, however,
     // it means we successfully deleted the views with $uri1 in the impactIndex
     $collections = \Tripod\Mongo\Config::getInstance()->getCollectionsForTables($this->defaultStoreName);
     foreach ($collections as $collection) {
         $query = array('value._impactIndex' => array('r' => $labeller->uri_to_alias($uri), 'c' => $this->defaultContext), '_id.type' => array('$in' => array("t_distinct", "t_join_source_count_regex")));
         $this->assertEquals(0, $collection->count($query));
     }
 }