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->assertArrayHasKey( 'gadget-bar', $prefs ); $this->assertArrayNotHasKey( 'gadget-baz', $prefs, 'Must not show unavailable gadgets' ); $this->assertEquals( 'gadgets/gadget-section-keep-section2', $prefs['gadget-quux']['section'] ); } }