jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394357 )

Change subject: Add test for WikiPage::updateCategoryCounts
......................................................................


Add test for WikiPage::updateCategoryCounts

Bug: T180989
Change-Id: Iff4bb885e5d385a7b3ec6169ee9a3e1e82d7d993
---
M tests/phpunit/includes/page/WikiPageDbTestBase.php
1 file changed, 29 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, approved



diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php 
b/tests/phpunit/includes/page/WikiPageDbTestBase.php
index 7ef279e..64ad644 100644
--- a/tests/phpunit/includes/page/WikiPageDbTestBase.php
+++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php
@@ -12,6 +12,7 @@
                        [ 'page',
                                'revision',
                                'archive',
+                               'category',
                                'ip_changes',
                                'text',
 
@@ -1154,4 +1155,32 @@
                ];
        }
 
+       /**
+        * @covers WikiPage::updateCategoryCounts
+        */
+       public function testUpdateCategoryCounts() {
+               $page = new WikiPage( Title::newFromText( __METHOD__ ) );
+
+               // Add an initial category
+               $page->updateCategoryCounts( [ 'A' ], [], 0 );
+
+               $this->assertEquals( 1, Category::newFromName( 'A' 
)->getPageCount() );
+               $this->assertEquals( 0, Category::newFromName( 'B' 
)->getPageCount() );
+               $this->assertEquals( 0, Category::newFromName( 'C' 
)->getPageCount() );
+
+               // Add a new category
+               $page->updateCategoryCounts( [ 'B' ], [], 0 );
+
+               $this->assertEquals( 1, Category::newFromName( 'A' 
)->getPageCount() );
+               $this->assertEquals( 1, Category::newFromName( 'B' 
)->getPageCount() );
+               $this->assertEquals( 0, Category::newFromName( 'C' 
)->getPageCount() );
+
+               // Add and remove a category
+               $page->updateCategoryCounts( [ 'C' ], [ 'A' ], 0 );
+
+               $this->assertEquals( 0, Category::newFromName( 'A' 
)->getPageCount() );
+               $this->assertEquals( 1, Category::newFromName( 'B' 
)->getPageCount() );
+               $this->assertEquals( 1, Category::newFromName( 'C' 
)->getPageCount() );
+       }
+
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iff4bb885e5d385a7b3ec6169ee9a3e1e82d7d993
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to