Jeroen De Dauw has uploaded a new change for review.

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


Change subject: Move broken phpunit config file out of the way and update 
travis build config
......................................................................

Move broken phpunit config file out of the way and update travis build config

Change-Id: I5a0cc117826ade47d053fe6773c7611facdc947e
---
M .travis.sh
M client/WikibaseClient.php
D phpunit.xml.dist
M repo/Wikibase.php
A repo/phpunit.xml.dist
A repo/tests/bootstrap.php
A repo/tests/evilMediaWikiBootstrap.php
7 files changed, 120 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/22/68722/1

diff --git a/.travis.sh b/.travis.sh
index 2763467..e8fee3c 100644
--- a/.travis.sh
+++ b/.travis.sh
@@ -25,5 +25,4 @@
 
 php /maintenance/update.php --quick
 
-cd extensions/Wikibase
-phpunit
\ No newline at end of file
+php /tests/phpunit/phpunit.php --group Wikibase
\ No newline at end of file
diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php
index 0388c19..2d54e64 100644
--- a/client/WikibaseClient.php
+++ b/client/WikibaseClient.php
@@ -23,6 +23,14 @@
        die( "Not an entry point.\n" );
 }
 
+if ( defined( 'WBL_VERSION' ) ) {
+       // Do not initialize more then once.
+       return;
+}
+
+define( 'WBC_VERSION', '0.4 alpha'
+       . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? 
'/experimental' : '' ) );
+
 if ( version_compare( $wgVersion, '1.21c', '<' ) ) { // Needs to be 1.21c 
because version_compare() works in confusing ways.
        die( "<b>Error:</b> Wikibase requires MediaWiki 1.21 alpha or above.\n" 
);
 }
@@ -35,9 +43,6 @@
 if ( !defined( 'WBL_VERSION' ) ) {
        die( '<b>Error:</b> WikibaseClient depends on the <a 
href="https://www.mediawiki.org/wiki/Extension:WikibaseLib";>WikibaseLib</a> 
extension.' );
 }
-
-define( 'WBC_VERSION', '0.4 alpha'
-       . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? 
'/experimental' : '' ) );
 
 $wgExtensionCredits['wikibase'][] = array(
        'path' => __DIR__,
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
deleted file mode 100644
index 327a5de..0000000
--- a/phpunit.xml.dist
+++ /dev/null
@@ -1,26 +0,0 @@
-<phpunit backupGlobals="false"
-         backupStaticAttributes="false"
-         bootstrap="Database/tests/bootstrap.php"
-         cacheTokens="false"
-         colors="true"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="false"
-         convertWarningsToExceptions="true"
-         stopOnError="false"
-         stopOnFailure="false"
-         stopOnIncomplete="false"
-         stopOnSkipped="false"
-         strict="true"
-         verbose="true">
-    <testsuites>
-        <testsuite name="WikibaseDatabaseStandalone">
-            <directory>Database/tests/phpunit</directory>
-            <exclude>Database/tests/phpunit/MWDB</exclude>
-            
<exclude>Database/tests/phpunit/MediaWikiQueryInterfaceTest.php</exclude>
-        </testsuite>
-        <testsuite name="WikibaseDatabaseMediaWiki">
-            <directory>Database/tests/phpunit/MWDB</directory>
-            <file>Database/tests/phpunit/MediaWikiQueryInterfaceTest.php</file>
-        </testsuite>
-    </testsuites>
-</phpunit>
diff --git a/repo/Wikibase.php b/repo/Wikibase.php
index cbc0168..ea6c1ed 100644
--- a/repo/Wikibase.php
+++ b/repo/Wikibase.php
@@ -34,6 +34,14 @@
        die( 'Not an entry point.' );
 }
 
+if ( defined( 'WB_VERSION' ) ) {
+       // Do not initialize more then once.
+       return;
+}
+
+define( 'WB_VERSION', '0.4 alpha'
+       . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? 
'/experimental' : '' ) );
+
 if ( version_compare( $wgVersion, '1.20c', '<' ) ) { // Needs to be 1.20c 
because version_compare() works in confusing ways.
        die( '<b>Error:</b> Wikibase requires MediaWiki 1.20 or above.' );
 }
