r72263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72262‎ | r72263 | r72264 >
Date:06:09, 3 September 2010
Author:tparscal
Status:deferred
Tags:
Comment:
Added basic structure for PHPUnit tests - had to name the directory strangely due to some messy SVN bugginess
Modified paths:
  • /branches/phpunit-restructure/maintenance/tests/phpunit (deleted) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/includes (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/languages (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/skins (added) (history)
  • /branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml (added) (history)

Diff [purge]

Index: branches/phpunit-restructure/maintenance/tests/phpunit
@@ -1,54 +0,0 @@
2 -#!/usr/bin/env php
3 -<?php
4 -
5 -require( dirname( __FILE__ ) . '/../commandLine.inc' );
6 -// XXX: This can go away if everyone switches to PHPUnit 3.5
7 -if ( @file_get_contents( 'PHPUnit/Autoload.php', true ) !== false ) {
8 - // Works for PHPUnit >= 3.5
9 - require_once 'PHPUnit/Autoload.php';
10 -} else {
11 - // Works for PHPUnit < 3.5
12 - require_once 'PHPUnit/TextUI/Command.php';
13 -}
14 -define( 'MW_PHPUNIT_TEST', 1 );
15 -
16 -$wgLocaltimezone = 'UTC';
17 -
18 -/* Tests were failing with sqlite */
19 -global $wgCaches;
20 -$wgCaches[CACHE_DB] = false;
21 -
22 -if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
23 - echo <<<EOF
24 -************************************************************
25 -
26 -These tests run best with version PHPUnit 3.4.2 or later.
27 -Earlier versions may show failures because earlier versions
28 -of PHPUnit do not properly implement dependencies.
29 -
30 -************************************************************
31 -
32 -EOF;
33 -}
34 -
35 -class MWPHPUnitCommand extends PHPUnit_TextUI_Command {
36 - protected function handleCustomTestSuite() {
37 - $suite = new PHPUnit_Framework_TestSuite;
38 - if ( !empty( $this->options[1] ) ) {
39 - $files = $this->options[1];
40 - } else {
41 - require( dirname( __FILE__ ) . '/TestFileList.php' );
42 - $files = $testFiles;
43 - wfRunHooks( 'UnitTestsList', array( &$files ) );
44 - }
45 - foreach ( $files as $file ) {
46 - $suite->addTestFile( $file );
47 - }
48 - $suite->setName( 'MediaWiki test suite' );
49 - $this->arguments['test'] = $suite;
50 - }
51 -}
52 -
53 -$command = new MWPHPUnitCommand;
54 -$command->run( $argv );
55 -
Index: branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php
@@ -0,0 +1,40 @@
 2+<?php
 3+/**
 4+ * Bootstrapping for MediaWiki PHPUnit tests
 5+ *
 6+ * @file
 7+ */
 8+
 9+// This file is not included in the global scope, but rather within a function, so we must global anything we need to
 10+// have access to in the global scope explicitly
 11+global $wgCommandLineMode, $IP, $optionsWithArgs;
 12+
 13+// Evaluate the include path relative to this file
 14+$IP = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
 15+
 16+// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
 17+define( 'MW_PHPUNIT_TEST', true );
 18+
 19+// Start up MediaWiki in command-line mode
 20+require_once( "$IP/maintenance/commandLine.inc" );
 21+
 22+// Assume UTC for testing purposes
 23+$wgLocaltimezone = 'UTC';
 24+
 25+// To prevent tests from failing with SQLite, we need to turn database caching off
 26+global $wgCaches;
 27+$wgCaches[CACHE_DB] = false;
 28+
 29+// Output a notice when running with older versions of PHPUnit
 30+if ( !version_compare( PHPUnit_Runner_Version::id(), "3.4.1", ">" ) ) {
 31+ echo <<<EOF
 32+********************************************************************************
 33+
 34+These tests run best with version PHPUnit 3.4.2 or better. Earlier versions may
 35+show failures because earlier versions of PHPUnit do not properly implement
 36+dependencies.
 37+
 38+********************************************************************************
 39+
 40+EOF;
 41+}
\ No newline at end of file
Property changes on: branches/phpunit-restructure/maintenance/tests/phpunit_dir/bootstrap.php
___________________________________________________________________
Added: svn:eol-style
142 + native
Index: branches/phpunit-restructure/maintenance/tests/phpunit_dir/suite.xml
@@ -0,0 +1,21 @@
 2+<?xml version="1.0" encoding="UTF-8"?>
 3+
 4+<phpunit bootstrap="./bootstrap.php"
 5+ colors="false"
 6+ backupGlobals="false"
 7+ convertErrorsToExceptions="true"
 8+ convertNoticesToExceptions="true"
 9+ convertWarningsToExceptions="true"
 10+ stopOnFailure="false">
 11+ <testsuites>
 12+ <testsuite name="includes">
 13+ <directory>./includes</directory>
 14+ </testsuite>
 15+ <testsuite name="languages">
 16+ <directory>./languages</directory>
 17+ </testsuite>
 18+ <testsuite name="skins">
 19+ <directory>./skins</directory>
 20+ </testsuite>
 21+ </testsuites>
 22+</phpunit>
\ No newline at end of file
Index: branches/phpunit-restructure/maintenance/tests/phpunit_dir/Makefile
@@ -0,0 +1,4 @@
 2+# Makefile
 3+
 4+test:
 5+ phpunit --configuration suite.xml
\ No newline at end of file

Status & tagging log