Page MenuHomeWickedGov Phorge

HooksTest.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

HooksTest.php

<?php
namespace MediaWiki\Extension\EventLogging\Tests\Integration;
use Generator;
use MediaWiki\Extension\EventLogging\Hooks;
use MediaWikiIntegrationTestCase;
/**
* @covers \MediaWiki\Extension\EventLogging\Hooks
*/
class HooksTest extends MediaWikiIntegrationTestCase {
public function setUp(): void {
parent::setUp();
$this->markTestSkippedIfExtensionNotLoaded( 'EventStreamConfig' );
$this->overrideConfigValue( 'EventStreams', [
'test.event' => [
'schema_title' => 'test/event',
'destination_event_service' => 'foo-event-service',
'topic_prefixes' => [ 'foo.' ],
'canary_events_enabled' => true,
'producers' => [
'foo_producer' => [
'enabled' => true,
],
],
'consumers' => [
'foo_consumer' => [
'enabled' => true,
],
],
'sample' => [
'unit' => 'pageview',
'rate' => 0.01,
],
],
] );
}
public static function provideEventLoggingConfigStreamConfigs(): Generator {
yield [
'eventLoggingStreamNames' => false,
'expectedStreamConfigs' => false,
];
yield [
'eventLoggingStreamNames' => [
'test.event',
],
'expectedStreamConfigs' => [
'test.event' => [
'producers' => [
'foo_producer' => [
'enabled' => true,
],
],
'sample' => [
'unit' => 'pageview',
'rate' => 0.01,
],
],
]
];
}
/**
* @dataProvider provideEventLoggingConfigStreamConfigs
*/
public function testGetEventLoggingConfigStreamConfigs( $eventLoggingStreamNames, $expectedStreamConfigs ): void {
$this->overrideConfigValue( 'EventLoggingStreamNames', $eventLoggingStreamNames );
// We could inject a HashConfig instance here. However, the EventLogging and
// EventStreamConfig extensions are not fully isolated from one another and they both
// use the config variables that were overridden above.
$config = $this->getServiceContainer()->getMainConfig();
$result = Hooks::getEventLoggingConfig( $config );
$this->assertEquals( $expectedStreamConfigs, $result['streamConfigs'] );
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 15:59 (1 d, 16 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cc/f3/f726c54bd1230bb4025c149756c1
Default Alt Text
HooksTest.php (2 KB)

Event Timeline