private function doMatchSubcategory(&$subjects, DIWikiPage $category)
 {
     $subcategories = $this->propertyHierarchyLookup->findSubcategoryListFor($category);
     foreach ($subcategories as $subcategory) {
         if ($this->propertyHierarchyLookup->hasSubcategoryFor($subcategory)) {
             $this->doMatchSubcategory($subjects, $subcategory);
         }
         $subjects[] = $subcategory;
     }
 }
 public function testFindSubcategoryList()
 {
     $category = DIWikiPage::newFromText('Foo', NS_CATEGORY);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->once())->method('getPropertySubjects')->with($this->equalTo(new DIProperty('_SUBC')), $this->equalTo($category), $this->anything())->will($this->returnValue(array(DIWikiPage::newFromText('Bar', NS_CATEGORY))));
     $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('_SUBC#Foo#-1#0##1##1#'), $this->anything());
     $instance = new PropertyHierarchyLookup($store, $cache);
     $expected = array(DIWikiPage::newFromText('Bar', NS_CATEGORY));
     $this->assertEquals($expected, $instance->findSubcategoryListFor($category));
 }
 private function doMatchSubcategory(&$subjects, DIWikiPage $category)
 {
     $hash = $category->getHash();
     $subcategories = array();
     // #1713
     // Safeguard against a possible category (or redirect thereof) to point
     // to itself by relying on tracking the hash of already inserted objects
     if (!isset($subjects[$hash])) {
         $subcategories = $this->propertyHierarchyLookup->findSubcategoryListFor($category);
     }
     foreach ($subcategories as $subcategory) {
         $subjects[$subcategory->getHash()] = $subcategory;
         if ($this->propertyHierarchyLookup->hasSubcategoryFor($subcategory)) {
             $this->doMatchSubcategory($subjects, $subcategory);
         }
     }
 }