mediawiki-extensions-AbuseF.../tests/phpunit/SpecialAbuseFilterIntegrationTest.php
Matěj Suchánek a1ba43f586 DI for AbuseFilterView and subclasses
Also add a test to ensure all views can be instantiated without problem.

Change-Id: Iedd7a5dca240efab1077fa51a3522c983b0ba4fa
2020-12-03 13:04:35 +01:00

57 lines
1.6 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
class SpecialAbuseFilterIntegrationTest extends SpecialPageTestBase {
/**
* @covers SpecialAbuseFilter::instantiateView
* @covers SpecialAbuseFilter::__construct
* @covers AbuseFilterView::__construct
* @covers AbuseFilterViewDiff::__construct
* @covers AbuseFilterViewEdit::__construct
* @covers AbuseFilterViewExamine::__construct
* @covers AbuseFilterViewHistory::__construct
* @covers AbuseFilterViewImport::__construct
* @covers AbuseFilterViewList::__construct
* @covers AbuseFilterViewRevert::__construct
* @covers AbuseFilterViewTestBatch::__construct
* @covers AbuseFilterViewTools::__construct
* @dataProvider provideInstantiateView
*/
public function testInstantiateView( string $viewClass, array $params = [] ) {
$sp = $this->newSpecialPage();
$view = $sp->instantiateView( $viewClass, $params );
$this->assertInstanceOf( $viewClass, $view );
}
public function provideInstantiateView() : array {
return [
[ AbuseFilterViewDiff::class ],
[ AbuseFilterViewEdit::class, [ 'filter' => 1 ] ],
[ AbuseFilterViewExamine::class ],
[ AbuseFilterViewHistory::class ],
[ AbuseFilterViewImport::class ],
[ AbuseFilterViewList::class ],
[ AbuseFilterViewRevert::class ],
[ AbuseFilterViewTestBatch::class ],
[ AbuseFilterViewTools::class ],
];
}
/**
* @inheritDoc
*/
protected function newSpecialPage() : SpecialAbuseFilter {
$services = MediaWikiServices::getInstance();
$sp = new SpecialAbuseFilter(
$services->getObjectFactory()
);
$sp->setLinkRenderer(
$services->getLinkRendererFactory()->create()
);
return $sp;
}
}