Merge "tests: Add ActionFactoryIntegrationTest"

This commit is contained in:
jenkins-bot 2023-01-13 21:25:06 +00:00 committed by Gerrit Code Review
commit 1a00dd26e5
2 changed files with 28 additions and 0 deletions

View file

@ -132,6 +132,7 @@ class ActionFactory {
'mcrundo' => [
'class' => McrUndoAction::class,
'services' => [
// Same as for McrRestoreAction
'ReadOnlyMode',
'RevisionLookup',
'RevisionRenderer',
@ -142,6 +143,7 @@ class ActionFactory {
'mcrrestore' => [
'class' => McrRestoreAction::class,
'services' => [
// Same as for McrUndoAction
'ReadOnlyMode',
'RevisionLookup',
'RevisionRenderer',

View file

@ -0,0 +1,26 @@
<?php
use MediaWiki\Actions\ActionFactory;
use MediaWiki\MediaWikiServices;
/**
* Test that runs against all core actions to make sure that
* creating an instance of the action works
*
* @coversNothing
*/
class ActionFactoryIntegrationTest extends MediaWikiIntegrationTestCase {
public function testActionFactoryServiceWiring() {
$services = MediaWikiServices::getInstance();
$actionFactory = $services->getActionFactory();
$context = RequestContext::getMain();
$article = Article::newFromTitle( Title::makeTitle( NS_MAIN, 'ActionFactoryServiceWiringTest' ), $context );
$actionSpecs = ( new ReflectionClassConstant( ActionFactory::class, 'CORE_ACTIONS' ) )->getValue();
foreach ( $actionSpecs as $action => $_ ) {
$this->assertInstanceOf( Action::class, $actionFactory->getAction( $action, $article, $context ) );
}
}
}