user = $this->getMockBuilder( '\MediaWiki\User\User' ) ->disableOriginalConstructor() ->getMock(); } public function testCanConstruct() { $this->assertInstanceOf( PreferenceExaminer::class, new PreferenceExaminer() ); } public function testHasPreferenceOf() { $userOptionsLookup = $this->createMock( UserOptionsLookup::class ); $userOptionsLookup->expects( $this->any() ) ->method( 'getOption' ) ->with( $this->user, 'foo', false ) ->willReturn( false ); $instance = new PreferenceExaminer( $this->user, $userOptionsLookup ); $this->assertIsBool( $instance->hasPreferenceOf( 'foo' ) ); } public function testHasPreferenceOf_NoUser() { $instance = new PreferenceExaminer(); $this->assertIsBool( $instance->hasPreferenceOf( 'foo' ) ); } }