mediawiki-extensions-Echo/tests/phpunit/NotificationStructureTest.php
Alexander Vorwerk 449f82faa3 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I68efac2c458748fa3ab16c4c652bd2c4af9cbb75
2021-10-12 00:42:10 +02:00

41 lines
1 KiB
PHP

<?php
class NotificationStructureTest extends MediaWikiIntegrationTestCase {
/**
* @coversNothing
* @dataProvider provideNotificationTypes
*
* @param string $type
* @param array $info
*/
public function testNotificationTypes( $type, array $info ) {
if ( isset( $info['presentation-model'] ) ) {
self::assertTrue( class_exists( $info['presentation-model'] ),
"Presentation model class {$info['presentation-model']} for {$type} must exist"
);
}
if ( isset( $info['user-locators'] ) ) {
$locators = (array)$info['user-locators'];
$callable = reset( $locators );
if ( is_array( $callable ) ) {
$callable = reset( $callable );
}
self::assertTrue( is_callable( $callable ),
'User locator ' . print_r( $callable, true ) . " for {$type} must be callable"
);
}
}
public function provideNotificationTypes() {
global $wgEchoNotifications;
$result = [];
foreach ( $wgEchoNotifications as $type => $info ) {
$result[] = [ $type, $info ];
}
return $result;
}
}