protected function alterPageContentToCreateNewRevisionWithoutAnnotations()
 {
     $pageCreator = new PageCreator();
     $pageCreator->createPage($this->title)->doEdit('No annotations');
     $this->testEnvironment->executePendingDeferredUpdates();
     return $pageCreator->getPage()->getRevision()->getId();
 }
 public function testDoUpdate()
 {
     $title = Title::newFromText(__METHOD__);
     $subject = DIWikiPage::newFromTitle($title);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($title)->doEdit('[[Has some property::LinksUpdateConstructedOnEmptyParserOutput]]');
     $propertiesCountBeforeUpdate = count($this->getStore()->getSemanticData($subject)->getProperties());
     $linksUpdate = new LinksUpdate($title, new ParserOutput());
     $linksUpdate->doUpdate();
     $this->assertCount($propertiesCountBeforeUpdate, $this->getStore()->getSemanticData($subject)->getProperties());
 }
 public function testCreatePageWithSubobject()
 {
     $this->title = Title::newFromText(__METHOD__);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($this->title)->doEdit('{{#subobject:namedSubobject|AA=Test1|@sortkey=Z}}' . '{{#subobject:|BB=Test2|@sortkey=Z}}');
     $semanticData = $this->getStore()->getSemanticData(DIWikiPage::newFromTitle($this->title));
     $this->assertInstanceOf('SMW\\SemanticData', $semanticData->findSubSemanticData('namedSubobject'));
     $expected = array('propertyCount' => 2, 'properties' => array(new DIProperty('AA'), new DIProperty('BB'), new DIProperty('_SKEY')), 'propertyValues' => array('Test1', 'Test2', 'Z'));
     $semanticDataValidator = new SemanticDataValidator();
     foreach ($semanticData->getSubSemanticData() as $subSemanticData) {
         $semanticDataValidator->assertThatPropertiesAreSet($expected, $subSemanticData);
     }
 }
 public function testDoUpdate()
 {
     $title = Title::newFromText(__METHOD__);
     $subject = DIWikiPage::newFromTitle($title);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($title)->doEdit('[[Has some property::LinksUpdateConstructedOnEmptyParserOutput]]');
     $propertiesCountBeforeUpdate = count($this->getStore()->getSemanticData($subject)->getProperties());
     /**
      * See #347 and LinksUpdateConstructed
      */
     $linksUpdate = new LinksUpdate($title, new ParserOutput());
     $linksUpdate->doUpdate();
     /**
      * Asserts that before and after the update, the SemanticData container
      * holds the same amount of properties despite the fact that the ParserOutput
      * was invoked empty
      */
     $this->assertCount($propertiesCountBeforeUpdate, $this->getStore()->getSemanticData($subject)->getProperties());
 }
 public function testSearchForGeographicCoordinateValueAsTerm()
 {
     if (!defined('SM_VERSION')) {
         $this->markTestSkipped("Requires 'Geographic coordinate' to be a supported data type (see Semantic Maps)");
     }
     $propertyPage = Title::newFromText('Has coordinates', SMW_NS_PROPERTY);
     $targetPage = Title::newFromText(__METHOD__);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($propertyPage)->doEdit('[[Has type::Geographic coordinate]]');
     $pageCreator->createPage($targetPage)->doEdit("[[Has coordinates::52°31'N, 13°24'E]]");
     $search = new Search();
     $results = $search->searchTitle("[[Has coordinates::52°31'N, 13°24'E]]");
     $this->assertInstanceOf('\\SMW\\MediaWiki\\Search\\SearchResultSet', $results);
     if (is_a($this->getStore(), '\\SMW\\SPARQLStore\\SPARQLStore')) {
         $this->markTestIncomplete("Test was marked as incomplete because the SPARQLStore doesn't support the Geo data type");
     }
     $this->assertEquals(1, $results->getTotalHits());
     $pageDeleter = new PageDeleter();
     $pageDeleter->deletePage($targetPage);
     $pageDeleter->deletePage($propertyPage);
 }
 public function testOnOutputPageParserOutputeOnDatabase()
 {
     $this->title = Title::newFromText(__METHOD__);
     $pageCreator = new PageCreator();
     $pageCreator->createPage($this->title)->doEdit('[[Has function hook test::output page]]');
     $parserOutput = $pageCreator->getEditInfo()->output;
     $this->assertInstanceOf('ParserOutput', $parserOutput);
     $context = new RequestContext();
     $context->setTitle($this->title);
     // Use of OutputPage::addParserOutputNoText was deprecated in MediaWiki 1.24
     if (method_exists($context->getOutput(), 'addParserOutputMetadata')) {
         $context->getOutput()->addParserOutputMetadata($parserOutput);
     } else {
         $context->getOutput()->addParserOutputNoText($parserOutput);
     }
 }
 private function createPageContentFrom(Title $title, $pageCopyThreshold, $useSamePage = false)
 {
     $this->getBenchmarker()->clear();
     $pageReader = new PageReader();
     $text = $pageReader->getContentAsText($title);
     $pageCreator = new PageCreator();
     $baseName = $useSamePage ? 'CopyOf' . $title->getText() : $title->getText();
     $memoryBefore = memory_get_peak_usage(false);
     for ($i = 0; $i < $pageCopyThreshold; $i++) {
         $start = microtime(true);
         $pageCreator->createPage(Title::newFromText($baseName . ($useSamePage ? '' : '-' . $i)), $text);
         $this->getBenchmarker()->addBenchmarkPoint(microtime(true) - $start);
     }
     $memoryAfter = memory_get_peak_usage(false);
     $memoryDiff = $memoryAfter - $memoryBefore;
     $sum = $this->getBenchmarker()->getSum();
     $mean = $this->getBenchmarker()->getMean();
     $sd = $this->getBenchmarker()->getStandardDeviation();
     $norm = $this->getBenchmarker()->getNormalizedValueBy($pageCopyThreshold);
     $this->addMessage("- '{$title->getText()}': {$norm} (n) {$mean} (mean) {$sum} (total) {$sd} (sd) (sec)");
     if ($this->showMemoryUsage) {
         $this->addMessage("+- Memory: {$memoryBefore} (before) {$memoryAfter} (after) {$memoryDiff} (diff)");
     }
 }
 protected function alterPageContentToCreateNewRevisionWithoutAnnotations()
 {
     $pageCreator = new PageCreator();
     $pageCreator->createPage($this->title)->doEdit('No annotations');
     return $pageCreator->getPage()->getRevision()->getId();
 }
 public function testCreatePageWithSubobjectPropertyChainQueryResultLookup()
 {
     $pageCreator = new PageCreator();
     $this->titles[] = Title::newFromText('Dreamland');
     $pageCreator->createPage($this->titles[0])->doEdit('{{#set:|Located in=Fairyland}}');
     $this->titles[] = Title::newFromText('Fairyland');
     $pageCreator->createPage($this->titles[1])->doEdit('{{#subobject:|Member of=Wonderland}}');
     $description = $this->queryParser->getQueryDescription('[[Located in.Has subobject.Member of::Wonderland]]');
     $query = new Query($description, false, false);
     $query->querymode = Query::MODE_COUNT;
     $result = $this->getStore()->getQueryResult($query);
     $this->assertEquals(1, $result instanceof \SMWQueryResult ? $result->getCountValue() : $result);
     $query->querymode = Query::MODE_INSTANCES;
     $this->queryResultValidator->assertThatQueryResultHasSubjects(new DIWikiPage('Dreamland', NS_MAIN, ''), $this->getStore()->getQueryResult($query));
 }
 private function createDummyPage()
 {
     $pageCreator = new PageCreator();
     $pageCreator->createPage(Title::newFromText('SMWUTDummyPage'))->doEdit('SMW dummy page');
 }