2014-06-21 17:19:42 +00:00
|
|
|
<?php
|
2014-08-15 21:11:26 +00:00
|
|
|
|
2017-12-25 07:27:02 +00:00
|
|
|
/**
|
2018-03-09 21:56:41 +00:00
|
|
|
* @group Database
|
2017-12-25 07:27:02 +00:00
|
|
|
* @covers MIMEsearchPage
|
|
|
|
|
*/
|
2014-06-21 17:19:42 +00:00
|
|
|
class SpecialMIMESearchTest extends MediaWikiTestCase {
|
|
|
|
|
|
2014-08-24 06:52:38 +00:00
|
|
|
/** @var MIMEsearchPage */
|
2014-06-21 17:19:42 +00:00
|
|
|
private $page;
|
|
|
|
|
|
|
|
|
|
function setUp() {
|
2014-08-24 06:52:38 +00:00
|
|
|
$this->page = new MIMEsearchPage;
|
2014-06-21 17:19:42 +00:00
|
|
|
$context = new RequestContext();
|
|
|
|
|
$context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) );
|
|
|
|
|
$context->setRequest( new FauxRequest() );
|
|
|
|
|
$this->page->setContext( $context );
|
|
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providerMimeFiltering
|
2014-07-24 12:55:43 +00:00
|
|
|
* @param string $par Subpage for special page
|
|
|
|
|
* @param string $major Major MIME type we expect to look for
|
|
|
|
|
* @param string $minor Minor MIME type we expect to look for
|
2014-06-21 17:19:42 +00:00
|
|
|
*/
|
|
|
|
|
function testMimeFiltering( $par, $major, $minor ) {
|
|
|
|
|
$this->page->run( $par );
|
|
|
|
|
$qi = $this->page->getQueryInfo();
|
|
|
|
|
$this->assertEquals( $qi['conds']['img_major_mime'], $major );
|
|
|
|
|
if ( $minor !== null ) {
|
|
|
|
|
$this->assertEquals( $qi['conds']['img_minor_mime'], $minor );
|
|
|
|
|
} else {
|
|
|
|
|
$this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
|
|
|
|
|
}
|
|
|
|
|
$this->assertContains( 'image', $qi['tables'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function providerMimeFiltering() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ 'image/gif', 'image', 'gif' ],
|
|
|
|
|
[ 'image/png', 'image', 'png' ],
|
|
|
|
|
[ 'application/pdf', 'application', 'pdf' ],
|
|
|
|
|
[ 'image/*', 'image', null ],
|
|
|
|
|
[ 'multipart/*', 'multipart', null ],
|
|
|
|
|
];
|
2014-06-21 17:19:42 +00:00
|
|
|
}
|
|
|
|
|
}
|