public function descriptionProvider() { $descriptionFactory = new DescriptionFactory(); $dataItemFactory = new DataItemFactory(); #0 No concept $concept = false; $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT)); $expected = new \stdClass(); $expected->type = 1; $expected->joinfield = ''; $provider[] = array($description, $concept, $expected); #1 Cached concept $concept = new \stdClass(); $concept->concept_size = 1; $concept->concept_features = 1; $concept->concept_depth = 1; $concept->cache_date = strtotime("now"); $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT)); $expected = new \stdClass(); $expected->type = 1; $expected->joinfield = 't0.s_id'; $expected->where = 't0.o_id=42'; $expected->queryNumber = 0; $provider[] = array($description, $concept, $expected); #2 Non cached concept $concept = new \stdClass(); $concept->concept_txt = "[[Category:Foo]]"; $concept->concept_size = 1; $concept->concept_features = 1; $concept->concept_depth = 1; $concept->cache_date = false; $description = $descriptionFactory->newConceptDescription($dataItemFactory->newDIWikiPage('Foo', SMW_NS_CONCEPT)); $expected = new \stdClass(); $expected->type = 1; $expected->joinfield = 't1.s_id'; $expected->components = array(2 => 't1.o_id'); $expected->queryNumber = 1; $provider[] = array($description, $concept, $expected); return $provider; }
public function testCanConstructConceptDescription() { $concept = $this->getMockBuilder('\\SMW\\DIWikiPage')->disableOriginalConstructor()->getMock(); $instance = new DescriptionFactory(); $this->assertInstanceOf('SMW\\Query\\Language\\ConceptDescription', $instance->newConceptDescription($concept)); }