Fix typo in Special:MIMESearch causing minor part to be ignored.
authorBrian Wolff <bawolff+wn@gmail.com>
Sat, 21 Jun 2014 17:19:42 +0000 (14:19 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sat, 21 Jun 2014 17:19:42 +0000 (14:19 -0300)
img_minor_mime was being added to wrong part of query info
array, and thus was being ignored.

Whoops.

Change-Id: I55f45f5ae9621ff1319b34a2aa85cb4bd2c96253
Follow-up: c93baa941a5a56b7

includes/specials/SpecialMIMEsearch.php
tests/phpunit/includes/specials/SpecialMIMESearchTest.php [new file with mode: 0644]

index cb9dac9..4d9e7da 100644 (file)
@@ -85,8 +85,8 @@ class MIMEsearchPage extends QueryPage {
                                        MEDIATYPE_TEXT,
                                        MEDIATYPE_EXECUTABLE,
                                        MEDIATYPE_ARCHIVE,
-                               ) + $minorType,
-                       ),
+                               ),
+                       ) + $minorType,
                );
 
                return $qi;
diff --git a/tests/phpunit/includes/specials/SpecialMIMESearchTest.php b/tests/phpunit/includes/specials/SpecialMIMESearchTest.php
new file mode 100644 (file)
index 0000000..e7bb35c
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+class SpecialMIMESearchTest extends MediaWikiTestCase {
+
+       /** @var MIMESearchPage */
+       private $page;
+
+       function setUp() {
+               $this->page = new MIMESearchPage;
+               $context = new RequestContext();
+               $context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) );
+               $context->setRequest( new FauxRequest() );
+               $this->page->setContext( $context );
+
+               parent::setUp();
+       }
+
+       /**
+        * @dataProvider providerMimeFiltering
+        * @param $par String subpage for special page
+        * @param $major String Major mime type we expect to look for
+        * @param $minor String Minor mime type we expect to look for
+        */
+       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() {
+               return array(
+                       array( 'image/gif', 'image', 'gif' ),
+                       array( 'image/png', 'image', 'png' ),
+                       array( 'application/pdf', 'application', 'pdf' ),
+                       array( 'image/*', 'image', null ),
+                       array( 'multipart/*', 'multipart', null ),
+               );
+       }
+}