private function doMatchSubproperty(&$subjects, DIProperty $property) { $subproperties = $this->propertyHierarchyLookup->findSubpropertListFor($property); foreach ($subproperties as $subproperty) { $this->doMatchProperty($subjects, new DIProperty($subproperty->getDBKey())); } }
public function testFindSubpropertyList() { $property = new DIProperty('Foo'); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->once())->method('getPropertySubjects')->with($this->equalTo(new DIProperty('_SUBP')), $this->equalTo($property->getDiWikiPage()), $this->anything())->will($this->returnValue(array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY)))); $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMock(); $cache->expects($this->once())->method('contains')->will($this->returnValue(false)); $cache->expects($this->once())->method('save')->with($this->equalTo('_SUBP#Foo#-1#0##1##1#'), $this->anything()); $instance = new PropertyHierarchyLookup($store, $cache); $expected = array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY)); $this->assertEquals($expected, $instance->findSubpropertListFor($property)); }
private function doMatchSubproperty(&$subjects, $subject, DIProperty $property) { $subproperties = array(); // Using the DBKey as short-cut, as we don't expect to match sub-properties for // pre-defined properties instead it should be sufficient for user-defined // properties to rely on the normalized DBKey (e.g Has_page) if (!isset($subjects[$subject->getHash()]) && !isset($this->propertyDependencyExemptionlist[$subject->getDBKey()])) { $subproperties = $this->propertyHierarchyLookup->findSubpropertListFor($property); } foreach ($subproperties as $subproperty) { if (isset($this->propertyDependencyExemptionlist[$subproperty->getDBKey()])) { continue; } $subjects[$subproperty->getHash()] = $subproperty; $this->doMatchProperty($subjects, new DIProperty($subproperty->getDBKey())); } }