public function diWikiPageProvider() { // Constant $wiki = \SMWExporter::getInstance()->getNamespaceUri('wiki'); $property = \SMWExporter::getInstance()->getNamespaceUri('property'); #0 $provider[] = array(new DIWikiPage('Foo', NS_MAIN, '', ''), '', array('type' => Element::TYPE_NSRESOURCE, 'uri' => "Foo|{$wiki}|wiki", 'dataitem' => array('type' => 9, 'item' => 'Foo#0#'))); #1 $provider[] = array(new DIWikiPage('Foo', NS_MAIN, 'bar', ''), '', array('type' => Element::TYPE_NSRESOURCE, 'uri' => "bar-3AFoo|{$wiki}|wiki", 'dataitem' => array('type' => 9, 'item' => 'Foo#0#bar'))); #2 $provider[] = array(new DIWikiPage('Foo', NS_MAIN, 'bar', '1234'), '', array('type' => Element::TYPE_NSRESOURCE, 'uri' => "bar-3AFoo-231234|{$wiki}|wiki", 'dataitem' => array('type' => 9, 'item' => 'Foo#0#bar#1234'))); #3 Extra modififer doesn't not alter the object when a subobject is used $provider[] = array(new DIWikiPage('Foo', NS_MAIN, 'bar', '1234'), 'abc', array('type' => Element::TYPE_NSRESOURCE, 'uri' => "bar-3AFoo-231234|{$wiki}|wiki", 'dataitem' => array('type' => 9, 'item' => 'Foo#0#bar#1234'))); #4 $provider[] = array(new DIWikiPage('Foo', SMW_NS_PROPERTY, '', ''), '', array('type' => Element::TYPE_NSRESOURCE, 'uri' => "Foo|{$property}|property", 'dataitem' => array('type' => 9, 'item' => 'Foo#102#'))); #5 $provider[] = array(new DIWikiPage('Foo', SMW_NS_PROPERTY, '', ''), true, array('type' => Element::TYPE_NSRESOURCE, 'uri' => "Foo-23aux|{$property}|property", 'dataitem' => array('type' => 9, 'item' => 'Foo#102#'))); #6 $name = Escaper::encodePage(new DIWikiPage('-Foo', SMW_NS_PROPERTY, '', '')); $provider[] = array(new DIWikiPage('-Foo', SMW_NS_PROPERTY, '', ''), true, array('type' => Element::TYPE_NSRESOURCE, 'uri' => "{$name}-23aux|{$wiki}|wiki", 'dataitem' => array('type' => 9, 'item' => '-Foo#102#'))); return $provider; }
private function defineElementsForDiWikiPage(DIWikiPage $diWikiPage, $modifier) { $localName = ''; if ($diWikiPage->getNamespace() === SMW_NS_PROPERTY) { $namespace = Exporter::getInstance()->getNamespaceUri('property'); $namespaceId = 'property'; $localName = Escaper::encodeUri(rawurlencode($diWikiPage->getDBkey())); } if ($localName === '' || in_array($localName[0], array('-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) { $namespace = Exporter::getInstance()->getNamespaceUri('wiki'); $namespaceId = 'wiki'; $localName = Escaper::encodePage($diWikiPage); } // "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not // occuring in MW titles). if ($modifier !== '') { $localName .= '-23' . Escaper::encodeUri(rawurlencode($modifier)); } return array($localName, $namespace, $namespaceId); }
public function testExportSubobject() { $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__); $subobject = new Subobject($semanticData->getSubject()->getTitle()); $subobject->setEmptyContainerForId('Foo'); $semanticData->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer()); $exportData = Exporter::getInstance()->makeExportData($semanticData); $expectedProperty = new ExpNsResource($this->transformPropertyLabelToAuxiliary($subobject->getProperty()), Exporter::getInstance()->getNamespaceUri('property'), 'property', new DIWikiPage('Has_subobject', SMW_NS_PROPERTY)); $this->assertTrue(Exporter::getInstance()->hasHelperExpElement($subobject->getProperty())); $this->assertCount(1, $exportData->getValues($expectedProperty)); $this->exportDataValidator->assertThatExportDataContainsProperty($expectedProperty, $exportData); $expectedResource = new ExpNsResource(Escaper::encodePage($subobject->getSemanticData()->getSubject()) . '-23' . 'Foo', Exporter::getInstance()->getNamespaceUri('wiki'), 'wiki', $subobject->getSemanticData()->getSubject()); $this->exportDataValidator->assertThatExportDataContainsResource($expectedResource, $expectedProperty, $exportData); }
/** * @dataProvider encodePageProvider */ public function testEncodePage($page, $expected) { $this->assertSame($expected, Escaper::encodePage($page)); }
public function testRedirectTragetForDBLookupWithMultipleEntriesForcesNewResource() { $propertyPage = new DIWikiPage('Foo', SMW_NS_PROPERTY); $resource = new ExpNsResource('Foo', Exporter::getInstance()->getNamespaceUri('property'), 'property', $propertyPage); $repositoryConnection = $this->createRepositoryConnectionMockToUse(array($resource, $resource)); $instance = new RedirectLookup($repositoryConnection); $instance->reset(); $dataItem = new DIWikiPage('Foo', 1, '', ''); $expNsResource = new ExpNsResource('Foo', 'Bar', '', $dataItem); $exists = null; $targetResource = $instance->findRedirectTargetResource($expNsResource, $exists); $this->assertNotSame($expNsResource, $targetResource); $expectedResource = new ExpNsResource(Escaper::encodePage($propertyPage), Exporter::getInstance()->getNamespaceUri('wiki'), 'wiki'); $this->assertEquals($expectedResource, $targetResource); $this->assertTrue($exists); }