. * * @file * @ingroup extensions */ use Popups\EventLogging\MWEventLogger; use Popups\EventLogging\NullLogger; use Popups\EventLogging\EventLoggerFactory; /** * Integration tests for Page Preview hooks * * @group Popups * @coversDefaultClass EventLoggerFactory */ class EventLoggerFactoryTest extends MediaWikiTestCase { /** * @covers ::get */ public function testReturnsMWEventWhenEventLoggingIsAvailable() { $mock = $this->getMock( ExtensionRegistry::class, [ 'isLoaded' ] ); $mock->expects( $this->once() ) ->method( 'isLoaded' ) ->with( 'EventLogging' ) ->willReturn( true ); $config = new HashConfig(); $factory = new EventLoggerFactory( $config, $mock ); $this->assertInstanceOf( MWEventLogger::class, $factory->get() ); } /** * @covers ::get */ public function testReturnsMWEventWhenEventLoggingIsNotAvailable() { $mock = $this->getMock( ExtensionRegistry::class, [ 'isLoaded' ] ); $mock->expects( $this->once() ) ->method( 'isLoaded' ) ->with( 'EventLogging' ) ->willReturn( false ); $config = new HashConfig(); $factory = new EventLoggerFactory( $config, $mock ); $this->assertInstanceOf( NullLogger::class, $factory->get() ); } }