/**
  * @throws RuntimeException
  * @return boolean
  */
 public function run()
 {
     $this->unregisterUploadsource();
     $start = microtime(true);
     $config = null;
     $source = ImportStreamSource::newFromFile($this->assertThatFileIsReadableOrThrowException($this->file));
     if (!$source->isGood()) {
         throw new RuntimeException('Import returned with error(s) ' . serialize($source->errors));
     }
     // WikiImporter::__construct without a Config instance was deprecated in MediaWiki 1.25.
     if (class_exists('\\ConfigFactory')) {
         $config = \ConfigFactory::getDefaultInstance()->makeConfig('main');
     }
     $importer = new WikiImporter($source->value, $config);
     $importer->setDebug($this->verbose);
     $reporter = new ImportReporter($importer, false, '', false);
     $reporter->setContext($this->acquireRequestContext());
     $reporter->open();
     $this->exception = false;
     try {
         $importer->doImport();
     } catch (\Exception $e) {
         $this->exception = $e;
     }
     $this->result = $reporter->close();
     $this->importTime = microtime(true) - $start;
     $this->testEnvironment->executePendingDeferredUpdates();
     return $this->result->isGood() && !$this->exception;
 }
 protected function setUp()
 {
     parent::setUp();
     $this->descriptionFactory = new DescriptionFactory();
     $testEnvironment = new TestEnvironment();
     $this->querySegmentValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newQuerySegmentValidator();
 }
 protected function setUp()
 {
     parent::setUp();
     $testEnvironment = new TestEnvironment();
     $this->semanticDataFactory = $testEnvironment->getUtilityFactory()->newSemanticDataFactory();
     $this->semanticDataValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newSemanticDataValidator();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->descriptionInterpreterFactory = new DescriptionInterpreterFactory();
     $testEnvironment = new TestEnvironment();
     $this->querySegmentValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newQuerySegmentValidator();
 }
 protected function setUp()
 {
     parent::setUp();
     $this->descriptionFactory = new DescriptionFactory();
     $this->dataItemFactory = new DataItemFactory();
     $this->descriptionInterpreterFactory = $this->getMockBuilder('\\SMW\\SQLStore\\QueryEngine\\DescriptionInterpreterFactory')->disableOriginalConstructor()->getMock();
     $testEnvironment = new TestEnvironment();
     $this->querySegmentValidator = $testEnvironment->getUtilityFactory()->newValidatorFactory()->newQuerySegmentValidator();
 }
 protected function tearDown()
 {
     // If setUp is skipped early this might not be initialized
     if ($this->testEnvironment !== null) {
         $this->testEnvironment->tearDown();
     }
     ApplicationFactory::clear();
     NamespaceExaminer::clear();
     PropertyRegistry::clear();
     Settings::clear();
     Exporter::getInstance()->clear();
     parent::tearDown();
 }
Пример #7
0
 /**
  * @since 1.9.2
  */
 public function run()
 {
     $conds = '';
     if ($this->type !== null) {
         $conds = "job_cmd = " . $this->dbConnectionProvider->getConnection()->addQuotes($this->type);
     }
     while ($this->dbConnectionProvider->getConnection()->selectField('job', 'job_id', $conds, __METHOD__)) {
         $job = $this->type === null ? $this->pop() : $this->pop_type($this->type);
         if (!$job) {
             break;
         }
         wfWaitForSlaves();
         $this->status[] = array('type' => $job->command, 'status' => $job->run());
     }
     $this->testEnvironment->executePendingDeferredUpdates();
 }
