jenkins-bot has submitted this change and it was merged.

Change subject: Code coverage fine tunning after forceCoversAnnotation="true"
......................................................................


Code coverage fine tunning after forceCoversAnnotation="true"

Several tests showed missing coverage after forceCoversAnnotation="true"
was turned on because they run implicit instead of explicit which
has been fixed now.

Change-Id: I141ad96a0e800a9f96f922f63096ad35dc2c19a0
---
M includes/RecurringEvents.php
M includes/Settings.php
M tests/phpunit/includes/HighlighterTest.php
M tests/phpunit/includes/RecurringEventsTest.php
M tests/phpunit/includes/SettingsTest.php
M tests/phpunit/includes/formatters/ParserParameterFormatterTest.php
6 files changed, 146 insertions(+), 13 deletions(-)

Approvals:
  Mwjames: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/RecurringEvents.php b/includes/RecurringEvents.php
index c06ebc7..2ad4c5f 100644
--- a/includes/RecurringEvents.php
+++ b/includes/RecurringEvents.php
@@ -4,7 +4,6 @@
 
 use SMWDITime;
 use SMWTimeValue;
-use SMWDataValueFactory;
 
 /**
  * Class returns recurring events
@@ -182,10 +181,10 @@
                                                $this->property = $value;
                                                break;
                                        case 'start':
-                                               $start_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $value );
+                                               $start_date = 
DataValueFactory::newTypeIDValue( '_dat', $value );
                                                break;
                                        case 'end':
-                                               $end_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $value );
+                                               $end_date = 
DataValueFactory::newTypeIDValue( '_dat', $value );
                                                break;
                                        case 'limit':
                                                // Override default limit with 
query specific limit
@@ -244,7 +243,7 @@
                // Exclude dates
                foreach ( $excluded_dates as $date_str ) {
                        $excluded_dates_jd[] = $this->getJulianDay(
-                               SMWDataValueFactory::newTypeIDValue( '_dat', 
$date_str )
+                               DataValueFactory::newTypeIDValue( '_dat', 
$date_str )
                        );
                }
 
@@ -310,7 +309,7 @@
                                }
 
                                $date_str = "$cur_year-$display_month-$cur_day 
$cur_time";
-                               $cur_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $date_str );
+                               $cur_date = DataValueFactory::newTypeIDValue( 
'_dat', $date_str );
                                $all_date_strings = array_merge( 
$all_date_strings, $included_dates);
                                $cur_date_jd = 
$cur_date->getDataItem()->getJD();
                        } elseif ( $unit == 'dayofweekinmonth' ) {
diff --git a/includes/Settings.php b/includes/Settings.php
index af12824..f53dacb 100644
--- a/includes/Settings.php
+++ b/includes/Settings.php
@@ -46,6 +46,9 @@
         */
        protected $settings;
 
+       /** @var Settings */
+       private static $instance = null;
+
        /**
         * @note Use composition over inheritance, if it necessary this class 
can
         * extended to use the ArrayObject without interrupting the interface
@@ -77,7 +80,6 @@
         * @return Settings
         */
        public static function newFromGlobals() {
-               static $instance = null;
 
                $settings = array(
                        'smwgScriptPath' => $GLOBALS['smwgScriptPath'],
@@ -153,11 +155,11 @@
                        'smwgIQRunningNumber' => 
$GLOBALS['smwgIQRunningNumber'],
                );
 
-               if ( $instance === null ) {
-                       $instance = self::newFromArray( $settings ) ;
+               if ( self::$instance === null ) {
+                       self::$instance = self::newFromArray( $settings ) ;
                }
 
-               return $instance;
+               return self::$instance;
        }
 
        /**
@@ -218,4 +220,13 @@
                }
                return $this->settings->offsetGet( $key );
        }
+
+       /**
+        * Reset instance
+        *
+        * @since 1.9
+        */
+       public static function reset() {
+               self::$instance = null;
+       }
 }
