Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384218 )

Change subject: RevisionUnittest for select*Fields methods
......................................................................

RevisionUnittest for select*Fields methods

Change-Id: I8ec1d35bb5e4706e5cfe72684bcac73c9f3d63cc
---
M tests/phpunit/includes/RevisionIntegrationTest.php
M tests/phpunit/includes/RevisionUnitTest.php
2 files changed, 152 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/18/384218/1

diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php 
b/tests/phpunit/includes/RevisionIntegrationTest.php
index bdd4561..ac7331a 100644
--- a/tests/phpunit/includes/RevisionIntegrationTest.php
+++ b/tests/phpunit/includes/RevisionIntegrationTest.php
@@ -331,30 +331,6 @@
        }
 
        /**
-        * @covers Revision::selectFields
-        */
-       public function testSelectFields() {
-               global $wgContentHandlerUseDB;
-
-               $fields = Revision::selectFields();
-
-               $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_user', $fields ), 'missing 
rev_user in list of fields' );
-
-               if ( $wgContentHandlerUseDB ) {
-                       $this->assertTrue( in_array( 'rev_content_model', 
$fields ),
-                               'missing rev_content_model in list of fields' );
-                       $this->assertTrue( in_array( 'rev_content_format', 
$fields ),
-                               'missing rev_content_format in list of fields' 
);
-               }
-       }
-
-       /**
         * @covers Revision::getPage
         */
        public function testGetPage() {
diff --git a/tests/phpunit/includes/RevisionUnitTest.php 
b/tests/phpunit/includes/RevisionUnitTest.php
index 47dcf65..5282ae6 100644
--- a/tests/phpunit/includes/RevisionUnitTest.php
+++ b/tests/phpunit/includes/RevisionUnitTest.php
@@ -222,4 +222,156 @@
                );
        }
 
+       public function provideSelectFields() {
+               yield [
+                       true,
+                       [
+                               'rev_id',
+                               'rev_page',
+                               'rev_text_id',
+                               'rev_timestamp',
+                               'rev_user_text',
+                               'rev_user',
+                               'rev_minor_edit',
+                               'rev_deleted',
+                               'rev_len',
+                               'rev_parent_id',
+                               'rev_sha1',
+                               'rev_comment_text' => 'rev_comment',
+                               'rev_comment_data' => 'NULL',
+                               'rev_comment_cid' => 'NULL',
+                               'rev_content_format',
+                               'rev_content_model',
+                       ]
+               ];
+               yield [
+                       false,
+                       [
+                               'rev_id',
+                               'rev_page',
+                               'rev_text_id',
+                               'rev_timestamp',
+                               'rev_user_text',
+                               'rev_user',
+                               'rev_minor_edit',
+                               'rev_deleted',
+                               'rev_len',
+                               'rev_parent_id',
+                               'rev_sha1',
+                               'rev_comment_text' => 'rev_comment',
+                               'rev_comment_data' => 'NULL',
+                               'rev_comment_cid' => 'NULL',
+                       ]
+               ];
+       }
+
+       /**
+        * @dataProvider provideSelectFields
+        * @covers Revision::selectFields
+        * @todo a true unit test would mock CommentStore
+        */
+       public function testSelectFields( $contentHandlerUseDB, $expected ) {
+               $this->setMwGlobals( 'wgContentHandlerUseDB', 
$contentHandlerUseDB );
+               $this->assertEquals( $expected, Revision::selectFields() );
+       }
+
+       public function provideSelectArchiveFields() {
+               yield [
+                       true,
+                       [
+                               'ar_id',
+                               'ar_page_id',
+                               'ar_rev_id',
+                               'ar_text',
+                               'ar_text_id',
+                               'ar_timestamp',
+                               'ar_user_text',
+                               'ar_user',
+                               'ar_minor_edit',
+                               'ar_deleted',
+                               'ar_len',
+                               'ar_parent_id',
+                               'ar_sha1',
+                               'ar_comment_text' => 'ar_comment',
+                               'ar_comment_data' => 'NULL',
+                               'ar_comment_cid' => 'NULL',
+                               'ar_content_format',
+                               'ar_content_model',
+                       ]
+               ];
+               yield [
+                       false,
+                       [
+                               'ar_id',
+                               'ar_page_id',
+                               'ar_rev_id',
+                               'ar_text',
+                               'ar_text_id',
+                               'ar_timestamp',
+                               'ar_user_text',
+                               'ar_user',
+                               'ar_minor_edit',
+                               'ar_deleted',
+                               'ar_len',
+                               'ar_parent_id',
+                               'ar_sha1',
+                               'ar_comment_text' => 'ar_comment',
+                               'ar_comment_data' => 'NULL',
+                               'ar_comment_cid' => 'NULL',
+                       ]
+               ];
+       }
+
+       /**
+        * @dataProvider provideSelectArchiveFields
+        * @covers Revision::selectArchiveFields
+        * @todo a true unit test would mock CommentStore
+        */
+       public function testSelectArchiveFields( $contentHandlerUseDB, 
$expected ) {
+               $this->setMwGlobals( 'wgContentHandlerUseDB', 
$contentHandlerUseDB );
+               $this->assertEquals( $expected, Revision::selectArchiveFields() 
);
+       }
+
+       /**
+        * @covers Revision::selectTextFields
+        */
+       public function testSelectTextFields() {
+               $this->assertEquals(
+                       [
+                               'old_text',
+                               'old_flags',
+                       ],
+                       Revision::selectTextFields()
+               );
+       }
+
+       /**
+        * @covers Revision::selectPageFields
+        */
+       public function testSelectPageFields() {
+               $this->assertEquals(
+                       [
+                               'page_namespace',
+                               'page_title',
+                               'page_id',
+                               'page_latest',
+                               'page_is_redirect',
+                               'page_len',
+                       ],
+                       Revision::selectPageFields()
+               );
+       }
+
+       /**
+        * @covers Revision::selectUserFields
+        */
+       public function testSelectUserFields() {
+               $this->assertEquals(
+                       [
+                               'user_name',
+                       ],
+                       Revision::selectUserFields()
+               );
+       }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/384218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ec1d35bb5e4706e5cfe72684bcac73c9f3d63cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to