fetchStructuredList( $gadgetsDef ); $this->assertGreaterThanOrEqual( 2, count( $gadgets ), "Gadget list parsed" ); $repo->definitions = $gadgets; $user = $this->createMock( User::class ); $user->method( 'isAllowedAll' ) ->willReturnCallback( static function ( ...$rights ) use ( $testRightNotAllowed ): bool { return !in_array( $testRightNotAllowed, $rights, true ); } ); ( new GadgetHooks() )->onGetPreferences( $user, $prefs ); $this->assertEquals( 'check', $prefs['gadget-bar']['type'] ); $this->assertEquals( 'api', $prefs['gadget-baz']['type'], 'Must not show unavailable gadgets' ); $this->assertEquals( 'gadgets/gadget-section-keep-section2', $prefs['gadget-quux']['section'] ); } }