diff --git a/tests/phpunit/includes/HighlighterTest.php 
b/tests/phpunit/includes/HighlighterTest.php
index ff93cdc..c4ead66 100644
--- a/tests/phpunit/includes/HighlighterTest.php
+++ b/tests/phpunit/includes/HighlighterTest.php
@@ -25,7 +25,6 @@
  * @since 1.9
  *
  * @file
- * @ingroup SMW
  * @ingroup Test
  *
  * @licence GNU GPL v2+
@@ -61,7 +60,13 @@
                return array(
                        array( '' , Highlighter::TYPE_NOTYPE ),
                        array( 'property', Highlighter::TYPE_PROPERTY ),
-                       array( 'PROPERTY', Highlighter::TYPE_PROPERTY ),
+                       array( 'text', Highlighter::TYPE_TEXT ),
+                       array( 'info', Highlighter::TYPE_INFO ),
+                       array( 'help', Highlighter::TYPE_HELP ),
+                       array( 'service', Highlighter::TYPE_SERVICE ),
+                       array( 'quantity', Highlighter::TYPE_QUANTITY ),
+                       array( 'note', Highlighter::TYPE_NOTE ),
+                       array( 'warning', Highlighter::TYPE_WARNING ),
                        array( 'PrOpErTy', Highlighter::TYPE_PROPERTY ),
                        array( 'バカなテスト', Highlighter::TYPE_NOTYPE ),
                        array( '<span>Something that should not work</span>', 
Highlighter::TYPE_NOTYPE ),
diff --git a/tests/phpunit/includes/RecurringEventsTest.php 
b/tests/phpunit/includes/RecurringEventsTest.php
index d7564e2..05b9683 100644
--- a/tests/phpunit/includes/RecurringEventsTest.php
+++ b/tests/phpunit/includes/RecurringEventsTest.php
@@ -26,7 +26,6 @@
  * @since 1.9
  *
  * @file
- * @ingroup SMW
  * @ingroup Test
  *
  * @licence GNU GPL v2+
@@ -37,7 +36,7 @@
  * Tests for the RecurringEvents class
  * @covers \SMW\RecurringEvents
  *
- * @ingroup SMW
+ * @ingroup Test
  *
  * @group SMW
  * @group SMWExtension
@@ -79,6 +78,60 @@
                                array(
                                        'errors' => 0,
                                        'dates' => array( '1 February 1970', '1 
February 1971 00:00:00', '1 February 1972 00:00:00', '1 February 1973 00:00:00' 
),
+                                       'property' => 'Has birthday',
+                                       'parameters' => array( 'has title' => 
array( 'Birthday' ) )
+                               )
+                       ),
+
+                       // {{#set_recurring_event:property=Has birthday
+                       // |start=01 Feb 1970
+                       // |end=01 Feb 1972
+                       // |has title= Birthday
+                       // |unit=year
+                       // |period=12
+                       // |limit=3
+                       // }}
+                       array(
+                               array(
+                                       'property=Has birthday',
+                                       'start=01 Feb 1970',
+                                       'end=01 Feb 1972',
+                                       'has title=Birthday',
+                                       'unit=month',
+                                       'period=12',
+                                       'limit=3'
+                               ),
+                               array(
+                                       'errors' => 0,
+                                       'dates' => array( '1 February 1970', '1 
February 1971 00:00:00', '1 February 1972 00:00:00' ),
+                                       'property' => 'Has birthday',
+                                       'parameters' => array( 'has title' => 
array( 'Birthday' ) )
+                               )
+                       ),
+
+                       // {{#set_recurring_event:property=Has birthday
+                       // |start=01 Feb 1970
+                       // |end=01 Feb 1972
+                       // |has title= Birthday
+                       // |unit=year
+                       // |week number=2
+                       // |period=12
+                       // |limit=3
+                       // }}
+                       array(
+                               array(
+                                       'property=Has birthday',
+                                       'start=01 Feb 1970',
+                                       'end=01 Feb 1972',
+                                       'has title=Birthday',
+                                       'unit=month',
+                                       'week number=2',
+                                       'period=12',
+                                       'limit=3'
+                               ),
+                               array(
+                                       'errors' => 0,
+                                       'dates' => array( '1 February 1970', 
'14 February 1971 00:00:00' ),
                                        'property' => 'Has birthday',
                                        'parameters' => array( 'has title' => 
array( 'Birthday' ) )
                                )
@@ -418,4 +471,24 @@
                $instance = $this->getInstance( $params );
                $this->assertCount( $expected['count'], $instance->getDates() );
        }
+
+       /**
+        * @test RecurringEvents::getJulianDay
+        *
+        * @since 1.9
+        */
+       public function testGetJulianDay() {
+               $instance = $this->getInstance( array() );
+
+               // SMWDIWikiPage stub object
+               $dataValue = $this->getMockBuilder( 'SMWTimeValue' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $dataValue->expects( $this->any() )
+                       ->method( 'getDataItem' )
+                       ->will( $this->returnValue( null ) );
+
+               $this->assertEquals( null, $instance->getJulianDay( $dataValue 
) );
+       }
 }
diff --git a/tests/phpunit/includes/SettingsTest.php 
b/tests/phpunit/includes/SettingsTest.php
index b04d7e3..ed3ac23 100644
--- a/tests/phpunit/includes/SettingsTest.php
+++ b/tests/phpunit/includes/SettingsTest.php
@@ -175,5 +175,9 @@
 
                // Assert that newFromGlobals is a static instance
                $this->assertTrue( $instance === Settings::newFromGlobals() );
+
+               // Reset instance
+               $instance->reset();
+               $this->assertTrue( $instance !== Settings::newFromGlobals() );
        }
 }
