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