Debian Codegraph @

extensions/Echo/tests/phpunit/NotificationStructureTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\Test;
4
5 use MediaWikiIntegrationTestCase;
6
7 class NotificationStructureTest extends MediaWikiIntegrationTestCase {
8 /**
9 * @coversNothing
10 * @dataProvider provideNotificationTypes
11 *
12 * @param string $type
13 * @param array $info
14 */
15 public function testNotificationTypes( $type, array $info ) {
16 if ( isset( $info['presentation-model'] ) ) {
17 self::assertTrue( class_exists( $info['presentation-model'] ),
18 "Presentation model class {$info['presentation-model']} for {$type} must exist"
19 );
20 }
21
22 if ( isset( $info['user-locators'] ) ) {
23 $locators = (array)$info['user-locators'];
24 $callable = reset( $locators );
25 if ( is_array( $callable ) ) {
26 $callable = reset( $callable );
27 }
28 self::assertTrue( is_callable( $callable ),
29 'User locator ' . print_r( $callable, true ) . " for {$type} must be callable"
30 );
31 }
32 }
33
34 public static function provideNotificationTypes() {
35 global $wgEchoNotifications;
36
37 $result = [];
38 foreach ( $wgEchoNotifications as $type => $info ) {
39 $result[] = [ $type, $info ];
40 }
41
42 return $result;
43 }
44 }