setMultiple( $options ); $this->setService( 'Minerva.SkinOptions', $mockOptions ); } /** * @covers ::setContext * @covers ::hasCategoryLinks */ public function testHasCategoryLinksWhenOptionIsOff() { $outputPage = $this->getMockBuilder( OutputPage::class ) ->disableOriginalConstructor() ->getMock(); $outputPage->expects( $this->never() ) ->method( 'getCategoryLinks' ); $this->overrideSkinOptions( [ SkinOptions::CATEGORIES => false ] ); $context = new RequestContext(); $context->setTitle( Title::makeTitle( NS_MAIN, 'Test' ) ); $context->setOutput( $outputPage ); $skin = new SkinMinerva(); $skin->setContext( $context ); $skin = TestingAccessWrapper::newFromObject( $skin ); $this->assertFalse( $skin->hasCategoryLinks() ); } /** * @dataProvider provideHasCategoryLinks * @param array $categoryLinks * @param bool $expected * @covers ::setContext * @covers ::hasCategoryLinks */ public function testHasCategoryLinks( array $categoryLinks, $expected ) { $outputPage = $this->getMockBuilder( OutputPage::class ) ->disableOriginalConstructor() ->getMock(); $outputPage->expects( $this->once() ) ->method( 'getCategoryLinks' ) ->willReturn( $categoryLinks ); $this->overrideSkinOptions( [ SkinOptions::CATEGORIES => true ] ); $context = new RequestContext(); $context->setTitle( Title::makeTitle( NS_MAIN, 'Test' ) ); $context->setOutput( $outputPage ); $skin = new SkinMinerva(); $skin->setContext( $context ); $skin = TestingAccessWrapper::newFromObject( $skin ); $this->assertEquals( $expected, $skin->hasCategoryLinks() ); } public function provideHasCategoryLinks() { return [ [ [], false ], [ [ 'normal' => '' ], true ], [ [ 'hidden' => '' ], true ], [ [ 'normal' => '', 'hidden' => '' ], true ], [ [ 'unexpected' => '' ], false ], ]; } }