Fix doc error in new incr test
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionTest.php
index 197bb06..b5819ff 100644 (file)
@@ -54,7 +54,10 @@ class RevisionTest extends MediaWikiTestCase {
                parent::tearDown();
        }
 
-       function testGetRevisionText() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionText() {
                $row = new stdClass;
                $row->old_flags = '';
                $row->old_text = 'This is a bunch of revision text.';
@@ -63,7 +66,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testGetRevisionTextGzip() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionTextGzip() {
                $this->checkPHPExtension( 'zlib' );
 
                $row = new stdClass;
@@ -74,7 +80,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testGetRevisionTextUtf8Native() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionTextUtf8Native() {
                $row = new stdClass;
                $row->old_flags = 'utf-8';
                $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
@@ -84,7 +93,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testGetRevisionTextUtf8Legacy() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionTextUtf8Legacy() {
                $row = new stdClass;
                $row->old_flags = '';
                $row->old_text = "Wiki est l'\xe9cole superieur !";
@@ -94,7 +106,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testGetRevisionTextUtf8NativeGzip() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionTextUtf8NativeGzip() {
                $this->checkPHPExtension( 'zlib' );
 
                $row = new stdClass;
@@ -106,7 +121,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testGetRevisionTextUtf8LegacyGzip() {
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionTextUtf8LegacyGzip() {
                $this->checkPHPExtension( 'zlib' );
 
                $row = new stdClass;
@@ -118,7 +136,10 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ) );
        }
 
-       function testCompressRevisionTextUtf8() {
+       /**
+        * @covers Revision::compressRevisionText
+        */
+       public function testCompressRevisionTextUtf8() {
                $row = new stdClass;
                $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
                $row->old_flags = Revision::compressRevisionText( $row->old_text );
@@ -132,11 +153,12 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ), "getRevisionText" );
        }
 
-       function testCompressRevisionTextUtf8Gzip() {
+       /**
+        * @covers Revision::compressRevisionText
+        */
+       public function testCompressRevisionTextUtf8Gzip() {
                $this->checkPHPExtension( 'zlib' );
-
-               global $wgCompressRevisions;
-               $wgCompressRevisions = true;
+               $this->setMwGlobals( 'wgCompressRevisions', true );
 
                $row = new stdClass;
                $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
@@ -157,6 +179,8 @@ class RevisionTest extends MediaWikiTestCase {
         * @param string $text
         * @param string $title
         * @param string $model
+        * @param null $format
+        *
         * @return Revision
         */
        function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
@@ -168,13 +192,13 @@ class RevisionTest extends MediaWikiTestCase {
 
                $rev = new Revision(
                        array(
-                               'id'         => 42,
-                               'page'       => 23,
-                               'title'      => $title,
+                               'id' => 42,
+                               'page' => 23,
+                               'title' => $title,
 
-                               'content'    => $content,
-                               'length'     => $content->getSize(),
-                               'comment'    => "testing",
+                               'content' => $content,
+                               'length' => $content->getSize(),
+                               'comment' => "testing",
                                'minor_edit' => false,
 
                                'content_format' => $format,
@@ -189,15 +213,16 @@ class RevisionTest extends MediaWikiTestCase {
                return array(
                        array( 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ),
                        array( 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ),
-                       array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
+                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
                );
        }
 
        /**
         * @group Database
         * @dataProvider dataGetContentModel
+        * @covers Revision::getContentModel
         */
-       function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
+       public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
 
                $this->assertEquals( $expectedModel, $rev->getContentModel() );
@@ -209,15 +234,16 @@ class RevisionTest extends MediaWikiTestCase {
                        array( 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ),
                        array( 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ),
                        array( 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ),
-                       array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
+                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
                );
        }
 
        /**
         * @group Database
         * @dataProvider dataGetContentFormat
+        * @covers Revision::getContentFormat
         */
-       function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
+       public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
 
                $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
@@ -228,15 +254,16 @@ class RevisionTest extends MediaWikiTestCase {
                return array(
                        array( 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ),
                        array( 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ),
-                       array( serialize('hello world'), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
+                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
                );
        }
 
        /**
         * @group Database
         * @dataProvider dataGetContentHandler
+        * @covers Revision::getContentHandler
         */
-       function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
+       public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
 
                $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
@@ -246,16 +273,17 @@ class RevisionTest extends MediaWikiTestCase {
                //NOTE: we expect the help namespace to always contain wikitext
                return array(
                        array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
-                       array( serialize('hello world'), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize('hello world') ),
-                       array( serialize('hello world'), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize('hello world') ),
+                       array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
+                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
                );
        }
 
        /**
         * @group Database
         * @dataProvider dataGetContent
+        * @covers Revision::getContent
         */
-       function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+       public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
                $content = $rev->getContent( $audience );
 
@@ -266,16 +294,17 @@ class RevisionTest extends MediaWikiTestCase {
                //NOTE: we expect the help namespace to always contain wikitext
                return array(
                        array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
-                       array( serialize('hello world'), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
-                       array( serialize('hello world'), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
+                       array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
+                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
                );
        }
 
        /**
         * @group Database
         * @dataProvider dataGetText
+        * @covers Revision::getText
         */
-       function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
+       public function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
                $this->hideDeprecated( 'Revision::getText' );
 
                $rev = $this->newTestRevision( $text, $title, $model, $format );
@@ -286,8 +315,9 @@ class RevisionTest extends MediaWikiTestCase {
        /**
         * @group Database
         * @dataProvider dataGetText
+        * @covers Revision::getRawText
         */
-       function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
+       public function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
                $this->hideDeprecated( 'Revision::getRawText' );
 
                $rev = $this->newTestRevision( $text, $title, $model, $format );
@@ -296,7 +326,7 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
 
-       public function dataGetSize( ) {
+       public function dataGetSize() {
                return array(
                        array( "hello world.", CONTENT_MODEL_WIKITEXT, 12 ),
                        array( serialize( "hello world." ), "testing", 12 ),
@@ -313,7 +343,7 @@ class RevisionTest extends MediaWikiTestCase {
                $this->assertEquals( $expected_size, $rev->getSize() );
        }
 
-       public function dataGetSha1( ) {
+       public function dataGetSha1() {
                return array(
                        array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
                        array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
@@ -330,13 +360,16 @@ class RevisionTest extends MediaWikiTestCase {
                $this->assertEquals( $expected_hash, $rev->getSha1() );
        }
 
+       /**
+        * @covers Revision::__construct
+        */
        public function testConstructWithText() {
                $this->hideDeprecated( "Revision::getText" );
 
                $rev = new Revision( array(
-                                         'text' => 'hello world.',
-                                         'content_model' => CONTENT_MODEL_JAVASCRIPT
-                                    ));
+                       'text' => 'hello world.',
+                       'content_model' => CONTENT_MODEL_JAVASCRIPT
+               );
 
                $this->assertNotNull( $rev->getText(), 'no content text' );
                $this->assertNotNull( $rev->getContent(), 'no content object available' );
@@ -344,14 +377,17 @@ class RevisionTest extends MediaWikiTestCase {
                $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
        }
 
+       /**
+        * @covers Revision::__construct
+        */
        public function testConstructWithContent() {
                $this->hideDeprecated( "Revision::getText" );
 
                $title = Title::newFromText( 'RevisionTest_testConstructWithContent' );
 
                $rev = new Revision( array(
-                                         'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ),
-                                    ));
+                       'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ),
+               );
 
                $this->assertNotNull( $rev->getText(), 'no content text' );
                $this->assertNotNull( $rev->getContent(), 'no content object available' );
@@ -363,19 +399,20 @@ class RevisionTest extends MediaWikiTestCase {
         * Tests whether $rev->getContent() returns a clone when needed.
         *
         * @group Database
+        * @covers Revision::getContent
         */
-       function testGetContentClone( ) {
+       public function testGetContentClone() {
                $content = new RevisionTestModifyableContent( "foo" );
 
                $rev = new Revision(
                        array(
-                               'id'         => 42,
-                               'page'       => 23,
-                               'title'      => Title::newFromText( "testGetContentClone_dummy" ),
+                               'id' => 42,
+                               'page' => 23,
+                               'title' => Title::newFromText( "testGetContentClone_dummy" ),
 
-                               'content'    => $content,
-                               'length'     => $content->getSize(),
-                               'comment'    => "testing",
+                               'content' => $content,
+                               'length' => $content->getSize(),
+                               'comment' => "testing",
                                'minor_edit' => false,
                        )
                );
@@ -396,8 +433,9 @@ class RevisionTest extends MediaWikiTestCase {
         * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
         *
         * @group Database
+        * @covers Revision::getContent
         */
-       function testGetContentUncloned() {
+       public function testGetContentUncloned() {
                $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT );
                $content = $rev->getContent( Revision::RAW );
                $content2 = $rev->getContent( Revision::RAW );
@@ -405,7 +443,6 @@ class RevisionTest extends MediaWikiTestCase {
                // for immutable content like wikitext, this should be the same object
                $this->assertSame( $content, $content2 );
        }
-
 }
 
 class RevisionTestModifyableContent extends TextContent {
@@ -413,7 +450,7 @@ class RevisionTestModifyableContent extends TextContent {
                parent::__construct( $text, "RevisionTestModifyableContent" );
        }
 
-       public function copy( ) {
+       public function copy() {
                return new RevisionTestModifyableContent( $this->mText );
        }
 
@@ -424,12 +461,11 @@ class RevisionTestModifyableContent extends TextContent {
        public function setText( $text ) {
                $this->mText = $text;
        }
-
 }
 
 class RevisionTestModifyableContentHandler extends TextContentHandler {
 
-       public function __construct( ) {
+       public function __construct() {
                parent::__construct( "RevisionTestModifyableContent", array( CONTENT_FORMAT_TEXT ) );
        }