diff --git a/tests/phpunit/includes/formatters/ParserParameterFormatterTest.php 
b/tests/phpunit/includes/formatters/ParserParameterFormatterTest.php
index e4c8781..4b430e5 100644
--- a/tests/phpunit/includes/formatters/ParserParameterFormatterTest.php
+++ b/tests/phpunit/includes/formatters/ParserParameterFormatterTest.php
@@ -91,6 +91,31 @@
        }
 
        /**
+        * @test ParserParameterFormatter::setParameters
+        *
+        * @since 1.9
+        */
+       public function testSetParameters() {
+               $instance = $this->getInstance( array() );
+               $parameters = array( 'Foo' => 'Bar' );
+
+               $instance->setParameters( $parameters );
+               $this->assertEquals( $parameters, $instance->toArray() );
+       }
+
+       /**
+        * @test ParserParameterFormatter::addParameter
+        *
+        * @since 1.9
+        */
+       public function testAddParameter() {
+               $instance = $this->getInstance( array() );
+               $instance->addParameter( 'Foo', 'Bar' );
+
+               $this->assertEquals( array( 'Foo' =>array( 'Bar' ) ), 
$instance->toArray() );
+       }
+
+       /**
         * @test ParserParameterFormatter::__construct (Test instance exception)
         * @dataProvider getParametersDataProvider
         *
@@ -154,6 +179,22 @@
                        ),
 
                        // {{#...:
+                       // |Has test 1=One
+                       // }}
+                       array(
+                               array(
+                                       array( 'Foo' ),
+                                       'Has test 1=One',
+                               ),
+                               array(
+                                       'Has test 1' => array( 'One' )
+                               ),
+                               array(
+                                       'msg' => 'Failed to recognize that only 
strings can be processed'
+                               )
+                       ),
+
+                       // {{#...:
                        // |Has test 2=Two
                        // |Has test 2=Three;Four|+sep=;
                        // }}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I141ad96a0e800a9f96f922f63096ad35dc2c19a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to