mediawiki-extensions-Echo/tests/phpunit/NotificationStructureTest.php
Matthias Mullie a969c6d312 Make tests match actual expected format for user-locators
EchoAttributeManager::getUserCallable casts to array,
which means that even a non-array value (e.g. a simple callback)
becomes an array and NotificationController::evaluateUserCallable
will handle it just fine. But tests seemed to thing it was wrong.

Change-Id: Ia1e1e4015ebbc4d79bba5274e802911f222692c0
2020-09-30 15:54:54 +00:00

41 lines
1,015 B
PHP

<?php
class NotificationStructureTest extends MediaWikiTestCase {
/**
* @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;
}
}