Umherirrender has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/356953 )
Change subject: Add phpcs and make pass - tests/phpunit ...................................................................... Add phpcs and make pass - tests/phpunit Change-Id: I387c7ea4cf73bffcb9e7198a54460659850b2883 --- M tests/phpunit/AutoEnrollmentTest.php M tests/phpunit/BetaFeaturesTestCase.php M tests/phpunit/DependentFeatureTest.php M tests/phpunit/HTMLFeatureFieldTest.php M tests/phpunit/HTMLHorizontalRuleTest.php M tests/phpunit/HTMLTextBlockTest.php M tests/phpunit/HooksRunTest.php M tests/phpunit/NewHTMLCheckFieldTest.php M tests/phpunit/PreferenceHandlingTest.php 9 files changed, 94 insertions(+), 94 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures refs/changes/53/356953/1 diff --git a/tests/phpunit/AutoEnrollmentTest.php b/tests/phpunit/AutoEnrollmentTest.php index 87d09a2..f397a1c 100644 --- a/tests/phpunit/AutoEnrollmentTest.php +++ b/tests/phpunit/AutoEnrollmentTest.php @@ -26,41 +26,41 @@ class AutoEnrollmentTest extends BetaFeaturesTestCase { // Structure of testing preference - public static $testPrefs = array( - 'unittest-all' => array( + public static $testPrefs = [ + 'unittest-all' => [ 'label-message' => 'nullish', 'desc-message' => 'nullish', 'info-link' => 'http://example.org/features', 'discussion-link' => 'http://example.org/feedback', 'auto-enrollment' => 'unittest', - ), + ], - 'unittest-ft1' => array( + 'unittest-ft1' => [ 'label-message' => 'something else', 'desc-message' => 'something even differenter', 'info-link' => 'http://example.org/feature/one', 'discussion-link' => 'http://example.org/feedback/one', 'group' => 'unittest', 'auto-enrollment' => 'unittest2', - ), + ], - 'unittest-ft2' => array( + 'unittest-ft2' => [ 'label-message' => 'something even more else', 'desc-message' => 'something even more differenter', 'info-link' => 'http://example.org/feature/two', 'discussion-link' => 'http://example.org/feedback/two', 'group' => 'unittest2', - ), + ], - 'unittest-ft3' => array( + 'unittest-ft3' => [ 'label-message' => 'something entirely different', 'desc-message' => 'something entirely differenter', 'info-link' => 'http://example.org/feature/three', 'discussion-link' => 'http://example.org/feedback/three', 'group' => 'unittest2', 'exempt-from-auto-enrollment' => true, - ), - ); + ], + ]; public static function hookThatRegistersPreference( $user, &$betaPrefs ) { foreach ( self::$testPrefs as $key => $testPref ) { @@ -71,72 +71,72 @@ } public static function getTestData() { - return array( - array( + return [ + [ null, null, 'unittest-ft1', null, 'Hooks set the preference though auto-enroll was not set.' - ), + ], - array( + [ 'betafeatures-auto-enroll', HTMLFeatureField::OPTION_ENABLED, 'unittest-ft1', HTMLFeatureField::OPTION_ENABLED, 'Hooks did not set the preference though global auto-enroll was set.', - ), + ], - array( + [ null, null, 'unittest-ft1', null, 'Hooks set the preference though group auto-enroll was not set.' - ), + ], - array( + [ 'unittest-all', HTMLFeatureField::OPTION_ENABLED, 'unittest-ft1', HTMLFeatureField::OPTION_ENABLED, 'Hooks did not set the preference though group auto-enroll was set.', - ), + ], - array( + [ null, null, 'unittest-ft2', null, 'Hooks set the preference though no auto-enroll was set.' - ), + ], - array( + [ 'unittest-all', HTMLFeatureField::OPTION_ENABLED, 'unittest-ft2', HTMLFeatureField::OPTION_ENABLED, 'Hooks did not set the preference though grandparent group auto-enroll was set.', - ), + ], - array( + [ 'betafeatures-auto-enroll', HTMLFeatureField::OPTION_ENABLED, 'unittest-ft2', HTMLFeatureField::OPTION_ENABLED, 'Hooks did not set the preference though global auto-enroll was set.', - ), + ], - array( + [ 'betafeatures-auto-enroll', HTMLFeatureField::OPTION_ENABLED, 'unittest-ft3', null, 'The preferences was not set despite auto-enroll ' . 'because it is exempt-from-auto-enrollment.', - ), - ); + ], + ]; } protected function setUp() { @@ -145,7 +145,7 @@ parent::setUp(); $wgHooks['GetBetaFeaturePreferences'] = - array( 'AutoEnrollmentTest::hookThatRegistersPreference' ); + [ 'AutoEnrollmentTest::hookThatRegistersPreference' ]; } /** @@ -153,13 +153,13 @@ */ public function testAutoEnroll( $set, $setVal, $check, $expected, $msg ) { $user = $this->user; - $prefs = array(); + $prefs = []; if ( $set !== null ) { $user->setOption( $set, $setVal ); } - Hooks::run( 'GetPreferences', array( $user, &$prefs ) ); + Hooks::run( 'GetPreferences', [ $user, &$prefs ] ); $value = $user->getOption( $check ); if ( $expected === null ) { diff --git a/tests/phpunit/BetaFeaturesTestCase.php b/tests/phpunit/BetaFeaturesTestCase.php index 95c6968..e884450 100644 --- a/tests/phpunit/BetaFeaturesTestCase.php +++ b/tests/phpunit/BetaFeaturesTestCase.php @@ -32,8 +32,8 @@ // Avoid interactions with other extensions $newHooks = $wgHooks; - $newHooks['GetPreferences'] = array( 'BetaFeaturesHooks::getPreferences' ); - $this->setMwGlobals( array( 'wgHooks' => $newHooks ) ); + $newHooks['GetPreferences'] = [ 'BetaFeaturesHooks::getPreferences' ]; + $this->setMwGlobals( [ 'wgHooks' => $newHooks ] ); $this->user = $this->getMutableTestUser()->getUser(); $this->user->addGroup( 'unittesters' ); diff --git a/tests/phpunit/DependentFeatureTest.php b/tests/phpunit/DependentFeatureTest.php index 23e6f2a..9138a61 100644 --- a/tests/phpunit/DependentFeatureTest.php +++ b/tests/phpunit/DependentFeatureTest.php @@ -32,13 +32,13 @@ const testDepsKey = 'DependentFeatureTestDependencyCheck'; // Structure of testing preference - public static $testPref = array( + public static $testPref = [ 'label-message' => 'nullish', 'desc-message' => 'nullish', 'info-link' => 'http://example.org/features', 'discussion-link' => 'http://example.org/feedback', 'dependent' => true, - ); + ]; public static function failHook() { return false; @@ -63,7 +63,7 @@ parent::setUp(); - $wgHooks[self::testDepsKey] = array(); + $wgHooks[self::testDepsKey] = []; $wgHooks['GetBetaFeaturePreferences'][] = 'DependentFeatureTest::hookThatRegistersPreference'; $wgHooks['GetBetaFeatureDependencyHooks'][] = @@ -76,9 +76,9 @@ $wgHooks[self::testDepsKey][] = 'DependentFeatureTest::passHook'; - $prefs = array(); + $prefs = []; - Hooks::run( 'GetPreferences', array( $this->user, &$prefs ) ); + Hooks::run( 'GetPreferences', [ $this->user, &$prefs ] ); $this->assertArrayHasKey( self::testPrefKey, $prefs, 'Hook did not run with passing dependency.' @@ -90,9 +90,9 @@ $wgHooks[self::testDepsKey][] = 'DependentFeatureTest::failHook'; - $prefs = array(); + $prefs = []; - Hooks::run( 'GetPreferences', array( $this->user, &$prefs ) ); + Hooks::run( 'GetPreferences', [ $this->user, &$prefs ] ); $this->assertArrayNotHasKey( self::testPrefKey, $prefs, 'Hook ran with failing dependency.' @@ -100,9 +100,9 @@ } public function testNoDependency() { - $prefs = array(); + $prefs = []; - Hooks::run( 'GetPreferences', array( $this->user, &$prefs ) ); + Hooks::run( 'GetPreferences', [ $this->user, &$prefs ] ); $this->assertArrayHasKey( self::testPrefKey, $prefs, 'Hook did not run without dependency.' diff --git a/tests/phpunit/HTMLFeatureFieldTest.php b/tests/phpunit/HTMLFeatureFieldTest.php index 0bc7cf4..c053dd9 100644 --- a/tests/phpunit/HTMLFeatureFieldTest.php +++ b/tests/phpunit/HTMLFeatureFieldTest.php @@ -26,56 +26,56 @@ class HTMLFeatureFieldTest extends MediaWikiTestCase { public function testCreatingFieldGivesExpectedStrings() { - $form = new HTMLForm( array( - 'blahblahblah' => array( + $form = new HTMLForm( [ + 'blahblahblah' => [ 'class' => 'HTMLFeatureField', 'label-message' => 'betafeatures-test-check-field', 'desc-message' => 'betafeatures-test-feature-field', 'info-link' => 'http://example.org/features', 'discussion-link' => 'http://example.org/feedback', - ), - ) ); + ], + ] ); $form->setTitle( Title::newMainPage() ); $form->prepareForm(); $html = $form->getHTML( false ); - $cases = array( - array( + $cases = [ + [ 'pattern' => '#<tr class="mw-htmlform-field-HTMLFeatureField">#', 'message' => 'Table row with class name not found.', - ), - array( + ], + [ 'pattern' => "#<input type='checkbox' tabindex='0' aria-disabled='false' " . "name='wpblahblahblah' value='1' id='ooui-\d+' class='oo-ui-inputWidget-input' />#", 'message' => 'Styled checkbox input not found.', - ), - array( + ], + [ 'pattern' => "#<label for='ooui-\d+' class='oo-ui-labelElement-label'>" . "blah blah blah</label>#", 'message' => 'Checkbox label not found.', - ), - array( + ], + [ 'pattern' => '#<p class="mw-ui-feature-description">This is a test feature - ' . 'it should not show up.</p>#', 'message' => 'Feature description not found', - ), - array( + ], + [ 'pattern' => '#<div class="mw-ui-feature-meta">#', 'message' => 'Meta div not found.', - ), - array( + ], + [ 'pattern' => '#<a href="http://example.org/features" class="mw-ui-feature-info-link">#', 'message' => 'Feature information link not found', - ), - array( + ], + [ 'pattern' => '#<a href="http://example.org/feedback" class="mw-ui-feature-discussion-link">#', 'message' => 'Discussion link not found', - ), - array( + ], + [ 'pattern' => '#<div class="mw-ui-feature-screenshot-contain"></div>#', 'message' => 'Screenshot div not empty or not found.', - ), - ); + ], + ]; foreach ( $cases as $case ) { $this->assertRegExp( diff --git a/tests/phpunit/HTMLHorizontalRuleTest.php b/tests/phpunit/HTMLHorizontalRuleTest.php index 53a946a..06be579 100644 --- a/tests/phpunit/HTMLHorizontalRuleTest.php +++ b/tests/phpunit/HTMLHorizontalRuleTest.php @@ -26,11 +26,11 @@ class HTMLHorizontalRuleFieldTest extends MediaWikiTestCase { public function testCreatingFieldGivesExpectedStrings() { - $form = new HTMLForm( array( - 'blahblahblah' => array( + $form = new HTMLForm( [ + 'blahblahblah' => [ 'class' => 'HTMLHorizontalRuleField', - ), - ) ); + ], + ] ); $form->setTitle( Title::newMainPage() ); $form->prepareForm(); $html = $form->getHTML( false ); diff --git a/tests/phpunit/HTMLTextBlockTest.php b/tests/phpunit/HTMLTextBlockTest.php index 7b99103..f526106 100644 --- a/tests/phpunit/HTMLTextBlockTest.php +++ b/tests/phpunit/HTMLTextBlockTest.php @@ -26,12 +26,12 @@ class HTMLTextBlockFieldTest extends MediaWikiTestCase { public function testCreatingFieldGivesExpectedStrings() { - $form = new HTMLForm( array( - 'blahblahblah' => array( + $form = new HTMLForm( [ + 'blahblahblah' => [ 'class' => 'HTMLTextBlockField', 'label' => 'This is a label.', - ), - ) ); + ], + ] ); $form->setTitle( Title::newMainPage() ); $form->prepareForm(); $html = $form->getHTML( false ); diff --git a/tests/phpunit/HooksRunTest.php b/tests/phpunit/HooksRunTest.php index 947ef76..94b970f 100644 --- a/tests/phpunit/HooksRunTest.php +++ b/tests/phpunit/HooksRunTest.php @@ -29,12 +29,12 @@ const testPrefKey = 'unittest'; // Structure of testing preference - public static $testPref = array( + public static $testPref = [ 'label-message' => 'nullish', 'desc-message' => 'nullish', 'info-link' => 'http://example.org/features', 'discussion-link' => 'http://example.org/feedback', - ); + ]; public static function nullHook( $user, &$betaPrefs ) { return true; @@ -55,9 +55,9 @@ public function testHooksRun() { global $wgHooks; - $wgHooks['GetBetaFeaturePreferences'] = array( 'HooksRunTest::hookThatRegistersPreference' ); - $prefs = array(); - Hooks::run( 'GetBetaFeaturePreferences', array( $this->user, &$prefs ) ); + $wgHooks['GetBetaFeaturePreferences'] = [ 'HooksRunTest::hookThatRegistersPreference' ]; + $prefs = []; + Hooks::run( 'GetBetaFeaturePreferences', [ $this->user, &$prefs ] ); $this->assertArrayHasKey( self::testPrefKey, $prefs, 'Hook did not run' ); $this->assertEquals( $prefs[self::testPrefKey], diff --git a/tests/phpunit/NewHTMLCheckFieldTest.php b/tests/phpunit/NewHTMLCheckFieldTest.php index 25dfa11..5fd25b6 100644 --- a/tests/phpunit/NewHTMLCheckFieldTest.php +++ b/tests/phpunit/NewHTMLCheckFieldTest.php @@ -26,13 +26,13 @@ class NewHTMLCheckFieldTest extends MediaWikiTestCase { public function testCreatingFieldGivesExpectedStrings() { - $form = new HTMLForm( array( - 'blahblahblah' => array( + $form = new HTMLForm( [ + 'blahblahblah' => [ 'class' => 'NewHTMLCheckField', 'label-message' => 'betafeatures-test-check-field', 'default' => true, - ) - ) ); + ] + ] ); $form->setTitle( Title::newMainPage() ); $form->prepareForm(); $html = $form->getHTML( false ); diff --git a/tests/phpunit/PreferenceHandlingTest.php b/tests/phpunit/PreferenceHandlingTest.php index c5f53e1..103a451 100644 --- a/tests/phpunit/PreferenceHandlingTest.php +++ b/tests/phpunit/PreferenceHandlingTest.php @@ -28,27 +28,27 @@ const testPrefKey = 'unittest'; static function preferenceListing() { - $invalidPref = array( + $invalidPref = [ 'screenshot' => 'google it bro', - ); + ]; - $validPref = array( + $validPref = [ 'label-message' => 'soup-label', 'desc-message' => 'something-something-desc-side', 'info-link' => 'http://example.org/features', 'discussion-link' => 'http://example.org/feedback', - ); + ]; $validPrefPostHook = $validPref; $validPrefPostHook['class'] = 'HTMLFeatureField'; $validPrefPostHook['section'] = 'betafeatures'; - return array( - array( 'Invalid preference should cause an error', $invalidPref, null ), - array( + return [ + [ 'Invalid preference should cause an error', $invalidPref, null ], + [ 'Totally valid preference should get set accurately', $validPref, $validPrefPostHook - ), - ); + ], + ]; } /** @@ -57,16 +57,16 @@ public function testHandlingOfPreferences( $msg, $pref, $expected ) { global $wgHooks; $prefkey = self::testPrefKey; - $prefs = array(); - $wgHooks['GetBetaFeaturePreferences'] = array( + $prefs = []; + $wgHooks['GetBetaFeaturePreferences'] = [ function ( $user, &$prefs ) use ( $pref, $prefkey ) { $prefs[$prefkey] = $pref; return true; } - ); + ]; try { - Hooks::run( 'GetPreferences', array( $this->user, &$prefs ) ); + Hooks::run( 'GetPreferences', [ $this->user, &$prefs ] ); } catch ( BetaFeaturesMissingFieldException $e ) { if ( $expected === null ) { $this->assertEquals( 'BetaFeaturesMissingFieldException', get_class( $e ) ); -- To view, visit https://gerrit.wikimedia.org/r/356953 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I387c7ea4cf73bffcb9e7198a54460659850b2883 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BetaFeatures Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits