Jarry1250 has submitted this change and it was merged. Change subject: Add testImportTranslations() and testGetOnWikiLanguages() ......................................................................
Add testImportTranslations() and testGetOnWikiLanguages() ...to SVGMessageGroup testing cycle. * Make one test platform independent (re: line-endings) * Flush database writes later to avoid uncommitted transactions * Note that MessageGroupStats regeneration is pretty expensive (I4625398) Change-Id: I7a2a3ee65a66e8b3ba41a38a0a0f1f70b715822a --- M SVGMessageGroup.php M tests/phpunit/SVGMessageGroupTest.php M tests/phpunit/TranslateSvgTestCase.php 3 files changed, 34 insertions(+), 7 deletions(-) Approvals: Jarry1250: Verified; Looks good to me, approved diff --git a/SVGMessageGroup.php b/SVGMessageGroup.php index 5642db4..6f276db 100644 --- a/SVGMessageGroup.php +++ b/SVGMessageGroup.php @@ -160,7 +160,7 @@ $translation = TranslateSvgUtils::arrayToTranslation( $innerArray ); $fullKey = $this->source . '/' . $key . '/' . $language; $title = Title::makeTitleSafe( $this->getNamespace(), $fullKey ); - if ( $title->exists() ) { + if ( $title === null || $title->exists() ) { // @todo: consider whether an update of the page is in order continue; } diff --git a/tests/phpunit/SVGMessageGroupTest.php b/tests/phpunit/SVGMessageGroupTest.php index 40b8418..ce22c6f 100644 --- a/tests/phpunit/SVGMessageGroupTest.php +++ b/tests/phpunit/SVGMessageGroupTest.php @@ -71,10 +71,33 @@ } public function testGetDescription() { - // Should be normalised to spaces - $name = str_replace( '_', ' ', self::$name ); - $expected = "[[File:$name|thumb|right|upright|275x275px]] -<div style=\"overflow:auto; padding:2px;\">Created during testing</div>"; - $this->assertEquals( $expected, $this->messageGroup->getDescription() ); + $expected = '[[File:' . self::$name . '|thumb|right|upright|275x275px]]' . "\n" . + '<div style="overflow:auto; padding:2px;">Created during testing</div>'; + $this->assertEquals( $expected, $this->messageGroup->getDescription() ."" ); + } + + public function testGetOnWikiLanguagesBeforeImport() { + $this->assertCount( + 0, + $this->messageGroup->getOnWikiLanguages(), + 'Message group is registered but has not been imported yet, so getOnWikiLanguages() should return an empty array' + ); + } + + public function testImportTranslations() { + $ret = $this->messageGroup->importTranslations(); + $this->assertTrue( $ret ); + + // Normally updating is asynchronous, but need to force the pace for testing + MessageGroupStats::clearGroup( $this->messageGroup->getId() ); + } + + public function testGetOnWikiLanguagesAfterImport() { + // Clearly this is dependent on the translations having been imported correctly + // Note that 'tlh-ca' is dropped since it is not supported by MediaWiki. + $this->assertArrayEquals( + array( 'de', 'en', 'fr', 'nl' ), + $this->messageGroup->getOnWikiLanguages() + ); } } \ No newline at end of file diff --git a/tests/phpunit/TranslateSvgTestCase.php b/tests/phpunit/TranslateSvgTestCase.php index 4f926d3..0ef7a15 100644 --- a/tests/phpunit/TranslateSvgTestCase.php +++ b/tests/phpunit/TranslateSvgTestCase.php @@ -63,6 +63,9 @@ // Preserve the syntax of $this->setMwGlobals for future use // but we can't use it te way it's written at the moment since we're static $pairs = array( + // Enable uploads + 'wgEnableUploads' => true, + // Add .svg to list of supported file extensions 'wgFileExtensions' => array( 'png', 'gif', 'jpg', 'jpeg', 'svg' ), @@ -107,7 +110,6 @@ $conds = array( 'tmd_group' => self::$name ); $dbw->delete( 'translate_metadata', $conds, __METHOD__ ); - $dbw->commit( __METHOD__, 'flush' ); if( !$title->exists() ) { return; @@ -122,5 +124,7 @@ $wikiPage = new WikiPage( $title ); $wikiPage->doDeleteArticle( 'resetting' ); + + $dbw->commit( __METHOD__, 'flush' ); } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/155733 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a2a3ee65a66e8b3ba41a38a0a0f1f70b715822a Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/TranslateSvg Gerrit-Branch: master Gerrit-Owner: Jarry1250 <jarry1...@gmail.com> Gerrit-Reviewer: Jarry1250 <jarry1...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits