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