jenkins-bot has submitted this change and it was merged. Change subject: Follow-up a43af3bc: Add Import integration test ......................................................................
Follow-up a43af3bc: Add Import integration test Previously failing test until fixed by a43af3bc. Bug: T89307 Change-Id: I2be12fa7d439ba4ad7e00fdd0f73495322c870a6 --- A tests/phpunit/data/import/ImportLinkCacheIntegrationTest.xml A tests/phpunit/includes/ImportLinkCacheIntegrationTest.php 2 files changed, 155 insertions(+), 0 deletions(-) Approvals: TTO: Looks good to me, approved Jforrester: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/tests/phpunit/data/import/ImportLinkCacheIntegrationTest.xml b/tests/phpunit/data/import/ImportLinkCacheIntegrationTest.xml new file mode 100644 index 0000000..8949f40 --- /dev/null +++ b/tests/phpunit/data/import/ImportLinkCacheIntegrationTest.xml @@ -0,0 +1,43 @@ +<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.6/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.6/ http://www.mediawiki.org/xml/export-0.6.xsd" version="0.6" xml:lang="en-gb"> + <siteinfo> + <sitename>MW-19</sitename> + <base>http://localhost:8080/w/index.php/Main_Page</base> + <generator>MediaWiki 1.19.7</generator> + <case>first-letter</case> + </siteinfo> + <page> + <title>Lorem ipsum</title> + <ns>0</ns> + <id>493</id> + <sha1>94lztkh4kgb0mvjr87iyjfq4iv7ltlh</sha1> + <revision> + <id>1358</id> + <timestamp>2014-04-04T22:55:04Z</timestamp> + <contributor> + <username>Tester</username> + <id>1</id> + </contributor> + <text xml:space="preserve" bytes="979">[[Has text::Lorem ipsum dolor sit amet consectetuer Maecenas adipiscing Pellentesque id sem]]. [[Has page::Elit Aliquam urna interdum]] morbi faucibus id tellus ipsum semper wisi. [[Has page::Platea enim hendrerit]] pellentesque consectetuer scelerisque Sed est felis felis quis. Auctor Proin In dolor id et ipsum vel at vitae ut. Praesent elit convallis Praesent aliquet pellentesque vel dolor pellentesque lacinia vitae. At tortor lacus Sed In interdum pulvinar et. + +[[Has number::1001]] [[Has quantity::10.25 km²]] [[Has date::1 Jan 2014]] [[Has Url::http://loremipsum.org/]] [[Has annotation uri::http://loremipsum.org/foaf.rdf]] [[Has email::lo...@ipsum.org]] [[Has temperature::100 °C]] [[Has boolean::true]] + +[[Category:Lorem ipsum]]</text> + </revision> + </page> + <page> + <title>Category:Lorem ipsum</title> + <ns>14</ns> + <id>496</id> + <sha1>sir97j6uzt9ev2uyhaz1aj4i3spogih</sha1> + <revision> + <id>1355</id> + <timestamp>2014-04-04T22:29:18Z</timestamp> + <contributor> + <username>Tester</username> + <id>1</id> + </contributor> + <text xml:space="preserve" bytes="17">[[Category:Main]]</text> + </revision> + </page> +</mediawiki> + diff --git a/tests/phpunit/includes/ImportLinkCacheIntegrationTest.php b/tests/phpunit/includes/ImportLinkCacheIntegrationTest.php new file mode 100644 index 0000000..1433b89 --- /dev/null +++ b/tests/phpunit/includes/ImportLinkCacheIntegrationTest.php @@ -0,0 +1,112 @@ +<?php +/** + * Integration test that checks import success and + * LinkCache integration. + * + * @group medium + * @group Database + * + * @author mwjames + */ +class ImportLinkCacheIntegrationTest extends MediaWikiTestCase { + + private $importStreamSource; + + protected function setUp() { + parent::setUp(); + + $file = dirname( __DIR__ ) . '/data/import/ImportLinkCacheIntegrationTest.xml'; + + $this->importStreamSource = ImportStreamSource::newFromFile( $file ); + + if ( !$this->importStreamSource->isGood() ) { + throw new Exception( "Import source for {$file} failed" ); + } + } + + public function testImportForImportSource() { + + $this->doImport( $this->importStreamSource ); + + // Imported title + $loremIpsum = Title::newFromText( 'Lorem ipsum' ); + + $this->assertSame( + $loremIpsum->getArticleID(), + $loremIpsum->getArticleID( Title::GAID_FOR_UPDATE ) + ); + + $categoryLoremIpsum = Title::newFromText( 'Category:Lorem ipsum' ); + + $this->assertSame( + $categoryLoremIpsum->getArticleID(), + $categoryLoremIpsum->getArticleID( Title::GAID_FOR_UPDATE ) + ); + + $page = new WikiPage( $loremIpsum ); + $page->doDeleteArticle( 'import test: delete page' ); + + $page = new WikiPage( $categoryLoremIpsum ); + $page->doDeleteArticle( 'import test: delete page' ); + } + + /** + * @depends testImportForImportSource + */ + public function testReImportForImportSource() { + + $this->doImport( $this->importStreamSource ); + + // ReImported title + $loremIpsum = Title::newFromText( 'Lorem ipsum' ); + + $this->assertSame( + $loremIpsum->getArticleID(), + $loremIpsum->getArticleID( Title::GAID_FOR_UPDATE ) + ); + + $categoryLoremIpsum = Title::newFromText( 'Category:Lorem ipsum' ); + + $this->assertSame( + $categoryLoremIpsum->getArticleID(), + $categoryLoremIpsum->getArticleID( Title::GAID_FOR_UPDATE ) + ); + } + + private function doImport( $importStreamSource ) { + + $importer = new WikiImporter( + $importStreamSource->value, + ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) + ); + $importer->setDebug( true ); + + $reporter = new ImportReporter( + $importer, + false, + '', + false + ); + + $reporter->setContext( new RequestContext() ); + $reporter->open(); + $exception = false; + + try { + $importer->doImport(); + } catch ( Exception $e ) { + $exception = $e; + } + + $result = $reporter->close(); + + $this->assertFalse( + $exception + ); + + $this->assertTrue( + $result->isGood() + ); + } + +} -- To view, visit https://gerrit.wikimedia.org/r/190127 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2be12fa7d439ba4ad7e00fdd0f73495322c870a6 Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: TTO <at.li...@live.com.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits