private function compileAccordingConditionsAndHackThemIntoQobj(array $extraProperties, $qobj, $qid)
 {
     $this->queryBuilder->setSortKeys($this->sortKeys);
     $this->queryBuilder->buildQuerySegmentFor(new Conjunction($extraProperties));
     $newQuerySegmentId = $this->queryBuilder->getLastQuerySegmentId();
     $this->querySegments = $this->queryBuilder->getQuerySegments();
     $this->errors = $this->queryBuilder->getErrors();
     $newQuerySegment = $this->querySegments[$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->querySegments[$cid]->sortfields);
     }
     $this->querySegments[$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 QueryBuilder($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->getQuerySegments());
 }