From c11667a4ca284ae44238bdd2848e3ebbc3442782 Mon Sep 17 00:00:00 2001 From: georggi Date: Tue, 5 Jan 2016 14:02:03 +0200 Subject: [PATCH] PHPUnit: Added test for unknown tags Bug: T43938 Change-Id: Idcb1576db39cc1d925207a37b4f22b40d76fea8b --- tests/phpunit/includes/import/ImportTest.php | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/phpunit/includes/import/ImportTest.php b/tests/phpunit/includes/import/ImportTest.php index 9c224309bb..f4aac235a2 100644 --- a/tests/phpunit/includes/import/ImportTest.php +++ b/tests/phpunit/includes/import/ImportTest.php @@ -13,6 +13,66 @@ class ImportTest extends MediaWikiLangTestCase { return new ImportStringSource( $xml ); } + /** + * @covers WikiImporter + * @dataProvider getUnknownTagsXML + * @param string $xml + * @param string $text + * @param string $title + */ + public function testUnknownXMLTags( $xml, $text, $title ) { + $source = $this->getDataSource( $xml ); + + $importer = new WikiImporter( + $source, + ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) + ); + + $importer->doImport(); + $title = Title::newFromText( $title ); + $this->assertTrue( $title->exists() ); + + $this->assertEquals( WikiPage::factory( $title )->getContent()->getNativeData(), $text ); + } + + public function getUnknownTagsXML() { + // @codingStandardsIgnoreStart Generic.Files.LineLength + return array( + array( + <<< EOF + + + TestImportPage + Should be ignored + 0 + 14 + + 15 + Should be ignored + 2016-01-03T11:18:43Z + + Should be ignored + Admin + 1 + + wikitext + text/x-wiki + noitazinagro tseb eht si ikiWaideM + phoiac9h4m842xq45sp7s6u21eteeq1 + Should be ignored + + + Should be ignored + +EOF + , + 'noitazinagro tseb eht si ikiWaideM', + 'TestImportPage' + ) + ); + // @codingStandardsIgnoreEnd + } + /** * @covers WikiImporter::handlePage * @dataProvider getRedirectXML -- 2.20.1