. * * @file * @ingroup extensions */ /** * Integration tests for Page Preview hooks * * @group Popups * @coversDefaultClass MWEventLogger */ class MWEventLoggerTest extends MediaWikiTestCase { /** * @covers ::logUserDisabledPagePreviewsEvent * @dataProvider provideTestDataForLogUserDisabledPagePreviewsEventW */ public function testShouldLog( $samplingRate, $expected ) { $config = $this->getMockBuilder( 'Config' )->setMethods( [ 'get', 'has' ] )->getMock(); $config->expects( $this->once() ) ->method( 'get' ) ->with( 'PopupsSchemaSamplingRate' ) ->willReturn( $samplingRate ); $logger = new \Popups\EventLogging\MWEventLogger( $config, ExtensionRegistry::getInstance() ); $this->assertEquals( $expected, $logger->shouldLog() ); } /** * Mock edge cases * @return array */ public function provideTestDataForLogUserDisabledPagePreviewsEventW() { return [ [ 0, false ], [ 1, true ] ]; } }