Merge "Avoid CAS errors on double post to ApiOptions"
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionStorageTest.php
index e69660e..301ec5c 100644 (file)
  * ^--- important, causes tests not to fail with timeout
  */
 class RevisionStorageTest extends MediaWikiTestCase {
-
        /**
         * @var WikiPage $the_page
         */
-       var $the_page;
+       private $the_page;
 
        function __construct( $name = null, array $data = array(), $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
@@ -52,7 +51,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
                MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
                $wgContLang->resetNamespaces(); # reset namespace cache
                if ( !$this->the_page ) {
-                       $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page", CONTENT_MODEL_WIKITEXT );
+                       $this->the_page = $this->createPage(
+                               'RevisionStorageTest_the_page',
+                               "just a dummy page",
+                               CONTENT_MODEL_WIKITEXT
+                       );
                }
        }
 
@@ -174,7 +177,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::newFromArchiveRow
         */
        public function testNewFromArchiveRow() {
-               $page = $this->createPage( 'RevisionStorageTest_testNewFromArchiveRow', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewFromArchiveRow',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $orig = $page->getRevision();
                $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
 
@@ -205,7 +212,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::fetchRevision
         */
        public function testFetchRevision() {
-               $page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testFetchRevision',
+                       'one',
+                       CONTENT_MODEL_WIKITEXT
+               );
 
                // Hidden process cache assertion below
                $page->getRevision()->getId();
@@ -215,7 +226,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
 
                $res = Revision::fetchRevision( $page->getTitle() );
 
-               #note: order is unspecified
+               # note: order is unspecified
                $rows = array();
                while ( ( $row = $res->fetchObject() ) ) {
                        $rows[$row->rev_id] = $row;
@@ -235,7 +246,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
 
                $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
                $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
-               $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
+               $this->assertTrue(
+                       in_array( 'rev_timestamp', $fields ),
+                       'missing rev_timestamp in list of fields'
+               );
                $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
 
                if ( $wgContentHandlerUseDB ) {
@@ -283,7 +297,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $this->assertNull( $rev->getContent(),
                        "getContent() should return null if the revision's text blob could not be loaded." );
 
-               //NOTE: check this twice, once for lazy initialization, and once with the cached value.
+               // NOTE: check this twice, once for lazy initialization, and once with the cached value.
                $this->assertNull( $rev->getContent(),
                        "getContent() should return null if the revision's text blob could not be loaded." );
        }
@@ -351,7 +365,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::isCurrent
         */
        public function testIsCurrent() {
-               $page = $this->createPage( 'RevisionStorageTest_testIsCurrent', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testIsCurrent',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                # @todo find out if this should be true
@@ -360,7 +378,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $rev1x = Revision::newFromId( $rev1->getId() );
                $this->assertTrue( $rev1x->isCurrent() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ), 'second rev' );
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+                       'second rev'
+               );
                $rev2 = $page->getRevision();
 
                # @todo find out if this should be true
@@ -377,12 +398,17 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::getPrevious
         */
        public function testGetPrevious() {
-               $page = $this->createPage( 'RevisionStorageTest_testGetPrevious', 'Lorem Ipsum testGetPrevious', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testGetPrevious',
+                       'Lorem Ipsum testGetPrevious',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                $this->assertNull( $rev1->getPrevious() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
                        'second rev testGetPrevious' );
                $rev2 = $page->getRevision();
 
@@ -394,13 +420,19 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::getNext
         */
        public function testGetNext() {
-               $page = $this->createPage( 'RevisionStorageTest_testGetNext', 'Lorem Ipsum testGetNext', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testGetNext',
+                       'Lorem Ipsum testGetNext',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $rev1 = $page->getRevision();
 
                $this->assertNull( $rev1->getNext() );
 
-               $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
-                       'second rev testGetNext' );
+               $page->doEditContent(
+                       ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+                       'second rev testGetNext'
+               );
                $rev2 = $page->getRevision();
 
                $this->assertNotNull( $rev1->getNext() );
@@ -411,7 +443,11 @@ class RevisionStorageTest extends MediaWikiTestCase {
         * @covers Revision::newNullRevision
         */
        public function testNewNullRevision() {
-               $page = $this->createPage( 'RevisionStorageTest_testNewNullRevision', 'some testing text', CONTENT_MODEL_WIKITEXT );
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewNullRevision',
+                       'some testing text',
+                       CONTENT_MODEL_WIKITEXT
+               );
                $orig = $page->getRevision();
 
                $dbw = wfGetDB( DB_MASTER );
@@ -426,16 +462,16 @@ class RevisionStorageTest extends MediaWikiTestCase {
 
        public static function provideUserWasLastToEdit() {
                return array(
-                       array( #0
+                       array( # 0
                                3, true, # actually the last edit
                        ),
-                       array( #1
+                       array( # 1
                                2, true, # not the current edit, but still by this user
                        ),
-                       array( #2
+                       array( # 2
                                1, false, # edit by another user
                        ),
-                       array( #3
+                       array( # 3
                                0, false, # first edit, by this user, but another user edited in the mean time
                        ),
                );
@@ -469,7 +505,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
                # zero
                $revisions[0] = new Revision( array(
                        'page' => $page->getId(),
-                       'title' => $page->getTitle(), // we need the title to determine the page's default content model
+                       // we need the title to determine the page's default content model
+                       'title' => $page->getTitle(),
                        'timestamp' => '20120101000000',
                        'user' => $userA->getId(),
                        'text' => 'zero',
@@ -481,7 +518,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
                # one
                $revisions[1] = new Revision( array(
                        'page' => $page->getId(),
-                       'title' => $page->getTitle(), // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+                       // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+                       'title' => $page->getTitle(),
                        'timestamp' => '20120101000100',
                        'user' => $userA->getId(),
                        'text' => 'one',