Пример #8
0
 /**
  * @since 2.1
  *
  * @param array $poolOfPages
  */
 public function doDeletePoolOfPages(array $poolOfPages)
 {
     foreach ($poolOfPages as $page) {
         if ($page instanceof WikiPage || $page instanceof DIWikiPage) {
             $page = $page->getTitle();
         }
         if (is_string($page)) {
             $page = Title::newFromText($page);
         }
         if (!$page instanceof Title) {
             continue;
         }
         $this->deletePage($page);
     }
     $this->testEnvironment->executePendingDeferredUpdates();
 }
 public function textDataProvider()
 {
     $testEnvironment = new TestEnvironment();
     $provider = array();
     // #0 NS_MAIN; [[FooBar...]] with a different caption
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[FooBar::dictumst|寒い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[Bar::tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[foo::9001]] et Donec.', array('resultText' => 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[:Dictumst|寒い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[:Tincidunt semper|tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[:9001|9001]] et Donec.', 'propertyCount' => 3, 'propertyLabels' => array('Foo', 'Bar', 'FooBar'), 'propertyValues' => array('Dictumst', 'Tincidunt semper', '9001')));
     // #1 NS_MAIN; [[FooBar...]] with a different caption and smwgLinksInValues = true
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => true, 'smwgInlineErrors' => true), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[FooBar::dictumst|寒い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[Bar::[[tincidunt semper]]]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[foo::[http:://www/foo/9001] ]] et Donec.', array('resultText' => 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[:Dictumst|寒い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[:Tincidunt semper|tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis' . ' [[:Http:://www/foo/9001|http:://www/foo/9001]] et Donec.', 'propertyCount' => 3, 'propertyLabels' => array('Foo', 'Bar', 'FooBar'), 'propertyValues' => array('Dictumst', 'Tincidunt semper', 'Http:://www/foo/9001')));
     // #2 NS_MAIN, [[-FooBar...]] produces an error with inlineErrors = true
     // (only check for an indication of an error in 'resultText' )
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[-FooBar::dictumst|重い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[Bar::tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[foo::9001]] et Donec.', array('resultText' => 'class="smw-highlighter" data-type="4" data-state="inline"', 'strictPropertyValueMatch' => false, 'propertyCount' => 3, 'propertyKeys' => array('Foo', 'Bar', '_ERRC'), 'propertyValues' => array('Tincidunt semper', '9001')));
     // #3 NS_MAIN, [[-FooBar...]] produces an error but inlineErrors = false
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => false), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[-FooBar::dictumst|軽い]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[Bar::tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[foo::9001]] et Donec.', array('resultText' => 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' 軽い cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[:Tincidunt semper|tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[:9001|9001]] et Donec.', 'strictPropertyValueMatch' => false, 'propertyCount' => 3, 'propertyKeys  ' => array('Foo', 'Bar', '_ERRC'), 'propertyValues' => array('Tincidunt semper', '9001')));
     // #4 NS_HELP disabled
     $provider[] = array(NS_HELP, array('smwgNamespacesWithSemanticLinks' => array(NS_HELP => false), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[FooBar::dictumst|おもろい]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[Bar::tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[foo::9001]] et Donec.', array('resultText' => 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' [[:Dictumst|おもろい]] cursus. Nisl sit condimentum Quisque facilisis' . ' Suspendisse [[:Tincidunt semper|tincidunt semper]] facilisi dolor Aenean. Ut' . ' Aliquam {{volutpat}} arcu ultrices eu Ut quis [[:9001|9001]] et Donec.', 'propertyCount' => 0, 'propertyLabels' => array(), 'propertyValues' => array()));
     // #5 NS_HELP enabled but no properties or links at all
     $provider[] = array(NS_HELP, array('smwgNamespacesWithSemanticLinks' => array(NS_HELP => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' Suspendisse tincidunt semper facilisi dolor Aenean.', array('resultText' => 'Lorem ipsum dolor sit &$% consectetuer auctor at quis' . ' Suspendisse tincidunt semper facilisi dolor Aenean.', 'propertyCount' => 0, 'propertyLabels' => array(), 'propertyValues' => array()));
     // #6 Bug 54967
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), '[[Foo::?bar]], [[Foo::Baz?]], [[Quxey::B?am]]', array('resultText' => '[[:?bar|?bar]], [[:Baz?|Baz?]], [[:B?am|B?am]]', 'propertyCount' => 2, 'propertyLabels' => array('Foo', 'Quxey'), 'propertyValues' => array('?bar', 'Baz?', 'B?am')));
     #7 673
     // Special:Types/Number
     $specialTypeName = \SpecialPage::getTitleFor('Types', 'Number')->getPrefixedText();
     $provider[] = array(SMW_NS_PROPERTY, array('smwgNamespacesWithSemanticLinks' => array(SMW_NS_PROPERTY => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), '[[has type::number]], [[has Type::page]] ', array('resultText' => "[[{$specialTypeName}|number]], [[:Page|page]]", 'propertyCount' => 2, 'propertyLabels' => array('Has type', 'Has Type'), 'propertyValues' => array('Number', 'Page')));
     #8 1048, Double-double
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), '[[Foo::Bar::Foobar]], [[IPv6::fc00:123:8000::/64]] [[ABC::10.1002/::AID-MRM16::]]', array('resultText' => '[[:Bar::Foobar|Bar::Foobar]], [[:Fc00:123:8000::/64|fc00:123:8000::/64]] [[:10.1002/::AID-MRM16::|10.1002/::AID-MRM16::]]', 'propertyCount' => 3, 'propertyLabels' => array('Foo', 'IPv6', 'ABC'), 'propertyValues' => array('Bar::Foobar', 'Fc00:123:8000::/64', '10.1002/::AID-MRM16::')));
     #9 T32603
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true), '[[Foo:::Foobar]] [[Bar:::ABC|DEF]] [[Foo:::0049 30 12345678/::Foo]] ', array('resultText' => '[[:Foobar|Foobar]] [[:ABC|DEF]] [[:0049 30 12345678/::Foo|0049 30 12345678/::Foo]]', 'propertyCount' => 2, 'propertyLabels' => array('Foo', 'Bar'), 'propertyValues' => array('Foobar', '0049 30 12345678/::Foo', 'ABC')));
     #10 #1252 (disabled strict mode)
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true, 'smwgEnabledInTextAnnotationParserStrictMode' => false), '[[Foo::Foobar::テスト]] [[Bar:::ABC|DEF]] [[Foo:::0049 30 12345678/::Foo]] ', array('resultText' => '[[:テスト|テスト]] [[:ABC|DEF]] [[:Foo|Foo]]', 'propertyCount' => 4, 'propertyLabels' => array('Foo', 'Bar:', 'Foobar', ':0049 30 12345678/'), 'propertyValues' => array('Foobar', 'Foo', 'ABC', 'テスト')));
     #11 #1747 (left pipe)
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true, 'smwgEnabledInTextAnnotationParserStrictMode' => false), '[[Foo|Bar::Foobar]] [[File:Example.png|alt=Bar::Foobar|Caption]] [[File:Example.png|Bar::Foobar|link=Foo]]', array('resultText' => '[[Foo|Bar::Foobar]] [[File:Example.png|alt=Bar::Foobar|Caption]] [[File:Example.png|Bar::Foobar|link=Foo]]', 'propertyCount' => 0));
     #12 #1747 (left pipe + including one annotation)
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true, 'smwgEnabledInTextAnnotationParserStrictMode' => true), '[[Foo|Bar::Foobar]] [[File:Example.png|alt=Bar::Foobar|Caption]] [[Foo::Foobar::テスト]] [[File:Example.png|Bar::Foobar|link=Foo]]', array('resultText' => '[[Foo|Bar::Foobar]] [[File:Example.png|alt=Bar::Foobar|Caption]] [[:Foobar::テスト|Foobar::テスト]] [[File:Example.png|Bar::Foobar|link=Foo]]', 'propertyCount' => 1, 'propertyLabels' => array('Foo'), 'propertyValues' => array('Foobar::テスト')));
     #13 @@@ syntax
     $provider[] = array(NS_MAIN, array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgLinksInValues' => false, 'smwgInlineErrors' => true, 'smwgEnabledInTextAnnotationParserStrictMode' => true), '[[Foo::@@@]] [[Bar::@@@en|Foobar]]', array('resultText' => $testEnvironment->getLocalizedTextByNamespace(SMW_NS_PROPERTY, '[[:Property:Foo|Foo]] [[:Property:Bar|Foobar]]'), 'propertyCount' => 0));
     return $provider;
 }
Пример #10
0
 /**
  * @since 2.3
  *
  * @return PageCreator
  */
 public function doMoveTo(Title $target, $isRedirect = true)
 {
     $this->getPage()->getTitle()->moveTo($target, false, "integration test", $isRedirect);
     $this->testEnvironment->executePendingDeferredUpdates();
     return $this;
 }