Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/71179
Change subject: Clean-up QueryPrinter tests
......................................................................
Clean-up QueryPrinter tests
Change-Id: I2b4d603c42d7cdff1d25c76ad08ff75b8294a91e
---
M docs/doxygen.group.definitions.php
M includes/Setup.php
M includes/queryprinters/ApiResultPrinter.php
M includes/queryprinters/CsvResultPrinter.php
R includes/queryprinters/ExportPrinter.php
M includes/queryprinters/FeedResultPrinter.php
R includes/queryprinters/FileExportPrinter.php
M includes/queryprinters/JsonResultPrinter.php
R tests/phpunit/QueryPrinterRegistryTestCase.php
A tests/phpunit/QueryPrinterTestCase.php
M tests/phpunit/SemanticMediaWikiTestCase.php
M tests/phpunit/includes/queryprinters/AggregatablePrinterTest.php
A tests/phpunit/includes/queryprinters/ApiResultPrinterTest.php
M tests/phpunit/includes/queryprinters/CsvResultPrinterTest.php
A tests/phpunit/includes/queryprinters/DsvResultPrinterTest.php
A tests/phpunit/includes/queryprinters/FeedResultPrinterTest.php
M tests/phpunit/includes/queryprinters/JsonResultPrinterTest.php
A tests/phpunit/includes/queryprinters/RdfResultPrinterTest.php
M tests/phpunit/includes/queryprinters/ResultPrintersTest.php
M tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
20 files changed, 506 insertions(+), 148 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/79/71179/1
diff --git a/docs/doxygen.group.definitions.php
b/docs/doxygen.group.definitions.php
index 2a40994..1822c35 100644
--- a/docs/doxygen.group.definitions.php
+++ b/docs/doxygen.group.definitions.php
@@ -32,6 +32,13 @@
*/
/**
+ * This group contains members that are related to the QueryPrinter unit tests
+ *
+ * @defgroup QueryPrinterTest QueryPrinterTest
+ * @ingroup Test
+ */
+
+/**
* This group contains members that are related to the Store unit tests
*
* @defgroup StoreTest StoreTest
diff --git a/includes/Setup.php b/includes/Setup.php
index 61e7a0f..405a8ce 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -177,8 +177,9 @@
// Printers
$qpDir = $smwgIP . 'includes/queryprinters/';
- $wgAutoloadClasses['SMWExportPrinter'] = $qpDir .
'SMW_ExportPrinter.php';
- $wgAutoloadClasses['SMWIExportPrinter'] = $qpDir .
'SMW_IExportPrinter.php';
+ $wgAutoloadClasses['SMWExportPrinter'] = $qpDir .
'FileExportPrinter.php';
+ $wgAutoloadClasses['SMW\FileExportPrinter'] = $qpDir .
'FileExportPrinter.php';
+ $wgAutoloadClasses['SMW\ExportPrinter'] = $qpDir .
'ExportPrinter.php';
$wgAutoloadClasses['SMWIResultPrinter'] = $qpDir .
'SMW_IResultPrinter.php';
$wgAutoloadClasses['SMWTableResultPrinter'] = $qpDir .
'TableResultPrinter.php';
$wgAutoloadClasses['SMW\TableResultPrinter'] = $qpDir .
'TableResultPrinter.php'; // 1.9
@@ -374,8 +375,10 @@
// Special pages and closely related helper classes
$testsDir = $smwgIP . 'tests/phpunit/';
+ $wgAutoloadClasses['SMW\Test\ResultPrinterTestCase'] =
$testsDir . 'QueryPrinterRegistryTestCase.php';
+ $wgAutoloadClasses['SMW\Test\QueryPrinterRegistryTestCase'] =
$testsDir . 'QueryPrinterRegistryTestCase.php';
+ $wgAutoloadClasses['SMW\Test\QueryPrinterTestCase'] =
$testsDir . 'QueryPrinterTestCase.php';
$wgAutoloadClasses['SMW\Tests\DataItemTest'] = $testsDir .
'includes/dataitems/DataItemTest.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';
diff --git a/includes/queryprinters/ApiResultPrinter.php
b/includes/queryprinters/ApiResultPrinter.php
index 85e0d0f..3b85754 100644
--- a/includes/queryprinters/ApiResultPrinter.php
+++ b/includes/queryprinters/ApiResultPrinter.php
@@ -25,9 +25,8 @@
* @since 1.9
*
* @file
- * @ingroup QueryPrinter
*
- * @licence GNU GPL v2 or later
+ * @license GNU GPL v2 or later
* @author mwjames
*/
diff --git a/includes/queryprinters/CsvResultPrinter.php
b/includes/queryprinters/CsvResultPrinter.php
index fa3a083..3fa8642 100644
--- a/includes/queryprinters/CsvResultPrinter.php
+++ b/includes/queryprinters/CsvResultPrinter.php
@@ -39,7 +39,7 @@
*
* @ingroup QueryPrinter
*/
-class CsvResultPrinter extends \SMWExportPrinter {
+class CsvResultPrinter extends FileExportPrinter {
/**
* @codeCoverageIgnore
diff --git a/includes/queryprinters/SMW_IExportPrinter.php
b/includes/queryprinters/ExportPrinter.php
similarity index 91%
rename from includes/queryprinters/SMW_IExportPrinter.php
rename to includes/queryprinters/ExportPrinter.php
index 8404fbc..f949e82 100644
--- a/includes/queryprinters/SMW_IExportPrinter.php
+++ b/includes/queryprinters/ExportPrinter.php
@@ -1,5 +1,9 @@
<?php
+namespace SMW;
+
+use SMWQueryResult;
+
/**
* Interface for SMW result printers.
*
@@ -18,15 +22,20 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @file
* @since 1.8
*
- * @ingroup SMW
+ * @file
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-interface SMWIExportPrinter extends SMWIResultPrinter {
+
+/**
+ * Interface for SMW export related result printers
+ *
+ * @ingroup QueryPrinter
+ */
+interface ExportPrinter extends \SMWIResultPrinter {
/**
* Outputs the result as file.
diff --git a/includes/queryprinters/FeedResultPrinter.php
b/includes/queryprinters/FeedResultPrinter.php
index fa5971c..2851138 100644
--- a/includes/queryprinters/FeedResultPrinter.php
+++ b/includes/queryprinters/FeedResultPrinter.php
@@ -25,9 +25,8 @@
* @since 1.8
*
* @file
- * @ingroup QueryPrinter
*
- * @licence GNU GPL v2 or later
+ * @license GNU GPL v2 or later
* @author mwjames
*/
@@ -36,7 +35,7 @@
*
* @ingroup QueryPrinter
*/
-final class FeedResultPrinter extends \SMWExportPrinter {
+final class FeedResultPrinter extends FileExportPrinter {
/**
* Returns human readable label for this printer
diff --git a/includes/queryprinters/SMW_ExportPrinter.php
b/includes/queryprinters/FileExportPrinter.php
similarity index 78%
rename from includes/queryprinters/SMW_ExportPrinter.php
rename to includes/queryprinters/FileExportPrinter.php
index d4f586b..89df341 100644
--- a/includes/queryprinters/SMW_ExportPrinter.php
+++ b/includes/queryprinters/FileExportPrinter.php
@@ -1,5 +1,9 @@
<?php
+namespace SMW;
+
+use SMWQueryResult;
+
/**
* Base for export result printers.
*
@@ -18,18 +22,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
- * @file
* @since 1.8
*
- * @ingroup SMW
+ * @file
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-abstract class SMWExportPrinter extends SMWResultPrinter implements
SMWIExportPrinter {
+
+/**
+ * Base class for file export result printers
+ *
+ * @ingroup QueryPrinter
+ */
+abstract class FileExportPrinter extends ResultPrinter implements
ExportPrinter {
/**
- * @see SMWIResultPrinter::isExportFormat
+ * @see ExportPrinter::isExportFormat
*
* @since 1.8
*
@@ -40,7 +49,7 @@
}
/**
- * @see SMWIExportPrinter::outputAsFile
+ * @see ExportPrinter::outputAsFile
*
* @since 1.8
*
@@ -62,7 +71,7 @@
}
/**
- * @see SMWIExportPrinter::getFileName
+ * @see ExportPrinter::getFileName
*
* @since 1.8
*
@@ -75,3 +84,10 @@
}
}
+
+/**
+ * SMWExportPrinter
+ *
+ * @deprecated since SMW 1.9
+ */
+class_alias( 'SMW\FileExportPrinter', 'SMWExportPrinter' );
diff --git a/includes/queryprinters/JsonResultPrinter.php
b/includes/queryprinters/JsonResultPrinter.php
index 8e18cda..8cc3175 100644
--- a/includes/queryprinters/JsonResultPrinter.php
+++ b/includes/queryprinters/JsonResultPrinter.php
@@ -42,7 +42,7 @@
*
* @ingroup QueryPrinter
*/
-class JsonResultPrinter extends \SMWExportPrinter {
+class JsonResultPrinter extends FileExportPrinter {
/**
* Returns human readable label for this printer
diff --git a/tests/phpunit/ResultPrinterTestCase.php
b/tests/phpunit/QueryPrinterRegistryTestCase.php
similarity index 89%
rename from tests/phpunit/ResultPrinterTestCase.php
rename to tests/phpunit/QueryPrinterRegistryTestCase.php
index c63437c..6d22de9 100644
--- a/tests/phpunit/ResultPrinterTestCase.php
+++ b/tests/phpunit/QueryPrinterRegistryTestCase.php
@@ -23,22 +23,20 @@
* @since 1.8
*
* @file
- * @ingroup Test
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
/**
* Base class for SMW\ResultPrinter tests
*
- * @ingroup Test
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
- * @group ResultPrinters
*/
-abstract class ResultPrinterTestCase extends SemanticMediaWikiTestCase {
+abstract class QueryPrinterRegistryTestCase extends QueryPrinterTestCase {
/**
* Returns the names of the formats supported by the
@@ -83,8 +81,8 @@
/**
* @since 1.8
- *
* @return array
+ *
*/
public function instanceProvider() {
$phpFails = array( $this, 'newInstance' );
@@ -111,3 +109,10 @@
$this->assertInstanceOf( '\SMW\ResultPrinter', $instance );
}
}
+
+/**
+ * SMWResultPrinter
+ *
+ * @deprecated since SMW 1.9
+ */
+class_alias( 'SMW\Test\QueryPrinterRegistryTestCase',
'SMW\Test\ResultPrinterTestCase' );
diff --git a/tests/phpunit/QueryPrinterTestCase.php
b/tests/phpunit/QueryPrinterTestCase.php
new file mode 100644
index 0000000..1c86639
--- /dev/null
+++ b/tests/phpunit/QueryPrinterTestCase.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\ResultPrinter;
+
+use ReflectionClass;
+
+/**
+ * Class contains methods to access data in connection with the QueryPrinter
+ *
+ * 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.9
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * Class contains methods to access data in connection with the QueryPrinter
+ *
+ * @ingroup Test
+ * @ingroup QueryPrinterTest
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+abstract class QueryPrinterTestCase extends SemanticMediaWikiTestCase {
+
+ /**
+ * Helper method sets result printer parameters
+ *
+ * @param ResultPrinter $instance
+ * @param array $parameters
+ *
+ * @return ResultPrinter
+ */
+ protected function setParameters( ResultPrinter $instance, array
$parameters ) {
+
+ $reflector = new ReflectionClass( $this->getClass() );
+ $params = $reflector->getProperty( 'params' );
+ $params->setAccessible( true );
+ $params->setValue( $instance, $parameters );
+
+ if ( isset( $parameters['searchlabel'] ) ) {
+ $searchlabel = $reflector->getProperty( 'mSearchlabel'
);
+ $searchlabel->setAccessible( true );
+ $searchlabel->setValue( $instance,
$parameters['searchlabel'] );
+ }
+
+ if ( isset( $parameters['headers'] ) ) {
+ $searchlabel = $reflector->getProperty( 'mShowHeaders'
);
+ $searchlabel->setAccessible( true );
+ $searchlabel->setValue( $instance,
$parameters['headers'] );
+ }
+
+ return $instance;
+
+ }
+}
diff --git a/tests/phpunit/SemanticMediaWikiTestCase.php
b/tests/phpunit/SemanticMediaWikiTestCase.php
index be1c2ae..e288ced 100644
--- a/tests/phpunit/SemanticMediaWikiTestCase.php
+++ b/tests/phpunit/SemanticMediaWikiTestCase.php
@@ -33,16 +33,15 @@
* @since 1.9
*
* @file
- * @ingroup SMW
- * @ingroup SMWParser
- * @ingroup Test
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author mwjames
*/
/**
* Class contains general purpose methods
+ *
+ * @ingroup Test
*
* @group SMW
* @group SMWExtension
@@ -134,6 +133,28 @@
}
/**
+ * Utility method taking an array of elements and wrapping
+ * each element in it's own array. Useful for data providers
+ * that only return a single argument.
+ *
+ * @see MediaWikiTestCase::arrayWrap
+ *
+ * @since 1.9
+ *
+ * @param array $elements
+ *
+ * @return array
+ */
+ protected function arrayWrap( array $elements ) {
+ return array_map(
+ function ( $element ) {
+ return array( $element );
+ },
+ $elements
+ );
+ }
+
+ /**
* Asserts that for a given semantic container expected property / value
* pairs are available
*
diff --git a/tests/phpunit/includes/queryprinters/AggregatablePrinterTest.php
b/tests/phpunit/includes/queryprinters/AggregatablePrinterTest.php
index 1ed5dc7..7a18b69 100644
--- a/tests/phpunit/includes/queryprinters/AggregatablePrinterTest.php
+++ b/tests/phpunit/includes/queryprinters/AggregatablePrinterTest.php
@@ -28,23 +28,20 @@
* @since 1.9
*
* @file
- * @ingroup QueryPrinter
- * @ingroup Test
*
- * @licence GNU GPL v2+
+ * @license GNU GPL v2+
* @author mwjames
*/
/**
- * Tests for the AggregatablePrinter class
* @covers \SMW\AggregatablePrinter
*
- * @ingroup Test
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
*/
-class AggregatablePrinterTest extends SemanticMediaWikiTestCase {
+class AggregatablePrinterTest extends QueryPrinterTestCase {
/**
* Returns the name of the class to be tested
diff --git a/tests/phpunit/includes/queryprinters/ApiResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/ApiResultPrinterTest.php
new file mode 100644
index 0000000..5095be5
--- /dev/null
+++ b/tests/phpunit/includes/queryprinters/ApiResultPrinterTest.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\ApiResultPrinter;
+
+/**
+ * Tests for the ApiResultPrinter class
+ *
+ * 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.9
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * @covers \SMW\ApiResultPrinter
+ *
+ * @ingroup QueryPrinterTest
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+class ApiResultPrinterTest extends QueryPrinterTestCase {
+
+ /**
+ * Returns the name of the class to be tested
+ *
+ * @return string|false
+ */
+ public function getClass() {
+ return '\SMW\ApiResultPrinter';
+ }
+
+ /**
+ * Helper method that returns a ApiResultPrinter object
+ *
+ * @return ApiResultPrinter
+ */
+ private function getInstance( $parameters = array() ) {
+ return $this->setParameters( $this->getMockForAbstractClass(
$this->getClass(), array( 'api' ) ), $parameters );
+ }
+
+ /**
+ * @test ApiResultPrinter::__construct
+ *
+ * @since 1.9
+ */
+ public function testConstructor() {
+ $this->assertInstanceOf( $this->getClass(),
$this->getInstance() );
+ }
+
+}
diff --git a/tests/phpunit/includes/queryprinters/CsvResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/CsvResultPrinterTest.php
index c9ab19b..13ba5ab 100644
--- a/tests/phpunit/includes/queryprinters/CsvResultPrinterTest.php
+++ b/tests/phpunit/includes/queryprinters/CsvResultPrinterTest.php
@@ -36,12 +36,12 @@
/**
* @covers \SMW\CsvResultPrinter
*
- * @ingroup Test
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
*/
-class CsvResultPrinterTest extends SemanticMediaWikiTestCase {
+class CsvResultPrinterTest extends QueryPrinterTestCase {
/**
* Returns the name of the class to be tested
@@ -66,37 +66,6 @@
->getMock();
return $queryResult;
- }
-
- /**
- * Helper method sets result printer parameters
- *
- * @param ResultPrinter $instance
- * @param array $parameters
- *
- * @return ResultPrinter
- */
- private function setParameters( ResultPrinter $instance, array
$parameters ) {
-
- $reflector = new ReflectionClass( $this->getClass() );
- $params = $reflector->getProperty( 'params' );
- $params->setAccessible( true );
- $params->setValue( $instance, $parameters );
-
- if ( isset( $parameters['searchlabel'] ) ) {
- $searchlabel = $reflector->getProperty( 'mSearchlabel'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['searchlabel'] );
- }
-
- if ( isset( $parameters['headers'] ) ) {
- $searchlabel = $reflector->getProperty( 'mShowHeaders'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['headers'] );
- }
-
- return $instance;
-
}
/**
diff --git a/tests/phpunit/includes/queryprinters/DsvResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/DsvResultPrinterTest.php
new file mode 100644
index 0000000..ef7c198
--- /dev/null
+++ b/tests/phpunit/includes/queryprinters/DsvResultPrinterTest.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace SMW\Test;
+
+use SMWDSVResultPrinter;
+use SMW\ResultPrinter;
+
+use ReflectionClass;
+
+/**
+ * Tests for the SMWDSVResultPrinter class
+ *
+ * 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.9
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * @covers \SMWDSVResultPrinter
+ *
+ * @ingroup QueryPrinterTest
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+class DsvResultPrinterTest extends QueryPrinterTestCase {
+
+ /**
+ * Returns the name of the class to be tested
+ *
+ * @return string|false
+ */
+ public function getClass() {
+ return '\SMWDSVResultPrinter';
+ }
+
+ /**
+ * Helper method that returns a SMWDSVResultPrinter object
+ *
+ * @return SMWDSVResultPrinter
+ */
+ private function getInstance( $parameters = array() ) {
+ return $this->setParameters( new SMWDSVResultPrinter( 'dsv' ),
$parameters );
+ }
+
+ /**
+ * @test SMWDSVResultPrinter::__construct
+ *
+ * @since 1.9
+ */
+ public function testConstructor() {
+ $this->assertInstanceOf( $this->getClass(),
$this->getInstance() );
+ }
+
+}
diff --git a/tests/phpunit/includes/queryprinters/FeedResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/FeedResultPrinterTest.php
new file mode 100644
index 0000000..8c401a7
--- /dev/null
+++ b/tests/phpunit/includes/queryprinters/FeedResultPrinterTest.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace SMW\Test;
+
+use SMW\FeedResultPrinter;
+use SMW\ResultPrinter;
+
+use ReflectionClass;
+
+/**
+ * Tests for the FeedResultPrinter class
+ *
+ * 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.9
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * @covers \SMW\FeedResultPrinter
+ *
+ * @ingroup QueryPrinterTest
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+class FeedResultPrinterTest extends QueryPrinterTestCase {
+
+ /**
+ * Returns the name of the class to be tested
+ *
+ * @return string|false
+ */
+ public function getClass() {
+ return '\SMW\FeedResultPrinter';
+ }
+
+ /**
+ * Helper method that returns a FeedResultPrinter object
+ *
+ * @return FeedResultPrinter
+ */
+ private function getInstance( $parameters = array() ) {
+ return $this->setParameters( new FeedResultPrinter( 'feed' ),
$parameters );
+ }
+
+ /**
+ * @test FeedResultPrinter::__construct
+ *
+ * @since 1.9
+ */
+ public function testConstructor() {
+ $this->assertInstanceOf( $this->getClass(),
$this->getInstance() );
+ }
+
+}
diff --git a/tests/phpunit/includes/queryprinters/JsonResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/JsonResultPrinterTest.php
index d04c282..b6e215d 100644
--- a/tests/phpunit/includes/queryprinters/JsonResultPrinterTest.php
+++ b/tests/phpunit/includes/queryprinters/JsonResultPrinterTest.php
@@ -36,12 +36,12 @@
/**
* @covers \SMW\JsonResultPrinter
*
- * @ingroup Test
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
*/
-class JsonResultPrinterTest extends SemanticMediaWikiTestCase {
+class JsonResultPrinterTest extends QueryPrinterTestCase {
/**
* Returns the name of the class to be tested
@@ -74,37 +74,6 @@
->will( $this->returnValue( $result ) );
return $queryResult;
- }
-
- /**
- * Helper method sets result printer parameters
- *
- * @param ResultPrinter $instance
- * @param array $parameters
- *
- * @return ResultPrinter
- */
- private function setParameters( ResultPrinter $instance, array
$parameters ) {
-
- $reflector = new ReflectionClass( $this->getClass() );
- $params = $reflector->getProperty( 'params' );
- $params->setAccessible( true );
- $params->setValue( $instance, $parameters );
-
- if ( isset( $parameters['searchlabel'] ) ) {
- $searchlabel = $reflector->getProperty( 'mSearchlabel'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['searchlabel'] );
- }
-
- if ( isset( $parameters['headers'] ) ) {
- $searchlabel = $reflector->getProperty( 'mShowHeaders'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['headers'] );
- }
-
- return $instance;
-
}
/**
diff --git a/tests/phpunit/includes/queryprinters/RdfResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/RdfResultPrinterTest.php
new file mode 100644
index 0000000..3a41c55
--- /dev/null
+++ b/tests/phpunit/includes/queryprinters/RdfResultPrinterTest.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace SMW\Test;
+
+use SMWRDFResultPrinter;
+use SMW\ResultPrinter;
+
+use ReflectionClass;
+
+/**
+ * Tests for the SMWRDFResultPrinter class
+ *
+ * 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.9
+ *
+ * @file
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * @covers \SMWRDFResultPrinter
+ *
+ * @ingroup QueryPrinterTest
+ *
+ * @group SMW
+ * @group SMWExtension
+ */
+class RdfResultPrinterTest extends QueryPrinterTestCase {
+
+ /**
+ * Returns the name of the class to be tested
+ *
+ * @return string|false
+ */
+ public function getClass() {
+ return '\SMWRDFResultPrinter';
+ }
+
+ /**
+ * Helper method that returns a SMWRDFResultPrinter object
+ *
+ * @return SMWRDFResultPrinter
+ */
+ private function getInstance( $parameters = array() ) {
+ return $this->setParameters( new SMWRDFResultPrinter( 'rdf' ),
$parameters );
+ }
+
+ /**
+ * @test SMWRDFResultPrinter::__construct
+ *
+ * @since 1.9
+ */
+ public function testConstructor() {
+ $this->assertInstanceOf( $this->getClass(),
$this->getInstance() );
+ }
+
+}
diff --git a/tests/phpunit/includes/queryprinters/ResultPrintersTest.php
b/tests/phpunit/includes/queryprinters/ResultPrintersTest.php
index 60d5bf7..a4fd98f 100644
--- a/tests/phpunit/includes/queryprinters/ResultPrintersTest.php
+++ b/tests/phpunit/includes/queryprinters/ResultPrintersTest.php
@@ -1,24 +1,54 @@
<?php
-namespace SMW\Tests;
+namespace SMW\Test;
+
+use SMW\ResultPrinter;
+use SMWQueryProcessor;
/**
- * Does some basic tests for the SMW\ResultPrinter deriving classes.
+ * Does some basic tests for the SMW\ResultPrinter deriving classes
+ *
+ * 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.9
*
* @file
- * @since 1.8
*
- * @ingroup SMW
- * @ingroup Test
+ * @license GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+
+/**
+ * @covers \SMW\ResultPrinter
+ *
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
- * @group ResultPrinters
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < [email protected] >
*/
-class ResultPrintersTest extends \MediaWikiTestCase {
+class ResultPrintersTest extends QueryPrinterTestCase {
+
+ /**
+ * Returns the name of the class to be tested
+ *
+ * @return string|false
+ */
+ public function getClass() {
+ return false;
+ }
public function constructorProvider() {
global $smwgResultFormats;
@@ -62,8 +92,8 @@
*
* @param \SMWResultPrinter $printer
*/
- public function testGetParamDefinitions( \SMWResultPrinter $printer ) {
- $params = $printer->getParamDefinitions(
\SMWQueryProcessor::getParameters() );
+ public function testGetParamDefinitions( ResultPrinter $printer ) {
+ $params = $printer->getParamDefinitions(
SMWQueryProcessor::getParameters() );
$params = \ParamDefinition::getCleanDefinitions( $params );
diff --git a/tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
b/tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
index 0c769c3..c16bd67 100644
--- a/tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
+++ b/tests/phpunit/includes/queryprinters/TableResultPrinterTest.php
@@ -37,12 +37,12 @@
/**
* @covers \SMW\TableResultPrinter
*
- * @ingroup Test
+ * @ingroup QueryPrinterTest
*
* @group SMW
* @group SMWExtension
*/
-class TableResultPrinterTest extends SemanticMediaWikiTestCase {
+class TableResultPrinterTest extends QueryPrinterTestCase {
/**
* Returns the name of the class to be tested
@@ -178,37 +178,6 @@
->will( $this->onConsecutiveCalls( $resultArray , false
) );
return $queryResult;
- }
-
- /**
- * Helper method sets result printer parameters
- *
- * @param ResultPrinter $instance
- * @param array $parameters
- *
- * @return ResultPrinter
- */
- private function setParameters( ResultPrinter $instance, array
$parameters ) {
-
- $reflector = new ReflectionClass( $this->getClass() );
- $params = $reflector->getProperty( 'params' );
- $params->setAccessible( true );
- $params->setValue( $instance, $parameters );
-
- if ( isset( $parameters['searchlabel'] ) ) {
- $searchlabel = $reflector->getProperty( 'mSearchlabel'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['searchlabel'] );
- }
-
- if ( isset( $parameters['headers'] ) ) {
- $searchlabel = $reflector->getProperty( 'mShowHeaders'
);
- $searchlabel->setAccessible( true );
- $searchlabel->setValue( $instance,
$parameters['headers'] );
- }
-
- return $instance;
-
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/71179
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b4d603c42d7cdff1d25c76ad08ff75b8294a91e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits