Add @covers tags to objectcache tests
[lhc/web/wiklou.git] / tests / phpunit / includes / MessageTest.php
index 424218e..f99cccd 100644 (file)
@@ -1,5 +1,10 @@
 <?php
 
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * @group Database
+ */
 class MessageTest extends MediaWikiLangTestCase {
 
        protected function setUp() {
@@ -394,6 +399,22 @@ class MessageTest extends MediaWikiLangTestCase {
                $this->assertSame( 'example &amp;', $msg->escaped() );
        }
 
+       public function testRawHtmlInMsg() {
+               global $wgParserConf;
+               $this->setMwGlobals( 'wgRawHtml', true );
+               // We have to reset the core hook registration.
+               // to register the html hook
+               MessageCache::destroyInstance();
+               $this->setMwGlobals( 'wgParser',
+                       ObjectFactory::constructClassInstance( $wgParserConf['class'], [ $wgParserConf ] )
+               );
+
+               $msg = new RawMessage( '<html><script>alert("xss")</script></html>' );
+               $txt = '<span class="error">&lt;html&gt; tags cannot be' .
+                       ' used outside of normal pages.</span>';
+               $this->assertSame( $txt, $msg->parse() );
+       }
+
        /**
         * @covers Message::params
         * @covers Message::toString
@@ -449,7 +470,6 @@ class MessageTest extends MediaWikiLangTestCase {
 
        /**
         * FIXME: This should not need database, but Language#formatExpiry does (T57912)
-        * @group Database
         * @covers Message::expiryParam
         * @covers Message::expiryParams
         */