示例#1
0
 private function compileAccordingConditionsAndHackThemIntoQobj(array $extraProperties, $qobj, $qid)
 {
     $this->querySegmentListBuilder->setSortKeys($this->sortKeys);
     $this->querySegmentListBuilder->buildQuerySegmentFor(new Conjunction($extraProperties));
     $newQuerySegmentId = $this->querySegmentListBuilder->getLastQuerySegmentId();
     $this->querySegmentList = $this->querySegmentListBuilder->getQuerySegmentList();
     $this->errors = $this->querySegmentListBuilder->getErrors();
     $newQuerySegment = $this->querySegmentList[$newQuerySegmentId];
     // This is always an QuerySegment::Q_CONJUNCTION ...
     foreach ($newQuerySegment->components as $cid => $field) {
         // ... so just re-wire its dependencies
         $qobj->components[$cid] = $qobj->joinfield;
         $qobj->sortfields = array_merge($qobj->sortfields, $this->querySegmentList[$cid]->sortfields);
     }
     $this->querySegmentList[$qid] = $qobj;
 }
 public function testClassDescription()
 {
     $objectIds = $this->getMockBuilder('\\stdClass')->setMethods(array('getSMWPageID'))->getMock();
     $objectIds->expects($this->any())->method('getSMWPageID')->will($this->returnValue(42));
     $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock();
     $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $store->expects($this->once())->method('getObjectIds')->will($this->returnValue($objectIds));
     $description = new ClassDescription(new DIWikiPage('Foo', NS_CATEGORY));
     $instance = new QuerySegmentListBuilder($store);
     $instance->buildQuerySegmentFor($description);
     $expectedClass = new \stdClass();
     $expectedClass->type = 1;
     $expectedClass->alias = "t0";
     $expectedClass->queryNumber = 0;
     $expectedHierarchy = new \stdClass();
     $expectedHierarchy->type = 5;
     $expectedHierarchy->joinfield = array(0 => 42);
     $expectedHierarchy->alias = "t1";
     $expectedHierarchy->queryNumber = 1;
     $this->assertEquals(0, $instance->getLastQuerySegmentId());
     $this->assertEmpty($instance->getErrors());
     $expected = array($expectedClass, $expectedHierarchy);
     $this->querySegmentValidator->assertThatContainerContains($expected, $instance->getQuerySegmentList());
 }