From 06cb0d29300cf8d5e7ade4d33056826f613bf045 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Mon, 5 Feb 2018 21:54:30 -0800 Subject: [PATCH] Unbreak CategoryMessagesTest This test previously wasn't running because the foreach() in the data provider was totally wrong. Also the -details variant for fostered isn't supposed to exist, so hardcode in an exception. Finally, add the @coversNothing annotation since this test is just verifying the contents of en.json, not any PHP code. Change-Id: I7ffffcc3a910aefb082f7ff59265d3be8bc46347 --- tests/phpunit/CategoryMessagesTest.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/CategoryMessagesTest.php b/tests/phpunit/CategoryMessagesTest.php index ef0860bd..b9bad17c 100644 --- a/tests/phpunit/CategoryMessagesTest.php +++ b/tests/phpunit/CategoryMessagesTest.php @@ -21,18 +21,18 @@ namespace MediaWiki\Linter\Test; use MediaWiki\Linter\CategoryManager; -use MediaWikiTestCase; +use MediaWikiLangTestCase; /** * Test that all of the messages for new categories * exist */ -class CategoryMessagesTest extends MediaWikiTestCase { +class CategoryMessagesTest extends MediaWikiLangTestCase { public static function provideCategoryNames() { $manager = new CategoryManager(); $tests = []; - foreach ( $manager as $category ) { + foreach ( $manager->getVisibleCategories() as $category ) { $tests[] = [ $category ]; } @@ -40,11 +40,23 @@ class CategoryMessagesTest extends MediaWikiTestCase { } /** + * @coversNothing * @dataProvider provideCategoryNames */ public function testMessagesExistence( $category ) { - $this->assertTrue( wfMessage( "linter-category-$category" )->exists() ); - $this->assertTrue( wfMessage( "linter-category-$category-desc" )->exists() ); - $this->assertTrue( wfMessage( "linter-pager-$category-details" )->exists() ); + $msgs = [ + "linter-category-$category", + "linter-category-$category-desc", + ]; + if ( $category !== 'fostered' ) { + // TODO: Don't hardcode this + $msgs[] = "linter-pager-$category-details"; + } + foreach ( $msgs as $msg ) { + $this->assertTrue( + wfMessage( $msg )->exists(), + "Missing '$msg' message" + ); + } } }