From 6b22f1089ec1b17716bbb5bff1e65f9fe4757736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thiemo=20M=C3=A4ttig?= Date: Tue, 30 May 2017 22:40:09 +0200 Subject: [PATCH] =?UTF-8?q?Use=20=E2=80=A6->assertArrayHasKey()=20instead?= =?UTF-8?q?=20of=20isset()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … as well as update a line of documentation I had stashed. I think this does not need it's own patch, or does it? Change-Id: I99eee1f7b5ec96c1c75e73d66200bc41807452fa --- includes/MediaWikiGadgetsDefinitionRepo.php | 2 +- tests/phpunit/GadgetTest.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/MediaWikiGadgetsDefinitionRepo.php b/includes/MediaWikiGadgetsDefinitionRepo.php index 06e0760f..c0ae3e0a 100644 --- a/includes/MediaWikiGadgetsDefinitionRepo.php +++ b/includes/MediaWikiGadgetsDefinitionRepo.php @@ -135,7 +135,7 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo { * Generates a structured list of Gadget objects from a definition * * @param string $definition - * @return array Array( name => Gadget ) + * @return Gadget[] List of Gadget objects indexed by the gadget's name. */ private function listFromDefinition( $definition ) { $definition = preg_replace( '//s', '', $definition ); diff --git a/tests/phpunit/GadgetTest.php b/tests/phpunit/GadgetTest.php index 25f1ef71..3d6917d5 100644 --- a/tests/phpunit/GadgetTest.php +++ b/tests/phpunit/GadgetTest.php @@ -163,9 +163,10 @@ class GadgetsTest extends MediaWikiTestCase { $this->assertTrue( GadgetHooks::getPreferences( new User, $prefs ), 'GetPrefences hook should return true' ); $options = $prefs['gadgets']['options']; - $this->assertFalse( isset( $options['⧼gadget-section-remove-section⧽'] ), 'Must not show empty sections' ); - $this->assertTrue( isset( $options['⧼gadget-section-keep-section1⧽'] ) ); - $this->assertTrue( isset( $options['⧼gadget-section-keep-section2⧽'] ) ); + $this->assertArrayNotHasKey( '⧼gadget-section-remove-section⧽', $options, + 'Must not show empty sections' ); + $this->assertArrayHasKey( '⧼gadget-section-keep-section1⧽', $options ); + $this->assertArrayHasKey( '⧼gadget-section-keep-section2⧽', $options ); } public function tearDown() {