Do not insert page titles into querycache.qc_value
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialSearchTest.php
index 4f4fa25..eeb4b00 100644 (file)
@@ -11,13 +11,34 @@ use MediaWiki\MediaWikiServices;
  */
 class SpecialSearchTest extends MediaWikiTestCase {
 
+       /**
+        * @covers SpecialSearch::load
+        * @covers SpecialSearch::showResults
+        */
+       public function testValidateSortOrder() {
+               $ctx = new RequestContext();
+               $ctx->setRequest( new FauxRequest( [
+                       'search' => 'foo',
+                       'fulltext' => 1,
+                       'sort' => 'invalid',
+               ] ) );
+               $sp = Title::makeTitle( NS_SPECIAL, 'Search' );
+               MediaWikiServices::getInstance()
+                       ->getSpecialPageFactory()
+                       ->executePath( $sp, $ctx );
+               $html = $ctx->getOutput()->getHTML();
+               $this->assertRegExp( '/class="warningbox"/', $html, 'must contain warnings' );
+               $this->assertRegExp( '/Sort order of invalid is unrecognized/',
+                       $html, 'must tell user sort order is invalid' );
+       }
+
        /**
         * @covers SpecialSearch::load
         * @dataProvider provideSearchOptionsTests
         * @param array $requested Request parameters. For example:
-        *   array( 'ns5' => true, 'ns6' => true). Null to use default options.
+        *   [ 'ns5' => true, 'ns6' => true ]. Null to use default options.
         * @param array $userOptions User options to test with. For example:
-        *   array('searchNs5' => 1 );. Null to use default options.
+        *   [ 'searchNs5' => 1 ];. Null to use default options.
         * @param string $expectedProfile An expected search profile name
         * @param array $expectedNS Expected namespaces
         * @param string $message