Merge "Move around "ا" to after "آ" and not before"
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionStorageTest.php
index 642ada2..e9f16db 100644 (file)
@@ -22,6 +22,7 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $this->tablesUsed = array_merge( $this->tablesUsed,
                        [ 'page',
                                'revision',
+                               'ip_changes',
                                'text',
 
                                'recentchanges',
@@ -145,8 +146,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
        public function testConstructFromRow() {
                $orig = $this->makeRevision();
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'revision', '*', [ 'rev_id' => $orig->getId() ] );
+               $dbr = wfGetDB( DB_REPLICA );
+               $res = $dbr->select( 'revision', Revision::selectFields(), [ 'rev_id' => $orig->getId() ] );
                $this->assertTrue( is_object( $res ), 'query failed' );
 
                $row = $res->fetchObject();
@@ -163,8 +164,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
        public function testNewFromRow() {
                $orig = $this->makeRevision();
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'revision', '*', [ 'rev_id' => $orig->getId() ] );
+               $dbr = wfGetDB( DB_REPLICA );
+               $res = $dbr->select( 'revision', Revision::selectFields(), [ 'rev_id' => $orig->getId() ] );
                $this->assertTrue( is_object( $res ), 'query failed' );
 
                $row = $res->fetchObject();
@@ -187,8 +188,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $orig = $page->getRevision();
                $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select( 'archive', '*', [ 'ar_rev_id' => $orig->getId() ] );
+               $dbr = wfGetDB( DB_REPLICA );
+               $res = $dbr->select(
+                       'archive', Revision::selectArchiveFields(), [ 'ar_rev_id' => $orig->getId() ]
+               );
                $this->assertTrue( is_object( $res ), 'query failed' );
 
                $row = $res->fetchObject();
@@ -438,6 +441,25 @@ class RevisionStorageTest extends MediaWikiTestCase {
                $this->assertEquals( 'some testing text', $rev->getContent()->getNativeData() );
        }
 
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn() {
+               $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
+
+               $orig = $this->makeRevision( [
+                       'user_text' => $ip
+               ] );
+
+               // Make sure the revision was copied to ip_changes
+               $dbr = wfGetDB( DB_REPLICA );
+               $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
+               $row = $res->fetchObject();
+
+               $this->assertEquals( IP::toHex( $ip ), $row->ipc_hex );
+               $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp );
+       }
+
        public static function provideUserWasLastToEdit() {
                return [
                        [ # 0