Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/57692
Change subject: Made tests runnable as standalone library
......................................................................
Made tests runnable as standalone library
Change-Id: I95dcd08d71d0b795e006b68c5b8a504f6508f363
---
M Ask.mw.php
M Ask.standalone.php
A Tests/AskTestClasses.php
R Tests/Phpunit/AskTestCase.php
R Tests/Phpunit/Language/Description/AnyValueTest.php
R Tests/Phpunit/Language/Description/ConjunctionTest.php
R Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
R Tests/Phpunit/Language/Description/DescriptionTest.php
R Tests/Phpunit/Language/Description/DisjunctionTest.php
R Tests/Phpunit/Language/Description/SomePropertyTest.php
R Tests/Phpunit/Language/Description/ValueDescriptionTest.php
R Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
R Tests/Phpunit/Language/Option/QueryOptionsTest.php
R Tests/Phpunit/Language/Option/SortExpressionTest.php
R Tests/Phpunit/Language/Option/SortOptionsTest.php
R Tests/Phpunit/Language/QueryTest.php
R Tests/Phpunit/Language/Selection/PropertySelectionTest.php
R Tests/Phpunit/Language/Selection/SelectionRequestTest.php
R Tests/Phpunit/Language/Selection/SubjectSelectionTest.php
A Tests/Phpunit/phpunit.php
20 files changed, 154 insertions(+), 75 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Ask
refs/changes/92/57692/1
diff --git a/Ask.mw.php b/Ask.mw.php
index 4d39924..dd85177 100644
--- a/Ask.mw.php
+++ b/Ask.mw.php
@@ -43,56 +43,56 @@
$wgAutoloadClasses[$class] = __DIR__ . '/' . $file;
}
-if ( defined( 'MW_PHPUNIT_TEST' ) ) {
- $wgAutoloadClasses['Ask\Tests\AskTestCase']
- = __DIR__ . '/tests/phpunit/AskTestCase.php';
-
- $wgAutoloadClasses['Ask\Tests\Language\Option\SortExpressionTest']
- = __DIR__ .
'/tests/phpunit/Language/Option/SortExpressionTest.php';
-
-
$wgAutoloadClasses['Ask\Tests\Language\Description\DescriptionCollectionTest']
- = __DIR__ .
'/tests/phpunit/Language/Description/DescriptionCollectionTest.php';
-
- $wgAutoloadClasses['Ask\Tests\Language\Description\DescriptionTest']
- = __DIR__ .
'/tests/phpunit/Language/Description/DescriptionTest.php';
-
- $wgAutoloadClasses['Ask\Tests\Language\Selection\SelectionRequestTest']
- = __DIR__ .
'/tests/phpunit/Language/Selection/SelectionRequestTest.php';
-}
-
-/**
- * Hook to add PHPUnit test cases.
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
- *
- * @since 0.1
- *
- * @param array $files
- *
- * @return boolean
- */
-$wgHooks['UnitTestsList'][] = function( array &$files ) {
- // @codeCoverageIgnoreStart
- $testFiles = array(
- 'Language/Description/AnyValue',
- 'Language/Description/Conjunction',
- 'Language/Description/SomeProperty',
- 'Language/Description/Disjunction',
- 'Language/Description/ValueDescription',
-
- 'Language/Option/PropertyValueSortExpression',
- 'Language/Option/QueryOptions',
- 'Language/Option/SortOptions',
-
- 'Language/Selection/PropertySelection',
- 'Language/Selection/SubjectSelection',
-
- 'Language/Query',
- );
-
- foreach ( $testFiles as $file ) {
- $files[] = __DIR__ . '/tests/phpunit/' . $file . 'Test.php';
- }
-
- return true;
- // @codeCoverageIgnoreEnd
-};
+//if ( defined( 'MW_PHPUNIT_TEST' ) ) {
+// $wgAutoloadClasses['Ask\Tests\AskTestCase']
+// = __DIR__ . '/tests/phpunit/AskTestCase.php';
+//
+// $wgAutoloadClasses['Ask\Tests\Language\Option\SortExpressionTest']
+// = __DIR__ .
'/tests/phpunit/Language/Option/SortExpressionTest.php';
+//
+//
$wgAutoloadClasses['Ask\Tests\Language\Description\DescriptionCollectionTest']
+// = __DIR__ .
'/tests/phpunit/Language/Description/DescriptionCollectionTest.php';
+//
+// $wgAutoloadClasses['Ask\Tests\Language\Description\DescriptionTest']
+// = __DIR__ .
'/tests/phpunit/Language/Description/DescriptionTest.php';
+//
+// $wgAutoloadClasses['Ask\Tests\Language\Selection\SelectionRequestTest']
+// = __DIR__ .
'/tests/phpunit/Language/Selection/SelectionRequestTest.php';
+//}
+//
+///**
+// * Hook to add PHPUnit test cases.
+// * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
+// *
+// * @since 0.1
+// *
+// * @param array $files
+// *
+// * @return boolean
+// */
+//$wgHooks['UnitTestsList'][] = function( array &$files ) {
+// // @codeCoverageIgnoreStart
+// $testFiles = array(
+// 'Language/Description/AnyValue',
+// 'Language/Description/Conjunction',
+// 'Language/Description/SomeProperty',
+// 'Language/Description/Disjunction',
+// 'Language/Description/ValueDescription',
+//
+// 'Language/Option/PropertyValueSortExpression',
+// 'Language/Option/QueryOptions',
+// 'Language/Option/SortOptions',
+//
+// 'Language/Selection/PropertySelection',
+// 'Language/Selection/SubjectSelection',
+//
+// 'Language/Query',
+// );
+//
+// foreach ( $testFiles as $file ) {
+// $files[] = __DIR__ . '/tests/phpunit/' . $file . 'Test.php';
+// }
+//
+// return true;
+// // @codeCoverageIgnoreEnd
+//};
diff --git a/Ask.standalone.php b/Ask.standalone.php
index 978cc4d..f291fe6 100644
--- a/Ask.standalone.php
+++ b/Ask.standalone.php
@@ -19,6 +19,11 @@
die( 'Not an entry point for MediaWiki. Use Ask.php' );
}
+if ( !defined( 'DataValues_VERSION') ) {
+ define( 'DATAVALUES', true );
+ @require_once( __DIR__ . '/../DataValues/DataValues/DataValues.php' );
+}
+
spl_autoload_register( function ( $className ) {
static $classes = false;
diff --git a/Tests/AskTestClasses.php b/Tests/AskTestClasses.php
new file mode 100644
index 0000000..fb52243
--- /dev/null
+++ b/Tests/AskTestClasses.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Test class registration file for the Ask library.
+ *
+ * @since 0.1
+ *
+ * @file
+ * @ingroup Ask
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+return call_user_func( function() {
+
+ // PSR-0 compliant :)
+
+ $classes = array(
+ 'Ask\Tests\Phpunit\AskTestCase',
+
+ 'Ask\Tests\Phpunit\Language\Description\DescriptionTest',
+
'Ask\Tests\Phpunit\Language\Description\DescriptionCollectionTest',
+
+ 'Ask\Tests\Phpunit\Language\Option\SortExpressionTest',
+
+ 'Ask\Tests\Phpunit\Language\Selection\SelectionRequestTest',
+ );
+
+ $paths = array();
+
+ foreach ( $classes as $class ) {
+ $path = str_replace( '\\', '/', $class ) . '.php';
+
+ $paths[$class] = $path;
+ }
+
+ return $paths;
+
+} );
diff --git a/tests/phpunit/AskTestCase.php b/Tests/Phpunit/AskTestCase.php
similarity index 98%
rename from tests/phpunit/AskTestCase.php
rename to Tests/Phpunit/AskTestCase.php
index 143a408..aadf2e8 100644
--- a/tests/phpunit/AskTestCase.php
+++ b/Tests/Phpunit/AskTestCase.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests;
+namespace Ask\Tests\Phpunit;
/**
* Base class for unit tests in the Ask library.
diff --git a/tests/phpunit/Language/Description/AnyValueTest.php
b/Tests/Phpunit/Language/Description/AnyValueTest.php
similarity index 95%
rename from tests/phpunit/Language/Description/AnyValueTest.php
rename to Tests/Phpunit/Language/Description/AnyValueTest.php
index c36b6b2..f15d045 100644
--- a/tests/phpunit/Language/Description/AnyValueTest.php
+++ b/Tests/Phpunit/Language/Description/AnyValueTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\AnyValue;
/**
diff --git a/tests/phpunit/Language/Description/ConjunctionTest.php
b/Tests/Phpunit/Language/Description/ConjunctionTest.php
similarity index 97%
rename from tests/phpunit/Language/Description/ConjunctionTest.php
rename to Tests/Phpunit/Language/Description/ConjunctionTest.php
index 0b245e9..b008698 100644
--- a/tests/phpunit/Language/Description/ConjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/ConjunctionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\Conjunction;
use Ask\Language\Description\Disjunction;
diff --git a/tests/phpunit/Language/Description/DescriptionCollectionTest.php
b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
similarity index 98%
rename from tests/phpunit/Language/Description/DescriptionCollectionTest.php
rename to Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
index c1983f2..3294eca 100644
--- a/tests/phpunit/Language/Description/DescriptionCollectionTest.php
+++ b/Tests/Phpunit/Language/Description/DescriptionCollectionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\Description;
use Ask\Language\Description\DescriptionCollection;
diff --git a/tests/phpunit/Language/Description/DescriptionTest.php
b/Tests/Phpunit/Language/Description/DescriptionTest.php
similarity index 96%
rename from tests/phpunit/Language/Description/DescriptionTest.php
rename to Tests/Phpunit/Language/Description/DescriptionTest.php
index 5848180..263652e 100644
--- a/tests/phpunit/Language/Description/DescriptionTest.php
+++ b/Tests/Phpunit/Language/Description/DescriptionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\Description;
/**
@@ -29,7 +29,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-abstract class DescriptionTest extends \Ask\Tests\AskTestCase {
+abstract class DescriptionTest extends \Ask\Tests\Phpunit\AskTestCase {
/**
* @since 0.1
diff --git a/tests/phpunit/Language/Description/DisjunctionTest.php
b/Tests/Phpunit/Language/Description/DisjunctionTest.php
similarity index 97%
rename from tests/phpunit/Language/Description/DisjunctionTest.php
rename to Tests/Phpunit/Language/Description/DisjunctionTest.php
index 06894a3..32223d7 100644
--- a/tests/phpunit/Language/Description/DisjunctionTest.php
+++ b/Tests/Phpunit/Language/Description/DisjunctionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\Disjunction;
use Ask\Language\Description\Description;
diff --git a/tests/phpunit/Language/Description/SomePropertyTest.php
b/Tests/Phpunit/Language/Description/SomePropertyTest.php
similarity index 98%
rename from tests/phpunit/Language/Description/SomePropertyTest.php
rename to Tests/Phpunit/Language/Description/SomePropertyTest.php
index 141da69..50694b6 100644
--- a/tests/phpunit/Language/Description/SomePropertyTest.php
+++ b/Tests/Phpunit/Language/Description/SomePropertyTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\SomeProperty;
use DataValues\PropertyValue;
diff --git a/tests/phpunit/Language/Description/ValueDescriptionTest.php
b/Tests/Phpunit/Language/Description/ValueDescriptionTest.php
similarity index 97%
rename from tests/phpunit/Language/Description/ValueDescriptionTest.php
rename to Tests/Phpunit/Language/Description/ValueDescriptionTest.php
index 3a40758..c8b2c37 100644
--- a/tests/phpunit/Language/Description/ValueDescriptionTest.php
+++ b/Tests/Phpunit/Language/Description/ValueDescriptionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Description;
+namespace Ask\Tests\Phpunit\Language\Description;
use Ask\Language\Description\ValueDescription;
/**
diff --git a/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
b/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
similarity index 97%
rename from tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
rename to Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
index e9dd157..4605991 100644
--- a/tests/phpunit/Language/Option/PropertyValueSortExpressionTest.php
+++ b/Tests/Phpunit/Language/Option/PropertyValueSortExpressionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Option;
+namespace Ask\Tests\Phpunit\Language\Option;
use Ask\Language\Option\SortExpression;
diff --git a/tests/phpunit/Language/Option/QueryOptionsTest.php
b/Tests/Phpunit/Language/Option/QueryOptionsTest.php
similarity index 94%
rename from tests/phpunit/Language/Option/QueryOptionsTest.php
rename to Tests/Phpunit/Language/Option/QueryOptionsTest.php
index 1f4229a..908b2d2 100644
--- a/tests/phpunit/Language/Option/QueryOptionsTest.php
+++ b/Tests/Phpunit/Language/Option/QueryOptionsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Option;
+namespace Ask\Tests\Phpunit\Language\Option;
use Ask\Language\Option\QueryOptions;
@@ -33,7 +33,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-class QueryOptionsTest extends \Ask\Tests\AskTestCase {
+class QueryOptionsTest extends \Ask\Tests\Phpunit\AskTestCase {
/**
* @since 0.1
diff --git a/tests/phpunit/Language/Option/SortExpressionTest.php
b/Tests/Phpunit/Language/Option/SortExpressionTest.php
similarity index 94%
rename from tests/phpunit/Language/Option/SortExpressionTest.php
rename to Tests/Phpunit/Language/Option/SortExpressionTest.php
index 66a243c..b89689c 100644
--- a/tests/phpunit/Language/Option/SortExpressionTest.php
+++ b/Tests/Phpunit/Language/Option/SortExpressionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Option;
+namespace Ask\Tests\Phpunit\Language\Option;
use Ask\Language\Option\SortExpression;
@@ -30,7 +30,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-abstract class SortExpressionTest extends \Ask\Tests\AskTestCase {
+abstract class SortExpressionTest extends \Ask\Tests\Phpunit\AskTestCase {
/**
* @since 0.1
diff --git a/tests/phpunit/Language/Option/SortOptionsTest.php
b/Tests/Phpunit/Language/Option/SortOptionsTest.php
similarity index 94%
rename from tests/phpunit/Language/Option/SortOptionsTest.php
rename to Tests/Phpunit/Language/Option/SortOptionsTest.php
index 963d4a5..bf6214d 100644
--- a/tests/phpunit/Language/Option/SortOptionsTest.php
+++ b/Tests/Phpunit/Language/Option/SortOptionsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Option;
+namespace Ask\Tests\Phpunit\Language\Option;
use Ask\Language\Option\SortOptions;
@@ -33,7 +33,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-class SortOptionsTest extends \Ask\Tests\AskTestCase {
+class SortOptionsTest extends \Ask\Tests\Phpunit\AskTestCase {
/**
* @since 0.1
diff --git a/tests/phpunit/Language/QueryTest.php
b/Tests/Phpunit/Language/QueryTest.php
similarity index 96%
rename from tests/phpunit/Language/QueryTest.php
rename to Tests/Phpunit/Language/QueryTest.php
index c606b14..62ee67a 100644
--- a/tests/phpunit/Language/QueryTest.php
+++ b/Tests/Phpunit/Language/QueryTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language;
+namespace Ask\Tests\Phpunit\Language;
use Ask\Language\Query;
use Ask\Language\Option\QueryOptions;
@@ -32,7 +32,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-class QueryTest extends \Ask\Tests\AskTestCase {
+class QueryTest extends \Ask\Tests\Phpunit\AskTestCase {
public function descriptionProvider() {
$descriptions = array();
diff --git a/tests/phpunit/Language/Selection/PropertySelectionTest.php
b/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
similarity index 96%
rename from tests/phpunit/Language/Selection/PropertySelectionTest.php
rename to Tests/Phpunit/Language/Selection/PropertySelectionTest.php
index 724713e..103d01e 100644
--- a/tests/phpunit/Language/Selection/PropertySelectionTest.php
+++ b/Tests/Phpunit/Language/Selection/PropertySelectionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Selection;
+namespace Ask\Tests\Phpunit\Language\Selection;
use Ask\Language\Selection\PropertySelection;
/**
diff --git a/tests/phpunit/Language/Selection/SelectionRequestTest.php
b/Tests/Phpunit/Language/Selection/SelectionRequestTest.php
similarity index 95%
rename from tests/phpunit/Language/Selection/SelectionRequestTest.php
rename to Tests/Phpunit/Language/Selection/SelectionRequestTest.php
index a66fa26..a1ccc23 100644
--- a/tests/phpunit/Language/Selection/SelectionRequestTest.php
+++ b/Tests/Phpunit/Language/Selection/SelectionRequestTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Selection;
+namespace Ask\Tests\Phpunit\Language\Selection;
use Ask\Language\Selection\SelectionRequest;
/**
@@ -29,7 +29,7 @@
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
-abstract class SelectionRequestTest extends \Ask\Tests\AskTestCase {
+abstract class SelectionRequestTest extends \Ask\Tests\Phpunit\AskTestCase {
/**
* @since 0.1
diff --git a/tests/phpunit/Language/Selection/SubjectSelectionTest.php
b/Tests/Phpunit/Language/Selection/SubjectSelectionTest.php
similarity index 96%
rename from tests/phpunit/Language/Selection/SubjectSelectionTest.php
rename to Tests/Phpunit/Language/Selection/SubjectSelectionTest.php
index c4bb9a2..b860270 100644
--- a/tests/phpunit/Language/Selection/SubjectSelectionTest.php
+++ b/Tests/Phpunit/Language/Selection/SubjectSelectionTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Ask\Tests\Language\Selection;
+namespace Ask\Tests\Phpunit\Language\Selection;
use Ask\Language\Selection\SubjectSelection;
/**
diff --git a/Tests/Phpunit/phpunit.php b/Tests/Phpunit/phpunit.php
new file mode 100755
index 0000000..9737b25
--- /dev/null
+++ b/Tests/Phpunit/phpunit.php
@@ -0,0 +1,35 @@
+#!/usr/bin/env php
+<?php
+
+// Start up MediaWiki in command-line mode
+//require_once( dirname( dirname( __DIR__ ) ) . "/maintenance/Maintenance.php"
);
+
+require_once( 'PHPUnit/Runner/Version.php' );
+
+if ( PHPUnit_Runner_Version::id() !== '@package_version@'
+ && version_compare( PHPUnit_Runner_Version::id(), '3.6.7', '<' )
+) {
+ die( 'PHPUnit 3.6.7 or later required, you have ' .
PHPUnit_Runner_Version::id() . ".\n" );
+}
+require_once( 'PHPUnit/Autoload.php' );
+
+require_once( __DIR__ . '/../../Ask.standalone.php' );
+
+spl_autoload_register( function ( $className ) {
+ static $classes = false;
+
+ if ( $classes === false ) {
+ $classes = include( __DIR__ . '/../AskTestClasses.php' );
+ }
+
+ if ( array_key_exists( $className, $classes ) ) {
+ include_once __DIR__ . '/../../../' . $classes[$className];
+ }
+} );
+
+$runner = new PHPUnit_TextUI_Command();
+$runner->run( array(
+ '--group',
+ 'Ask',
+ __DIR__
+ ) );
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/57692
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I95dcd08d71d0b795e006b68c5b8a504f6508f363
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Ask
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits