a8459383f6cec5b59009399ef2dc9e869b597408
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialMIMESearchTest.php
1 <?php
2 /**
3 * @group Database
4 */
5
6 /**
7 * @covers MIMEsearchPage
8 */
9 class SpecialMIMESearchTest extends MediaWikiTestCase {
10
11 /** @var MIMEsearchPage */
12 private $page;
13
14 function setUp() {
15 $this->page = new MIMEsearchPage;
16 $context = new RequestContext();
17 $context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) );
18 $context->setRequest( new FauxRequest() );
19 $this->page->setContext( $context );
20
21 parent::setUp();
22 }
23
24 /**
25 * @dataProvider providerMimeFiltering
26 * @param string $par Subpage for special page
27 * @param string $major Major MIME type we expect to look for
28 * @param string $minor Minor MIME type we expect to look for
29 */
30 function testMimeFiltering( $par, $major, $minor ) {
31 $this->page->run( $par );
32 $qi = $this->page->getQueryInfo();
33 $this->assertEquals( $qi['conds']['img_major_mime'], $major );
34 if ( $minor !== null ) {
35 $this->assertEquals( $qi['conds']['img_minor_mime'], $minor );
36 } else {
37 $this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
38 }
39 $this->assertContains( 'image', $qi['tables'] );
40 }
41
42 function providerMimeFiltering() {
43 return [
44 [ 'image/gif', 'image', 'gif' ],
45 [ 'image/png', 'image', 'png' ],
46 [ 'application/pdf', 'application', 'pdf' ],
47 [ 'image/*', 'image', null ],
48 [ 'multipart/*', 'multipart', null ],
49 ];
50 }
51 }