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

Change subject: Improve code coverage, add exception testing and 
codeCoverageIgnore
......................................................................


Improve code coverage, add exception testing and codeCoverageIgnore

* MockSuperUser add @codeCoverageIgnore
* Setup add @codeCoverageIgnore
* Move ResultPrinterTest to ResultPrinterTestCase
* FormatFactory add exception tests to cover 100%
* Add doxygen welcome page (I was just lazy to make another commit)

Change-Id: Id59ee61a48d7657402b2d3e862e0a34d27086ca7
---
A docs/doxygen.first.page.php
M docs/doxygen.group.definitions.php
M includes/Setup.php
M tests/phpunit/MockSuperUser.php
A tests/phpunit/ResultPrinterTestCase.php
M tests/phpunit/SemanticMediaWikiTestCase.php
M tests/phpunit/includes/FormatFactoryTest.php
D tests/phpunit/includes/printers/ResultPrinterTest.php
8 files changed, 251 insertions(+), 118 deletions(-)

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



diff --git a/docs/doxygen.first.page.php b/docs/doxygen.first.page.php
new file mode 100644
index 0000000..140e93f
--- /dev/null
+++ b/docs/doxygen.first.page.php
@@ -0,0 +1,21 @@
+<?php
+
+die("Not a valid entry point\n");
+
+/**
+ * This file does not hold any code. It is used mainly during the doxygen
+ * auto-documentation process
+ *
+ * @file
+ */
+
+/**
+ * @mainpage Introduction
+ *
+ * Welcome to the auto-generated Semantic MediaWiki code documentation
+ *
+ * For information about how to install or configure Semantic MediaWiki,
+ * please visit the main site:
+ *
+ * https://www.semantic-mediawiki.org/
+ */
diff --git a/docs/doxygen.group.definitions.php 
b/docs/doxygen.group.definitions.php
index a5d9e96..6f3524d 100644
--- a/docs/doxygen.group.definitions.php
+++ b/docs/doxygen.group.definitions.php
@@ -10,35 +10,36 @@
  */
 
 /**
- * This group contains members that are relate to message, error, and 
parameter formatting
+ * This group contains members that are related to message, error, and 
parameter
+ * formatting
  *
  * @defgroup Formatter Formatter
  * @ingroup SMW
  */
 
 /**
- * This group contains members that are relate to parser hooks and functions
+ * This group contains members that are related to parser hooks and functions
  *
  * @defgroup ParserFunction ParserFunction
  * @ingroup SMW
  */
 
 /**
- * This group contains members that are relate to unit tests
+ * This group contains members that are related to unit tests
  *
  * @defgroup Test Test
  * @ingroup SMW
  */
 
 /**
- * This group contains members that are relate to the Semantic MediaWiki Api
+ * This group contains members that are related to the Semantic MediaWiki Api
  *
  * @defgroup Api Api
  * @ingroup SMW
  */
 
 /**
- * This group contains members that are relate to handler classes (including
+ * This group contains members that are related to handler classes (including
  * object handler, hooks handler, instance handler etc.)
  *
  * @defgroup Handler Handler
diff --git a/includes/Setup.php b/includes/Setup.php
index 745c8d9..8b48682 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -23,6 +23,8 @@
  * @param boolean $complete
  *
  * @return true
+ *
+ * @codeCoverageIgnore
  */
 function enableSemantics( $namespace = null, $complete = false ) {
        global $smwgNamespace;
@@ -41,6 +43,8 @@
 
 /**
  * Register all SMW hooks with MediaWiki.
+ *
+ * @codeCoverageIgnore
  */
 function smwfRegisterHooks() {
        global $wgHooks;
@@ -110,6 +114,7 @@
 /**
  * Register all SMW classes with the MediaWiki autoloader.
  *
+ * @codeCoverageIgnore
  */
 function smwfRegisterClasses() {
        global $smwgIP, $wgAutoloadClasses, $wgJobClasses;
@@ -333,7 +338,7 @@
        // Special pages and closely related helper classes
        $testsDir = $smwgIP . 'tests/phpunit/';
        $wgAutoloadClasses['SMW\Tests\DataItemTest']              = $testsDir . 
'includes/dataitems/DataItemTest.php';
-       $wgAutoloadClasses['SMW\Tests\ResultPrinterTest']         = $testsDir . 
'includes/printers/ResultPrinterTest.php';
+       $wgAutoloadClasses['SMW\Test\ResultPrinterTestCase']      = $testsDir . 
'ResultPrinterTestCase.php';
        $wgAutoloadClasses['SMW\Test\SemanticMediaWikiTestCase']  = $testsDir . 
'SemanticMediaWikiTestCase.php';
        $wgAutoloadClasses['SMW\Test\ParserTestCase']             = $testsDir . 
'ParserTestCase.php';
        $wgAutoloadClasses['SMW\Test\ApiTestCase']                = $testsDir . 
'ApiTestCase.php';
@@ -364,6 +369,8 @@
 
 /**
  * Register all SMW special pages with MediaWiki.
+ *
+ * @codeCoverageIgnore
  */
 function smwfRegisterSpecialPages() {
        $specials = array(
@@ -435,6 +442,8 @@
  *
  * The main things this function does are: register all hooks, set up extension
  * credits, and init some globals that are not for configuration settings.
+ *
+ * @codeCoverageIgnore
  */
 function smwfSetupExtension() {
        wfProfileIn( 'smwfSetupExtension (SMW)' );
@@ -453,6 +462,8 @@
 
 /**
  * Init the additional namespaces used by Semantic MediaWiki.
+ *
+ * @codeCoverageIgnore
  */
 function smwfInitNamespaces() {
        global $smwgNamespaceIndex, $wgExtraNamespaces, $wgNamespaceAliases, 
$wgNamespacesWithSubpages, $wgLanguageCode, $smwgContLang;
@@ -502,6 +513,8 @@
  * early on, even before user language is known, to determine labels for
  * additional namespaces. In contrast, messages can be initialised much later
  * when they are actually needed.
+ *
+ * @codeCoverageIgnore
  */
 function smwfInitContentLanguage( $langcode ) {
        global $smwgIP, $smwgContLang;
diff --git a/tests/phpunit/MockSuperUser.php b/tests/phpunit/MockSuperUser.php
index e537df7..6a2a7ab 100644
--- a/tests/phpunit/MockSuperUser.php
+++ b/tests/phpunit/MockSuperUser.php
@@ -25,11 +25,7 @@
  * @since 1.9
  *
  * @file
- * @ingroup SMW
  * @ingroup Test
- *
- * @group SMW
- * @group SMWExtension
  *
  * @licence GNU GPL v2+
  */
@@ -37,6 +33,13 @@
 /**
  * Instantiate a SuperUser in order to be able to do everything.
  * Borrowed from Translate/EducationProgram extension :-)
+ *
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @codeCoverageIgnore
  */
 class MockSuperUser extends User {
        public function getId() {
diff --git a/tests/phpunit/ResultPrinterTestCase.php 
b/tests/phpunit/ResultPrinterTestCase.php
new file mode 100644
index 0000000..c63437c
--- /dev/null
+++ b/tests/phpunit/ResultPrinterTestCase.php
@@ -0,0 +1,113 @@
+<?php
+
+namespace SMW\Test;
+
+/**
+ * Base class for SMW\ResultPrinter tests.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.8
+ *
+ * @file
+ * @ingroup Test
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+
+/**
+ * Base class for SMW\ResultPrinter tests
+ *
+ * @ingroup Test
+ *
+ * @group SMW
+ * @group SMWExtension
+ * @group ResultPrinters
+ */
+abstract class ResultPrinterTestCase extends SemanticMediaWikiTestCase {
+
+       /**
+        * Returns the names of the formats supported by the
+        * \SMW\ResultPrinter being tested.
+        *
+        * @since 1.8
+        *
+        * @return array
+        */
+       public abstract function getFormats();
+
+       /**
+        * @since 1.8
+        *
+        * @return array
+        */
+       public function constructorProvider() {
+               $argumentLists = array();
+
+               foreach ( $this->getFormats() as $format ) {
+                       $argumentLists[] = array( $format, true );
+                       $argumentLists[] = array( $format, false );
+               }
+
+               return $argumentLists;
+       }
+
+       /**
+        * Creates and returns a new instance of the result printer.
+        *
+        * @since 1.8
+        *
+        * @param string $format
+        * @param boolean $isInline
+        *
+        * @return \SMW\ResultPrinter
+        */
+       protected function newInstance( $format, $isInline ) {
+               $class = $this->getClass();
+               return new $class( $format, $isInline );
+       }
+
+       /**
+        * @since 1.8
+        *
+        * @return array
+        */
+       public function instanceProvider() {
+               $phpFails = array( $this, 'newInstance' );
+
+               return array_map(
+                       function( array $args ) use ( $phpFails ) {
+                               return call_user_func_array( $phpFails, $args );
+                       },
+                       $this->constructorProvider()
+               );
+       }
+
+       /**
+        * @dataProvider constructorProvider
+        *
+        * @since 1.8
+        *
+        * @param string $format
+        * @param boolean $isInline
+        */
+       public function testConstructor( $format, $isInline ) {
+               $instance = $this->newInstance( $format, $isInline );
+
+               $this->assertInstanceOf( '\SMW\ResultPrinter', $instance );
+       }
+}
diff --git a/tests/phpunit/SemanticMediaWikiTestCase.php 
b/tests/phpunit/SemanticMediaWikiTestCase.php
index 76d9351..90428cc 100644
--- a/tests/phpunit/SemanticMediaWikiTestCase.php
+++ b/tests/phpunit/SemanticMediaWikiTestCase.php
@@ -55,7 +55,7 @@
         *
         * @return string
         */
-       protected abstract function getClass();
+       public abstract function getClass();
 
        /**
         * Helper method that returns a randomized Title object to avoid results
diff --git a/tests/phpunit/includes/FormatFactoryTest.php 
b/tests/phpunit/includes/FormatFactoryTest.php
index bb0f700..e6b80d1 100644
--- a/tests/phpunit/includes/FormatFactoryTest.php
+++ b/tests/phpunit/includes/FormatFactoryTest.php
@@ -21,18 +21,23 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
- * @file
  * @since 1.9
  *
- * @ingroup SMW
+ * @file
+ * @ingroup Test
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+
+/**
+ * Tests for the SMW\FormatFactory class.
+ *
  * @ingroup Test
  *
  * @group SMW
  * @group SMWExtension
  * @group SMWQueries
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
  */
 class FormatFactoryTest extends \MediaWikiTestCase {
 
@@ -157,4 +162,83 @@
                }
        }
 
+       /**
+        * @test FormatFactory::getPrinter
+        *
+        * @since 1.9
+        */
+       public function testGetPrinterException() {
+               $this->SetExpectedException( 'MWException' );
+
+               $factory = $this->getNewInstance();
+               $factory->getPrinter( 'lula' );
+
+               $this->assertTrue( true );
+       }
+
+       /**
+        * @test FormatFactory::getCanonicalName
+        *
+        * @since 1.9
+        */
+       public function testGetCanonicalNameException() {
+               $this->SetExpectedException( 'MWException' );
+
+               $factory = $this->getNewInstance();
+               $factory->getCanonicalName( 9001 );
+
+               $this->assertTrue( true );
+       }
+
+       /**
+        * @test FormatFactory::registerFormat
+        * @dataProvider getRegisterFormatExceptioDataProvider
+        *
+        * @since 1.9
+        */
+       public function testRegisterFormatException( $formatName, $class ) {
+               $this->SetExpectedException( 'MWException' );
+
+               $factory = $this->getNewInstance();
+               $factory->registerFormat( $formatName, $class );
+               $this->assertTrue( true );
+       }
+
+       /**
+        * @test FormatFactory::registerAliases
+        * @dataProvider getRegisterAliasesExceptioDataProvider
+        *
+        * @since 1.9
+        */
+       public function testRegisterAliasesException( $formatName, array 
$aliases ) {
+               $this->SetExpectedException( 'MWException' );
+
+               $factory = $this->getNewInstance();
+               $factory->registerAliases( $formatName, $aliases );
+               $this->assertTrue( true );
+       }
+
+       /**
+        * Register format exception data provider
+        *
+        * @return array
+        */
+       public function getRegisterFormatExceptioDataProvider() {
+               return array(
+                       array( 1001, 'Foo' ),
+                       array( 'Foo', 9001 ),
+               );
+       }
+
+       /**
+        * Register aliases exception data provider
+        *
+        * @return array
+        */
+       public function getRegisterAliasesExceptioDataProvider() {
+               return array(
+                       array( 1001, array( 'Foo' => 'Bar' ) ),
+                       array( 'Foo', array( 'Foo' => 9001 ) ),
+               );
+       }
 }
\ No newline at end of file
diff --git a/tests/phpunit/includes/printers/ResultPrinterTest.php 
b/tests/phpunit/includes/printers/ResultPrinterTest.php
deleted file mode 100644
index 28571b4..0000000
--- a/tests/phpunit/includes/printers/ResultPrinterTest.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-
-namespace SMW\Tests;
-
-/**
- * Base class for SMW\ResultPrinter tests.
- *
- * @file
- * @since 1.8
- *
- * @ingroup SMW
- * @ingroup Test
- *
- * @group SMW
- * @group SMWExtension
- * @group ResultPrinters
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
- */
-abstract class ResultPrinterTest extends \MediaWikiTestCase {
-
-       /**
-        * Returns the names of the formats supported by the \SMW\ResultPrinter 
being tested.
-        *
-        * @since 1.8
-        *
-        * @return array
-        */
-       public abstract function getFormats();
-
-       /**
-        * Returns the name of the \SMW\ResultPrinter deriving class this test 
tests.
-        *
-        * @since 1.8
-        *
-        * @return string
-        */
-       public abstract function getClass();
-
-       /**
-        * @since 1.8
-        *
-        * @return array
-        */
-       public function constructorProvider() {
-               $argumentLists = array();
-
-               foreach ( $this->getFormats() as $format ) {
-                       $argumentLists[] = array( $format, true );
-                       $argumentLists[] = array( $format, false );
-               }
-
-               return $argumentLists;
-       }
-
-       /**
-        * Creates and returns a new instance of the result printer.
-        *
-        * @since 1.8
-        *
-        * @param string $format
-        * @param boolean $isInline
-        *
-        * @return \SMWResultPrinter
-        */
-       protected function newInstance( $format, $isInline ) {
-               $class = $this->getClass();
-               return new $class( $format, $isInline );
-       }
-
-       /**
-        * @since 1.8
-        *
-        * @return array
-        */
-       public function instanceProvider() {
-               $phpFails = array( $this, 'newInstance' );
-
-               return array_map(
-                       function( array $args ) use ( $phpFails ) {
-                               return call_user_func_array( $phpFails, $args );
-                       },
-                       $this->constructorProvider()
-               );
-       }
-
-       /**
-        * @dataProvider constructorProvider
-        *
-        * @since 1.8
-        *
-        * @param string $format
-        * @param boolean $isInline
-        */
-       public function testConstructor( $format, $isInline ) {
-               $instance = $this->newInstance( $format, $isInline );
-
-               $this->assertInstanceOf( '\SMWResultPrinter', $instance );
-       }
-
-}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id59ee61a48d7657402b2d3e862e0a34d27086ca7
Gerrit-PatchSet: 2
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