2018-10-11 02:07:04 +00:00
|
|
|
<?php
|
|
|
|
|
2021-10-11 22:42:10 +00:00
|
|
|
class NotificationStructureTest extends MediaWikiIntegrationTestCase {
|
2018-10-11 02:07:04 +00:00
|
|
|
/**
|
|
|
|
* @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'] ) ) {
|
2020-04-07 13:18:20 +00:00
|
|
|
$locators = (array)$info['user-locators'];
|
|
|
|
$callable = reset( $locators );
|
|
|
|
if ( is_array( $callable ) ) {
|
|
|
|
$callable = reset( $callable );
|
2018-10-11 02:07:04 +00:00
|
|
|
}
|
2020-04-07 13:18:20 +00:00
|
|
|
self::assertTrue( is_callable( $callable ),
|
|
|
|
'User locator ' . print_r( $callable, true ) . " for {$type} must be callable"
|
2018-10-11 02:07:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-20 18:35:53 +00:00
|
|
|
public static function provideNotificationTypes() {
|
2018-10-11 02:07:04 +00:00
|
|
|
global $wgEchoNotifications;
|
|
|
|
|
|
|
|
$result = [];
|
|
|
|
foreach ( $wgEchoNotifications as $type => $info ) {
|
|
|
|
$result[] = [ $type, $info ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|