Merge "Improve documentation of constants throughout the codebase"
[lhc/web/wiklou.git] / tests / phpunit / includes / page / WikiCategoryPageTest.php
index 5f1bf0c..9f696c0 100644 (file)
@@ -60,4 +60,46 @@ class WikiCategoryPageTest extends MediaWikiLangTestCase {
 
                ScopedCallback::consume( $scopedOverride );
        }
+
+       /**
+        * @covers WikiCategoryPage::isExpectedUnusedCategory
+        */
+       public function testExpectUnusedCategory_PropertyNotSet() {
+               $title = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
+               $categoryPage = WikiCategoryPage::factory( $title );
+
+               $pageProps = $this->getMockPageProps();
+               $pageProps->expects( $this->once() )
+                       ->method( 'getProperties' )
+                       ->with( $title, 'expectunusedcategory' )
+                       ->will( $this->returnValue( [] ) );
+
+               $scopedOverride = PageProps::overrideInstance( $pageProps );
+
+               $this->assertFalse( $categoryPage->isExpectedUnusedCategory() );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
+
+       /**
+        * @dataProvider provideCategoryContent
+        * @covers WikiCategoryPage::isExpectedUnusedCategory
+        */
+       public function testExpectUnusedCategory_PropertyIsSet( $isExpectedUnusedCategory ) {
+               $categoryTitle = Title::makeTitle( NS_CATEGORY, 'CategoryPage' );
+               $categoryPage = WikiCategoryPage::factory( $categoryTitle );
+               $returnValue = $isExpectedUnusedCategory ? [ $categoryTitle->getArticleID() => '' ] : [];
+
+               $pageProps = $this->getMockPageProps();
+               $pageProps->expects( $this->once() )
+                       ->method( 'getProperties' )
+                       ->with( $categoryTitle, 'expectunusedcategory' )
+                       ->will( $this->returnValue( $returnValue ) );
+
+               $scopedOverride = PageProps::overrideInstance( $pageProps );
+
+               $this->assertEquals( $isExpectedUnusedCategory, $categoryPage->isExpectedUnusedCategory() );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
 }