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