Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/276899

Change subject: Hygiene: Add some @cover tags
......................................................................

Hygiene: Add some @cover tags

It would be nice to see some coverage on
https://tools.wmflabs.org/coverage/MobileFrontend/extensions_MobileFrontend.html
This gets us started with tests in the root directory.

Bug: T102006
Change-Id: I73010d4ba024976741f1ea780e1fda55b3e15111
---
M tests/phpunit/DeviceDetectionTest.php
M tests/phpunit/MenuBuilderTest.php
M tests/phpunit/MobileContextTest.php
M tests/phpunit/MobileFormatterTest.php
M tests/phpunit/MobileFrontend.hooksTest.php
M tests/phpunit/MobileFrontend.skin.hooksTest.php
6 files changed, 61 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/99/276899/1

diff --git a/tests/phpunit/DeviceDetectionTest.php 
b/tests/phpunit/DeviceDetectionTest.php
index 1ccdd39..0e8333d 100644
--- a/tests/phpunit/DeviceDetectionTest.php
+++ b/tests/phpunit/DeviceDetectionTest.php
@@ -90,6 +90,7 @@
 
        /**
         * @dataProvider provideTestIsMobileDevice
+        * @covers DeviceDetection::detectDeviceProperties
         */
        public function testIsMobileDevice( $expected, $userAgent ) {
                $detector = new DeviceDetection();
@@ -135,6 +136,7 @@
 
        /**
         * @dataProvider provideTestIsTablet
+        * @covers DeviceDetection::isMobileDevice
         */
        public function testIsTablet( $expected, $userAgent ) {
                $detector = new DeviceDetection();
diff --git a/tests/phpunit/MenuBuilderTest.php 
b/tests/phpunit/MenuBuilderTest.php
index 75081d2..002de62 100644
--- a/tests/phpunit/MenuBuilderTest.php
+++ b/tests/phpunit/MenuBuilderTest.php
@@ -18,12 +18,19 @@
                'class' => 'mw-ui-icon mw-ui-icon-before mw-ui-icon-nearby',
        );
 
+       /**
+        * @covers MenuBuilder::getEntries
+        */
        public function test_it_shouldnt_have_entries_by_default() {
                $menu = new MenuBuilder();
 
                $this->assertEmpty( $menu->getEntries() );
        }
 
+       /**
+        * @covers MenuBuilder::insert
+        * @covers MenuEntry::addComponent
+        */
        public function test_inserting_an_entry() {
                $menu = new MenuBuilder();
                $menu->insert( 'home' )
@@ -46,6 +53,10 @@
                $this->assertEquals( $expectedEntries, $menu->getEntries() );
        }
 
+       /**
+        * @covers MenuBuilder::insert
+        * @covers MenuEntry::addComponent
+        */
        public function test_inserting_an_entry_after_another() {
                $menu = new MenuBuilder();
                $menu->insert( 'home' )
@@ -94,6 +105,8 @@
        /**
         * @expectedException DomainException
         * @expectedExceptionMessage The "home" entry doesn't exist.
+        * @covers MenuBuilder::insertAfter
+        * @covers MenuEntry::addComponent
         */
        public function test_inserting_an_entry_after_that_doesnt_exist() {
                $menu = new MenuBuilder();
@@ -108,6 +121,7 @@
        /**
         * @expectedException DomainException
         * @expectedExceptionMessage The "home" entry already exists.
+        * @covers MenuBuilder::insert
         */
        public function test_inserting_an_entry_with_an_existing_name() {
                $menu = new MenuBuilder();
@@ -118,6 +132,7 @@
        /**
         * @expectedException DomainException
         * @expectedExceptionMessage The "home" entry already exists.
+        * @covers MenuBuilder::insert
         */
        public function test_inserting_an_entry_with_an_existing_name_after() {
                $menu = new MenuBuilder();
@@ -125,6 +140,10 @@
                $menu->insertAfter( 'home', 'home' );
        }
 
+       /**
+        * @covers MenuBuilder::insert
+        * @covers MenuEntry::addComponent
+        */
        public function test_inserting_an_entry_with_multiple_components() {
                $authLoginComponent = array(
                        'text' => 'Phuedx (WMF)',
@@ -165,6 +184,10 @@
                $this->assertEquals( $expectedEntries, $menu->getEntries() );
        }
 
+       /**
+        * @covers MenuBuilder::insert
+        * @covers MenuEntry::addComponent
+        */
        public function test_inserting_a_javascript_only_entry() {
                $menu = new MenuBuilder();
                $menu->insert( 'nearby', $isJSOnly = true )
diff --git a/tests/phpunit/MobileContextTest.php 
b/tests/phpunit/MobileContextTest.php
index 4dfc4fd..36557b4 100644
--- a/tests/phpunit/MobileContextTest.php
+++ b/tests/phpunit/MobileContextTest.php
@@ -58,6 +58,7 @@
 
        /**
         * @dataProvider getBaseDomainProvider
+        * @covers MobileContext::getBaseDomain
         */
        public function testGetBaseDomain( $server, $baseDomain ) {
                $this->setMwGlobals( 'wgServer', $server );
@@ -75,6 +76,9 @@
                );
        }
 
+       /**
+        * @covers MobileContext::getMobileUrl
+        */
        public function testGetMobileUrl() {
                $this->setMwGlobals( array(
                        'wgMFMobileHeader' => 'X-WAP',
@@ -111,6 +115,9 @@
                $this->assertEquals( 3, $invokes, 'Ensure that hook got the 
right context' );
        }
 
+       /**
+        * @covers MobileContext::parseMobileUrlTemplate
+        */
        public function testParseMobileUrlTemplate() {
                $this->setMwGlobals( 'wgMobileUrlTemplate', 
'%h0.m.%h1.%h2/path/morepath' );
                $context = $this->makeContext();
@@ -130,6 +137,7 @@
 
        /**
         * @dataProvider updateMobileUrlHostProvider
+        * @covers MobileContext::updateMobileUrlHost
         */
        public function testUpdateMobileUrlHost( $url, $expected, $urlTemplate 
) {
                $updateMobileUrlHost = self::getMethod( "updateMobileUrlHost" );
@@ -175,6 +183,7 @@
 
        /**
         * @dataProvider updateDesktopUrlQueryProvider
+        * @covers MobileContext::updateDesktopUrlQuery
         */
        public function testUpdateDesktopUrlQuery( $mobile, $desktop ) {
                $updateDesktopUrlQuery = self::getMethod( 
"updateDesktopUrlQuery" );
@@ -197,6 +206,7 @@
 
        /**
         * @dataProvider updateDesktopUrlHostProvider
+        * @covers MobileContext::updateDesktopUrlHost
         */
        public function testUpdateDesktopUrlHost( $mobile, $desktop, $server ) {
                $updateMobileUrlHost = self::getMethod( "updateDesktopUrlHost" 
);
@@ -231,6 +241,9 @@
                );
        }
 
+       /**
+        * @covers MobileContext::updateMobileUrlPath
+        */
        public function testUpdateMobileUrlPath() {
                $this->setMwGlobals( array(
                        'wgScriptPath' => '/wiki',
@@ -257,6 +270,7 @@
 
        /**
         * @dataProvider isFauxMobileDeviceProvider
+        * @covers MobileContext::isFauxMobileDevice
         */
        public function testIsFauxMobileDevice( $isFauxDevice, $msg, $useformat 
= null ) {
                $isFauxMobileDevice = self::getMethod( 'isFauxMobileDevice' );
@@ -282,6 +296,7 @@
 
        /**
         * @dataProvider shouldDisplayMobileViewProvider
+        * @covers MobileContext::shouldDisplayMobileView
         */
        public function testShouldDisplayMobileView( $shouldDisplay, $xWap = 
null,
                $requestVal = array(), $msg = null
@@ -325,6 +340,7 @@
 
        /**
         * @dataProvider getMobileActionProvider
+        * @covers MobileContext::getMobileAction
         */
        public function testGetMobileAction( $mobileaction = null ) {
                $context = $this->makeContext();
@@ -347,6 +363,7 @@
 
        /**
         * @dataProvider getUseFormatProvider
+        * @covers MobileContext::getUseFormat
         */
        public function testGetUseFormat( $explicit, $requestParam, $expected ) 
{
                $context = $this->makeContext();
@@ -364,6 +381,9 @@
                );
        }
 
+       /**
+        * @covers MobileContext::getUseFormatCookieExpiry
+        */
        public function testGetUseFormatCookieExpiry() {
                global $wgCookieExpiration;
                $getUseFormatCookieExpiry = self::getMethod( 
'getUseFormatCookieExpiry' );
@@ -391,6 +411,9 @@
                );
        }
 
+       /**
+        * @covers MobileContext::getStopMobileRedirectCookieDomain
+        */
        public function testGetStopMobileRedirectCookieDomain() {
                $context = $this->makeContext();
                $this->setMwGlobals( array(
@@ -402,6 +425,9 @@
                $this->assertEquals( 
$context->getStopMobileRedirectCookieDomain(), 'foo.bar.baz' );
        }
 
+       /**
+        * @covers MobileContext::isLocalUrl
+        */
        public function testIsLocalUrl() {
                global $wgServer;
                $context = $this->makeContext();
@@ -411,6 +437,7 @@
 
        /**
         * @dataProvider addAnalyticsLogItemProvider
+        * @covers MobileContext::getAnalyticsLogItems
         */
        public function testAddAnalyticsLogItem( $key, $val ) {
                $context = $this->makeContext();
@@ -431,6 +458,7 @@
 
        /**
         * @dataProvider getXAnalyticsHeaderProvider
+        * @covers MobileContext::getXAnalyticsHeader
         */
        public function testGetXAnalyticsHeader( $existingHeader, $logItems, 
$expectedHeader ) {
                $context = $this->makeContext();
@@ -473,6 +501,7 @@
 
        /**
         * @dataProvider addAnalyticsLogItemFromXAnalyticsProvider
+        * @covers MobileContext::addAnalyticsLogItemFromXanalytics
         */
        public function testAddAnalyticsLogItemFromXAnalytics( $analyticsItem, 
$key, $val ) {
                $context = $this->makeContext();
@@ -494,6 +523,7 @@
 
        /**
         * @dataProvider getMobileHostTokenProvider
+        * @covers MobileContext::getMobileHostToken
         */
        public function testGetMobileHostToken( $domainTemplate, $result ) {
                $context = $this->makeContext();
@@ -510,6 +540,7 @@
 
        /**
         * @dataProvider optInProvider
+        * @covers MobileContext::isBetaGroupMember
         */
        public function testOptIn( array $cookies, $isBeta, $enabledInSettings 
) {
                $this->setMwGlobals( 'wgMFEnableBeta', $enabledInSettings );
@@ -530,6 +561,8 @@
 
        /**
         * @dataProvider provideToggleView
+        * @covers MobileContext::checkToggleView
+        * @covers MobileContext::doToggling
         * @param $page
         * @param $url
         * @param $urlTemplate
diff --git a/tests/phpunit/MobileFormatterTest.php 
b/tests/phpunit/MobileFormatterTest.php
index 5372e37..2913901 100644
--- a/tests/phpunit/MobileFormatterTest.php
+++ b/tests/phpunit/MobileFormatterTest.php
@@ -6,6 +6,7 @@
 class MobileFormatterTest extends MediaWikiTestCase {
        /**
         * @dataProvider getHtmlData
+        * @covers MobileFormatter::filterContent
         *
         * @param $input
         * @param $expected
diff --git a/tests/phpunit/MobileFrontend.hooksTest.php 
b/tests/phpunit/MobileFrontend.hooksTest.php
index 80f4b43..07f956b 100644
--- a/tests/phpunit/MobileFrontend.hooksTest.php
+++ b/tests/phpunit/MobileFrontend.hooksTest.php
@@ -7,7 +7,7 @@
        /**
         * Test headers and alternate/canonical links to be set or not
         *
-        * @dataProvider onBeforePageDisplayDataProvider
+        * @covers MobileFrontendHooks::OnBeforePageDisplay
         */
        public function testOnBeforePageDisplay( $mobileUrlTemplate, 
$mfNoindexPages,
                $mfEnableXAnalyticsLogging, $mfAutoDetectMobileView, 
$mfVaryOnUA, $mfXAnalyticsItems,
diff --git a/tests/phpunit/MobileFrontend.skin.hooksTest.php 
b/tests/phpunit/MobileFrontend.skin.hooksTest.php
index 639d5dd..671765e 100644
--- a/tests/phpunit/MobileFrontend.skin.hooksTest.php
+++ b/tests/phpunit/MobileFrontend.skin.hooksTest.php
@@ -6,6 +6,7 @@
 class SkinMinervaTest extends MediaWikiTestCase {
        /**
         * @dataProvider getGetPluralLicenseInfo
+        * @covers MobileFrontendSkinHooks::getPluralLicenseInfo
         */
        public function testGetPluralLicenseInfo( $isDisabledValue, $license, 
$expectedResult ) {
                $msgObj = $this->getMockBuilder( 'Message' )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73010d4ba024976741f1ea780e1fda55b3e15111
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to