http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72263

Revision: 72263
Author:   tparscal
Date:     2010-09-03 06:09:07 +0000 (Fri, 03 Sep 2010)

Log Message:
-----------
Added basic structure for PHPUnit tests - had to name the directory strangely 
due to some messy SVN bugginess

Added Paths:
-----------
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/includes/
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/languages/
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/skins/
    branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml

Removed Paths:
-------------
    branches/phpunit-restructure/maintenance/tests/phpunit

Deleted: branches/phpunit-restructure/maintenance/tests/phpunit
===================================================================
--- branches/phpunit-restructure/maintenance/tests/phpunit      2010-09-03 
05:45:23 UTC (rev 72262)
+++ branches/phpunit-restructure/maintenance/tests/phpunit      2010-09-03 
06:09:07 UTC (rev 72263)
@@ -1,54 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-require( dirname( __FILE__ ) . '/../commandLine.inc' );
-// XXX: This can go away if everyone switches to PHPUnit 3.5
-if ( @file_get_contents( 'PHPUnit/Autoload.php', true ) !== false ) { 
-       // Works for PHPUnit >= 3.5
-       require_once 'PHPUnit/Autoload.php';
-} else {
-       // Works for PHPUnit < 3.5
-       require_once 'PHPUnit/TextUI/Command.php';
-}
-define( 'MW_PHPUNIT_TEST', 1 );
-
-$wgLocaltimezone = 'UTC';
-
-/* Tests were failing with sqlite */
-global $wgCaches;
-$wgCaches[CACHE_DB] = false;
-
-if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
-       echo <<<EOF
-************************************************************
-
-These tests run best with version PHPUnit 3.4.2 or later.
-Earlier versions may show failures because earlier versions
-of PHPUnit do not properly implement dependencies.
-
-************************************************************
-
-EOF;
-}
-
-class MWPHPUnitCommand extends PHPUnit_TextUI_Command {
-       protected function handleCustomTestSuite() {
-               $suite = new PHPUnit_Framework_TestSuite;
-               if ( !empty( $this->options[1] ) ) {
-                       $files = $this->options[1];
-               } else {
-                       require( dirname( __FILE__ ) . '/TestFileList.php' );
-                       $files = $testFiles;
-                       wfRunHooks( 'UnitTestsList', array( &$files ) );
-               }
-               foreach ( $files as $file ) {
-                       $suite->addTestFile( $file );
-               }
-               $suite->setName( 'MediaWiki test suite' );
-               $this->arguments['test'] = $suite;
-       }
-}
-
-$command = new MWPHPUnitCommand;
-$command->run( $argv );
-

Added: branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile
===================================================================
--- branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile         
                (rev 0)
+++ branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile 
2010-09-03 06:09:07 UTC (rev 72263)
@@ -0,0 +1,4 @@
+# Makefile
+
+test:
+       phpunit --configuration suite.xml
\ No newline at end of file

Added: branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php
===================================================================
--- branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php    
                        (rev 0)
+++ branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php    
2010-09-03 06:09:07 UTC (rev 72263)
@@ -0,0 +1,40 @@
+<?php 
+/**
+ * Bootstrapping for MediaWiki PHPUnit tests
+ * 
+ * @file
+ */
+
+// This file is not included in the global scope, but rather within a 
function, so we must global anything we need to
+// have access to in the global scope explicitly
+global $wgCommandLineMode, $IP, $optionsWithArgs;
+
+// Evaluate the include path relative to this file
+$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
+
+// Set a flag which can be used to detect when other scripts have been entered 
through this entry point or not
+define( 'MW_PHPUNIT_TEST', true );
+
+// Start up MediaWiki in command-line mode
+require_once( "$IP/maintenance/commandLine.inc" );
+
+// Assume UTC for testing purposes
+$wgLocaltimezone = 'UTC';
+
+// To prevent tests from failing with SQLite, we need to turn database caching 
off
+global $wgCaches;
+$wgCaches[CACHE_DB] = false;
+
+// Output a notice when running with older versions of PHPUnit
+if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
+  echo <<<EOF
+********************************************************************************
+
+These tests run best with version PHPUnit 3.4.2 or better. Earlier versions may
+show failures because earlier versions of PHPUnit do not properly implement
+dependencies.
+
+********************************************************************************
+
+EOF;
+}
\ No newline at end of file


Property changes on: 
branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php
___________________________________________________________________
Added: svn:eol-style
   + native

Added: branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml
===================================================================
--- branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml        
                        (rev 0)
+++ branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml        
2010-09-03 06:09:07 UTC (rev 72263)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit bootstrap="./bootstrap.php"
+                colors="false"
+         backupGlobals="false"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+                stopOnFailure="false">
+       <testsuites>
+               <testsuite name="includes">
+                       <directory>./includes</directory>
+               </testsuite>
+               <testsuite name="languages">
+                       <directory>./languages</directory>
+               </testsuite>
+               <testsuite name="skins">
+                       <directory>./skins</directory>
+               </testsuite>
+       </testsuites>
+</phpunit>
\ No newline at end of file



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

Reply via email to