Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / specials / SpecialMIMESearchTest.php
blobf9adbe59a2f658608e6a736f033706ac558b5344
1 <?php
3 use MediaWiki\Context\RequestContext;
4 use MediaWiki\Request\FauxRequest;
5 use MediaWiki\Specials\SpecialMIMESearch;
6 use MediaWiki\Title\Title;
8 /**
9 * @group Database
10 * @covers \MediaWiki\Specials\SpecialMIMESearch
12 class SpecialMIMESearchTest extends MediaWikiIntegrationTestCase {
14 /** @var SpecialMIMESearch */
15 private $page;
17 protected function setUp(): void {
18 parent::setUp();
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 );
32 /**
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 );
44 } else {
45 $this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
47 $this->assertContains( 'image', $qi['tables'] );
50 public static function providerMimeFiltering() {
51 return [
52 [ 'image/gif', 'image', 'gif' ],
53 [ 'image/png', 'image', 'png' ],
54 [ 'application/pdf', 'application', 'pdf' ],
55 [ 'image/*', 'image', null ],
56 [ 'multipart/*', 'multipart', null ],