3 use MediaWiki\Context\RequestContext
;
4 use MediaWiki\Request\FauxRequest
;
5 use MediaWiki\Specials\SpecialMIMESearch
;
6 use MediaWiki\Title\Title
;
10 * @covers \MediaWiki\Specials\SpecialMIMESearch
12 class SpecialMIMESearchTest
extends MediaWikiIntegrationTestCase
{
14 /** @var SpecialMIMESearch */
17 protected function setUp(): void
{
20 $services = $this->getServiceContainer();
21 $this->page
= new SpecialMIMESearch(
22 $services->getConnectionProvider(),
23 $services->getLinkBatchFactory(),
24 $services->getLanguageConverterFactory()
26 $context = new RequestContext();
27 $context->setTitle( Title
::makeTitle( NS_SPECIAL
, 'MIMESearch' ) );
28 $context->setRequest( new FauxRequest() );
29 $this->page
->setContext( $context );
33 * @dataProvider providerMimeFiltering
34 * @param string $par Subpage for special page
35 * @param string $major Major MIME type we expect to look for
36 * @param string $minor Minor MIME type we expect to look for
38 public function testMimeFiltering( $par, $major, $minor ) {
39 $this->page
->run( $par );
40 $qi = $this->page
->getQueryInfo();
41 $this->assertEquals( $qi['conds']['img_major_mime'], $major );
42 if ( $minor !== null ) {
43 $this->assertEquals( $qi['conds']['img_minor_mime'], $minor );
45 $this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
47 $this->assertContains( 'image', $qi['tables'] );
50 public static function providerMimeFiltering() {
52 [ 'image/gif', 'image', 'gif' ],
53 [ 'image/png', 'image', 'png' ],
54 [ 'application/pdf', 'application', 'pdf' ],
55 [ 'image/*', 'image', null ],
56 [ 'multipart/*', 'multipart', null ],