SECURITY: blacklist CSS var()
[lhc/web/wiklou.git] / tests / phpunit / includes / content / TextContentTest.php
index a890494..ecd23f1 100644 (file)
@@ -32,7 +32,7 @@ class TextContentTest extends MediaWikiLangTestCase {
                                CONTENT_MODEL_CSS,
                                CONTENT_MODEL_JAVASCRIPT,
                        ],
-                       'wgTidyConfig' => [ 'driver' => 'disabled' ],
+                       'wgTidyConfig' => [ 'driver' => 'RemexHtml' ],
                        'wgCapitalLinks' => true,
                        'wgHooks' => [], // bypass hook ContentGetParserOutput that force custom rendering
                ] );
@@ -45,6 +45,10 @@ class TextContentTest extends MediaWikiLangTestCase {
                parent::tearDown();
        }
 
+       /**
+        * @param string $text
+        * @return TextContent
+        */
        public function newContent( $text ) {
                return new TextContent( $text );
        }
@@ -131,7 +135,7 @@ class TextContentTest extends MediaWikiLangTestCase {
                        $options
                );
 
-               $this->assertEquals( $expected, $content->getNativeData() );
+               $this->assertEquals( $expected, $content->getText() );
        }
 
        public static function dataPreloadTransform() {
@@ -154,7 +158,7 @@ class TextContentTest extends MediaWikiLangTestCase {
                $content = $this->newContent( $text );
                $content = $content->preloadTransform( $this->context->getTitle(), $options );
 
-               $this->assertEquals( $expected, $content->getNativeData() );
+               $this->assertEquals( $expected, $content->getText() );
        }
 
        public static function dataGetRedirectTarget() {
@@ -269,7 +273,7 @@ class TextContentTest extends MediaWikiLangTestCase {
                $copy = $content->copy();
 
                $this->assertTrue( $content->equals( $copy ), 'copy must be equal to original' );
-               $this->assertEquals( 'hello world.', $copy->getNativeData() );
+               $this->assertEquals( 'hello world.', $copy->getText() );
        }
 
        /**
@@ -281,13 +285,22 @@ class TextContentTest extends MediaWikiLangTestCase {
                $this->assertEquals( 12, $content->getSize() );
        }
 
+       /**
+        * @covers TextContent::getText
+        */
+       public function testGetText() {
+               $content = $this->newContent( 'hello world.' );
+
+               $this->assertEquals( 'hello world.', $content->getText() );
+       }
+
        /**
         * @covers TextContent::getNativeData
         */
        public function testGetNativeData() {
                $content = $this->newContent( 'hello world.' );
 
-               $this->assertEquals( 'hello world.', $content->getNativeData() );
+               $this->assertEquals( 'hello world.', $content->getText() );
        }
 
        /**
@@ -438,13 +451,14 @@ class TextContentTest extends MediaWikiLangTestCase {
        public function testConvert( $text, $model, $lossy, $expectedNative ) {
                $content = $this->newContent( $text );
 
+               /** @var TextContent $converted */
                $converted = $content->convert( $model, $lossy );
 
                if ( $expectedNative === false ) {
                        $this->assertFalse( $converted, "conversion to $model was expected to fail!" );
                } else {
                        $this->assertInstanceOf( Content::class, $converted );
-                       $this->assertEquals( $expectedNative, $converted->getNativeData() );
+                       $this->assertEquals( $expectedNative, $converted->getText() );
                }
        }
 
@@ -473,4 +487,14 @@ class TextContentTest extends MediaWikiLangTestCase {
                ];
        }
 
+       /**
+        * @covers TextContent::__construct
+        * @covers TextContentHandler::serializeContent
+        */
+       public function testSerialize() {
+               $cnt = $this->newContent( 'testing text' );
+
+               $this->assertSame( 'testing text', $cnt->serialize() );
+       }
+
 }