@@ -46,9 +54,6 @@
 if ( !defined( 'WBL_VERSION' ) ) {
        die( '<b>Error:</b> Wikibase depends on the <a 
href="https://www.mediawiki.org/wiki/Extension:WikibaseLib";>WikibaseLib</a> 
extension.' );
 }
-
-define( 'WB_VERSION', '0.4 alpha'
-       . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? 
'/experimental' : '' ) );
 
 $wgExtensionCredits['wikibase'][] = array(
        'path' => __DIR__,
diff --git a/repo/phpunit.xml.dist b/repo/phpunit.xml.dist
new file mode 100644
index 0000000..e04344a
--- /dev/null
+++ b/repo/phpunit.xml.dist
@@ -0,0 +1,13 @@
+<phpunit bootstrap="tests/bootstrap.php"
+         colors="true"
+         stopOnError="false"
+         stopOnFailure="false"
+         stopOnIncomplete="false"
+         stopOnSkipped="false"
+         verbose="true">
+    <testsuites>
+        <testsuite name="WikibaseRepo">
+            <directory>tests/phpunit</directory>
+        </testsuite>
+    </testsuites>
+</phpunit>
diff --git a/repo/tests/bootstrap.php b/repo/tests/bootstrap.php
new file mode 100644
index 0000000..57cb3c0
--- /dev/null
+++ b/repo/tests/bootstrap.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * PHPUnit bootstrap file for the Wikibase Repo extension.
+ *
+ * @since 0.4
+ *
+ * @file
+ * @ingroup Wikibase
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+
+die( 'This test bootstrap does not work yet due to assumed global scope in 
Wikibase' );
+
+require_once( __DIR__ . '/evilMediaWikiBootstrap.php' );
+
+require_once( __DIR__ . '/../Wikibase.php' );
+
+require_once( __DIR__ . '/../ExampleSettings.php' );
\ No newline at end of file
diff --git a/repo/tests/evilMediaWikiBootstrap.php 
b/repo/tests/evilMediaWikiBootstrap.php
new file mode 100644
index 0000000..b66658a
--- /dev/null
+++ b/repo/tests/evilMediaWikiBootstrap.php
@@ -0,0 +1,69 @@
+<?php
+
+define( 'MEDIAWIKI', true );
+
+global $IP;
+$IP = getenv( 'MW_INSTALL_PATH' );
+
+if ( $IP === false ) {
+       $IP = dirname( __FILE__ ) . '/../../../..';
+}
+
+$self = 'foobar';
+
+// Detect compiled mode
+# Get the MWInit class
+require_once "$IP/includes/Init.php";
+require_once "$IP/includes/AutoLoader.php";
+
+# Stub the profiler
+require_once "$IP/includes/profiler/Profiler.php";
+
+# Start the profiler
+$wgProfiler = array();
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+       require "$IP/StartProfiler.php";
+}
+
+// Some other requires
+require_once "$IP/includes/Defines.php";
+
+require_once MWInit::compiledPath( 'includes/DefaultSettings.php' );
+
+foreach ( get_defined_vars() as $key => $var ) {
+       if ( !array_key_exists( $key, $GLOBALS ) ) {
+               $GLOBALS[$key] = $var;
+       }
+}
+
+if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
+       # Use a callback function to configure MediaWiki
+       MWFunction::call( MW_CONFIG_CALLBACK );
+} else {
+       // Require the configuration (probably LocalSettings.php)
+       require loadSettings();
+}
+
+// Some last includes
+require_once MWInit::compiledPath( 'includes/Setup.php' );
+
+// Much much faster startup than creating a title object
+$wgTitle = null;
+
+global $wgAutoloadClasses;
+$wgAutoloadClasses = array();
+require_once $IP . '/tests/TestsAutoLoader.php';
+
+function loadSettings() {
+       global $wgCommandLineMode, $IP;
+
+       $settingsFile = "$IP/LocalSettings.php";
+
+       if ( !is_readable( $settingsFile ) ) {
+               $this->error( "A copy of your installation's 
LocalSettings.php\n" .
+                       "must exist and be readable in the source directory.\n" 
.
+                       "Use --conf to specify it.", true );
+       }
+       $wgCommandLineMode = true;
+       return $settingsFile;
+}
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a0cc117826ade47d053fe6773c7611facdc947e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

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

Reply via email to