/** * @dataProvider importDataProvider */ public function testMapWikiPageToResourceElementForImportMatch($dataItem, $expected) { $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->once())->method('getPropertyValues')->will($this->returnValue(array(new \SMWDIBlob('foo:bar:fom:fuz')))); $instance = new CachedDataItemToExpResourceEncoder($store); $resource = $instance->mapWikiPageToResourceElement($dataItem); $this->assertSame($expected, $resource->getSerialization()); }
public function testMapWikiPageToResourceElementForImportMatch() { $dataItem = new DIWikiPage('Foo', SMW_NS_PROPERTY, '', ''); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->once())->method('getPropertyValues')->will($this->returnValue(array(new \SMWDIBlob('foo:bar:fom:fuz')))); $instance = new CachedDataItemToExpResourceEncoder($store); $resource = $instance->mapWikiPageToResourceElement($dataItem); // || is not the result we normally would expect but mocking the // dataValueFactory at this point is not worth the hassle therefore // we live with || output $expected = array('type' => Element::TYPE_NSRESOURCE, 'uri' => "||", 'dataitem' => array('type' => 9, 'item' => 'Foo#102#')); $this->assertSame($expected, $resource->getSerialization()); }
/** * @see CachedDataItemToExpResourceEncoder::mapWikiPageToResourceElement */ public static function getResourceElementForWikiPage(SMWDIWikiPage $diWikiPage, $markForAuxiliaryUsage = false) { return self::$cachedDataItemToExpResourceEncoder->mapWikiPageToResourceElement($diWikiPage, $markForAuxiliaryUsage); }