r109765 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109764‎ | r109765 | r109766 >
Date:21:53, 22 January 2012
Author:jpostlethwaite
Status:ok
Tags:
Comment:
Adding UnitTest Extension. See r109762.
Modified paths:
  • /trunk/extensions/UnitTest/tools/tests-template (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/AllTests.php (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/TestConfiguration.php.dist (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/TestHelper.php (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/phpunit.xml (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/selenium.ini.dst (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/unittest.conf.dist (added) (history)
  • /trunk/extensions/UnitTest/tools/tests-template/unittest.sh (added) (history)

Diff [purge]

Index: trunk/extensions/UnitTest/tools/tests-template/TestConfiguration.php.dist
@@ -0,0 +1,52 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ */
 18+
 19+/*
 20+ * Include PHPUnit dependencies
 21+ */
 22+require_once 'PHPUnit/Framework/IncompleteTestError.php';
 23+require_once 'PHPUnit/Framework/TestCase.php';
 24+require_once 'PHPUnit/Framework/TestSuite.php';
 25+require_once 'PHPUnit/Runner/Version.php';
 26+require_once 'PHPUnit/TextUI/TestRunner.php';
 27+require_once 'PHPUnit/Util/Filter.php';
 28+
 29+/*
 30+ * This file contains custom options and constants for test configuration.
 31+ */
 32+
 33+/**
 34+ * TESTS_MESSAGE_NOT_IMPLEMENTED
 35+ *
 36+ * Message for code that has not been implemented.
 37+ */
 38+define( 'TESTS_MESSAGE_NOT_IMPLEMENTED', 'Not implemented yet!' );
 39+
 40+/**
 41+ * TESTS_HOSTNAME
 42+ *
 43+ * The hostname for the system
 44+ */
 45+define( 'TESTS_HOSTNAME', 'localhost' );
 46+
 47+/**
 48+ * TESTS_EMAIL
 49+ *
 50+ * An email address to use in case test send mail
 51+ */
 52+define( 'TESTS_EMAIL', 'no-reply@example.org' );
 53+
Index: trunk/extensions/UnitTest/tools/tests-template/AllTests.php
@@ -0,0 +1,50 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ */
 18+
 19+/**
 20+ * REPLACE_ME_WITH_THE_EXTENSION_AllTests
 21+ */
 22+class REPLACE_ME_WITH_THE_EXTENSION_AllTests
 23+{
 24+
 25+ /**
 26+ * Run the main test and load any parameters if needed.
 27+ *
 28+ */
 29+ public static function main()
 30+ {
 31+ $parameters = array();
 32+
 33+ PHPUnit_TextUI_TestRunner::run( self::suite(), $parameters );
 34+ }
 35+
 36+ /**
 37+ * Run test suites
 38+ *
 39+ * @return PHPUnit_Framework_TestSuite
 40+ */
 41+ public static function suite()
 42+ {
 43+ $suite = new PHPUnit_Framework_TestSuite( 'REPLACE_ME_WITH_THE_EXTENSION Suite' );
 44+
 45+ // This is the class name of a test suite
 46+ $suite->addTestSuite( 'REPLACE_ME_WITH_THE_EXTENSION_Tests' );
 47+
 48+ return $suite;
 49+ }
 50+}
 51+
Property changes on: trunk/extensions/UnitTest/tools/tests-template/AllTests.php
___________________________________________________________________
Added: svn:mime-type
152 + text/plain
Added: svn:keywords
253 + Author Date HeadURL Header Id Revision
Added: svn:eol-style
354 + native
Index: trunk/extensions/UnitTest/tools/tests-template/TestHelper.php
@@ -0,0 +1,104 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 19+ */
 20+
 21+/*
 22+ * Set error reporting to the level to which code must comply.
 23+ */
 24+error_reporting( E_ALL | E_STRICT );
 25+
 26+if ( !defined( 'MEDIAWIKI' ) ) {
 27+ define( 'MEDIAWIKI', 1 );
 28+}
 29+
 30+/**
 31+ * TESTS_WEB_ROOT
 32+ *
 33+ * This is similar to $IP, the installation path in Mediawiki.
 34+ */
 35+define( 'TESTS_WEB_ROOT', dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) );
 36+
 37+$IP = TESTS_WEB_ROOT;
 38+
 39+/*
 40+ * Required files for unit testing.
 41+ */
 42+require_once( TESTS_WEB_ROOT . '/includes/Defines.php' );
 43+require_once( TESTS_WEB_ROOT . '/includes/DefaultSettings.php' );
 44+require_once( TESTS_WEB_ROOT . '/LocalSettings.php' );
 45+require_once( TESTS_WEB_ROOT . '/includes/SpecialPage.php' );
 46+require_once( TESTS_WEB_ROOT . '/includes/Title.php' );
 47+require_once( TESTS_WEB_ROOT . '/includes/Exception.php' );
 48+
 49+
 50+/*
 51+ * Unit tests are run from the command line.
 52+ *
 53+ * It should be confirmed that this will not affect other tests such as Selenium.
 54+ */
 55+//$wgCommandLineMode = true;
 56+//$wgCanonicalServer = true;
 57+
 58+/**
 59+ * Initializing the global $_SERVER for unit testing. This array does not exist
 60+ * on the CLI.
 61+ *
 62+ * You may customize this variable in TestConfiguration.php.
 63+ *
 64+ * @var array $_SERVER
 65+ */
 66+$_SERVER = array ( 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_COOKIE' => 'mediawiki_fundraising_117_session=f2rc8vv6av1o324qodvinqlpi1', 'HTTP_IF_MODIFIED_SINCE' => 'Fri, 14 Oct 2011 20:18:45 GMT', 'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin', 'SERVER_SIGNATURE' => '
 67+Apache/2.2.19 (Unix) DAV/2 PHP/5.3.7 Server at localhost Port 80
 68+', 'SERVER_SOFTWARE' => 'Apache/2.2.19 (Unix) DAV/2 PHP/5.3.7', 'SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/dev/null', 'SERVER_ADMIN' => 'no-reply@example.org', 'SCRIPT_FILENAME' => '/dev/null/index.php', 'REMOTE_PORT' => '62747', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'REQUEST_TIME' => 1318890010, );
 69+
 70+// Initialize session for unit testing
 71+$_SESSION = isset( $_SESSION ) ? $_SESSION : array();
 72+
 73+/*
 74+ * Required files for unit testing.
 75+ *
 76+ * These files need to be required after the above code. Do not move.
 77+ */
 78+require_once( TESTS_WEB_ROOT . '/includes/WebRequest.php' );
 79+require_once( TESTS_WEB_ROOT . '/includes/GlobalFunctions.php' );
 80+require_once( TESTS_WEB_ROOT . '/includes/HttpFunctions.php' );
 81+require_once( TESTS_WEB_ROOT . '/includes/db/Database.php' );
 82+require_once( TESTS_WEB_ROOT . '/includes/db/DatabaseMysql.php' );
 83+require_once( TESTS_WEB_ROOT . '/includes/Profiler.php' );
 84+require_once( TESTS_WEB_ROOT . '/includes/Sanitizer.php' );
 85+$request = $_SERVER;
 86+$wgRequest = new FauxRequest( $request );
 87+
 88+/*
 89+ * Load the user-defined test configuration file, if it exists; otherwise, load
 90+ * the default configuration.
 91+ */
 92+if ( is_file( 'TestConfiguration.php' ) ) {
 93+ require_once 'TestConfiguration.php';
 94+} else {
 95+ require_once 'TestConfiguration.php.dist';
 96+}
 97+
 98+/*
 99+ * Customize the server variable options.
 100+ */
 101+$_SERVER['HTTP_HOST'] = TESTS_HOSTNAME;
 102+$_SERVER['SERVER_NAME'] = TESTS_HOSTNAME;
 103+$_SERVER['SERVER_NAME'] = TESTS_WEB_ROOT;
 104+$_SERVER['SERVER_ADMIN'] = TESTS_EMAIL;
 105+
Property changes on: trunk/extensions/UnitTest/tools/tests-template/TestHelper.php
___________________________________________________________________
Added: svn:mime-type
1106 + text/plain
Added: svn:keywords
2107 + Author Date HeadURL Header Id Revision
Added: svn:eol-style
3108 + native
Index: trunk/extensions/UnitTest/tools/tests-template/unittest.conf.dist
@@ -0,0 +1,115 @@
 2+#!/bin/sh
 3+################################################################################
 4+#
 5+# Wikimedia Foundation
 6+#
 7+# LICENSE
 8+#
 9+# This program is free software; you can redistribute it and/or modify
 10+# it under the terms of the GNU General Public License as published by
 11+# the Free Software Foundation; either version 2 of the License, or
 12+# (at your option) any later version.
 13+#
 14+# This program is distributed in the hope that it will be useful,
 15+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17+# GNU General Public License for more details.
 18+#
 19+# @license http://www.gnu.org/copyleft/gpl.html GNU GENERAL PUBLIC LICENSE
 20+#
 21+################################################################################
 22+#
 23+# This is the distributed configuration file. If you need to make changes to
 24+# these settings, copy this file to this directory and remove the ".dist"
 25+# extension.
 26+#
 27+################################################################################
 28+#
 29+# @var string $UNITTEST_HOSTNAME The hostname to the webserver.
 30+#
 31+: ${UNITTEST_HOSTNAME:="localhost"}
 32+#
 33+# @var string $UNITTEST_URL The url to the webserver. You need the trailing
 34+# slash.
 35+#
 36+: ${UNITTEST_URL:="http://localhost/extensions/UnitTest/tests/"}
 37+#
 38+# @var string $PHPUNIT If phpunit.php is not within your shell $PATH, you may
 39+# specify the full path here.
 40+#
 41+: ${PHPUNIT:="phpunit.php"}
 42+#
 43+# @var string $PHPUNIT_OPTS By default, all testing will be run in verbose mode.
 44+#
 45+: ${PHPUNIT_OPTS:="--verbose"}
 46+#
 47+# @var string $PHPUNIT_LIST_GROUPS Specify the relative path to the file in
 48+# which you want to list groups designated by the doctag @group
 49+#
 50+: ${PHPUNIT_LIST_GROUPS:"=AllTests.php"}
 51+#
 52+# @var string $PHPUNIT_FILE Specify the relative path to the test in which you
 53+# want to run. You need to omit the ".php" extension.
 54+#
 55+: ${PHPUNIT_FILE:="AllTests"}
 56+#
 57+# @var string $PHPUNIT_COVERAGE_HTML The relative path to the code coverage
 58+# html directory
 59+#
 60+# This is where code coverage will be saved if the flag -ch is passed. If you wish to specify a full path, use:
 61+# --coverage-html "/some/absolute/path"
 62+#
 63+# These directories will need to exist, they will not be created.
 64+#
 65+: ${PHPUNIT_COVERAGE_HTML:="logs/coverage/html"}
 66+#
 67+# @var string $PHPUNIT_COVERAGE_CLOVER The relative path to the code coverage
 68+# clover directory
 69+#
 70+# This is where code coverage will be saved if the flag -ch is passed. If you wish to specify a full path, use:
 71+# --coverage-clover "/some/absolute/path"
 72+#
 73+# These directories will need to exist, they will not be created.
 74+#
 75+: ${PHPUNIT_COVERAGE_CLOVER:="logs/coverage/clover/index.xml"}
 76+#
 77+# @var string $PHPUNIT_TESTDOX_HTML The relative path to the testdox output html
 78+# directory. It is okay to put this the same directory as html coverage.
 79+#
 80+# This is where testdox will be saved if the flag -tdh is passed. If you wish to specify a full path, use:
 81+# --testdox-html "/some/absolute/path"
 82+#
 83+# These directories will need to exist, they will not be created.
 84+#
 85+: ${PHPUNIT_TESTDOX_HTML:="logs/coverage/html/testdox.html"}
 86+#
 87+# @var string $PHPUNIT_LOG_JSON The relative path to the log output json
 88+# directory.
 89+#
 90+# This is where log.json will be saved if the flag -ljs is passed. If you wish to specify a full path, use:
 91+# --log-json "/some/absolute/path"
 92+#
 93+# These directories will need to exist, they will not be created.
 94+#
 95+: ${PHPUNIT_LOG_JSON:="logs/coverage/results/log.json"}
 96+#
 97+# @var string $PHPUNIT_LOG_JUNIT The relative path to the log output junit
 98+# directory.
 99+#
 100+# This is where log.xml will be saved if the flag -lju is passed. If you wish to specify a full path, use:
 101+# --log-junit "/some/absolute/path"
 102+#
 103+# These directories will need to exist, they will not be created.
 104+#
 105+: ${PHPUNIT_LOG_JUNIT:="logs/coverage/results/log.xml"}
 106+#
 107+# @var string $PHPUNIT_LOG_TAP The relative path to the log output tap
 108+# directory.
 109+#
 110+# This is where log.tap will be saved if the flag -ljs is passed. If you wish to specify a full path, use:
 111+# --log-tap "/some/absolute/path"
 112+#
 113+# These directories will need to exist, they will not be created.
 114+#
 115+: ${PHPUNIT_LOG_TAP:="logs/coverage/results/log.tap"}
 116+
Index: trunk/extensions/UnitTest/tools/tests-template/phpunit.xml
@@ -0,0 +1,46 @@
 2+<phpunit bootstrap="TestHelper.php">
 3+ <filter>
 4+ <blacklist>
 5+ <directory>../resources</directory>
 6+ <directory>../tests</directory>
 7+ <directory>../tools</directory>
 8+ </blacklist>
 9+ <whitelist>
 10+ <directory suffix=".php">../special</directory>
 11+ <exclude>
 12+ </exclude>
 13+ </whitelist>
 14+ </filter>
 15+ <selenium>
 16+ <!-- Choose a browser to run for testing and uncomment it. -->
 17+
 18+ <!-- You may need to alter the parameters for your browser. -->
 19+
 20+ <!-- Chrome -->
 21+
 22+ <!--
 23+ <browser name="Chrome on Mac" browser="*chrome /Applications/Google Chrome.app/Contents/MacOS/Google Chrome" host="localhost" port="4444" timeout="30000"/>
 24+ -->
 25+
 26+ <!-- Firefox -->
 27+
 28+ <!--
 29+ <browser name="Firefox on Linux" browser="*firefox /usr/lib/firefox/firefox-bin" host="localhost" port="4444" timeout="30000"/>
 30+ <browser name="Firefox on Mac" browser="*firefox /Applications/Firefox.app/Contents/MacOS/firefox-bin" host="localhost" port="4444" timeout="30000"/>
 31+ <browser name="Firefox on Windows XP" browser="*firefox C:\Program Files\Mozilla Firefox\firefox.exe" host="localhost" port="4444" timeout="30000"/>
 32+ -->
 33+
 34+ <!-- Internet Explorer -->
 35+
 36+ <!--
 37+ <browser name="IE on Windows XP" browser="*iexplore" host="localhost" port="4444" timeout="30000"/>
 38+ -->
 39+
 40+ <!-- Safari -->
 41+
 42+ <!--
 43+ <browser name="Safari on Mac" browser="*safari /Applications/Safari.app/Contents/MacOS/Safari" host="localhost" port="4444" timeout="30000"/>
 44+ <browser name="Safari on Windows XP" browser="**custom C:\Program Files\Safari\Safari.exe -url" host="localhost" port="4444" timeout="30000"/>
 45+ -->
 46+ </selenium>
 47+</phpunit>
\ No newline at end of file
Property changes on: trunk/extensions/UnitTest/tools/tests-template/phpunit.xml
___________________________________________________________________
Added: svn:mime-type
148 + text/xml
Added: svn:keywords
249 + Author Date HeadURL Header Id Revision
Added: svn:eol-style
350 + native
Index: trunk/extensions/UnitTest/tools/tests-template/selenium.ini.dst
@@ -0,0 +1,44 @@
 2+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 3+;
 4+; This is the distributed configuration file for selenium and the extension
 5+; CentralNotice.
 6+;
 7+; Do not edit this file. If you would like to make changes, copy this file to
 8+; the same directory, removing the .dst extension:
 9+;
 10+; cp selenium.ini.dst selenium.ini
 11+;
 12+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 13+;
 14+; selenium
 15+;
 16+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 17+[selenium]
 18+;
 19+; Screenshots are enabled by default
 20+;
 21+screenshots = yes
 22+;
 23+; Capture screenshots after assertion is enabled by default
 24+;
 25+screenshotAfterAssertion = yes
 26+;
 27+; Load selenese
 28+;
 29+selenese = yes
 30+
 31+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 32+;
 33+; host
 34+;
 35+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 36+[host]
 37+hostname = "localhost"
 38+browserUrl = "http://localhost/"
 39+
 40+[credentials]
 41+admin[username] = "admin"
 42+admin[password] = "mediawiki"
 43+
 44+user[username] = "user"
 45+user[password] = "mediawiki"
Index: trunk/extensions/UnitTest/tools/tests-template/unittest.sh
@@ -0,0 +1,386 @@
 2+#!/bin/sh
 3+################################################################################
 4+#
 5+# Wikimedia Foundation
 6+#
 7+# LICENSE
 8+#
 9+# This program is free software; you can redistribute it and/or modify
 10+# it under the terms of the GNU General Public License as published by
 11+# the Free Software Foundation; either version 2 of the License, or
 12+# (at your option) any later version.
 13+#
 14+# This program is distributed in the hope that it will be useful,
 15+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17+# GNU General Public License for more details.
 18+#
 19+#
 20+# @license http://www.gnu.org/copyleft/gpl.html GNU GENERAL PUBLIC LICENSE
 21+# @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 22+#
 23+################################################################################
 24+#
 25+# The script:
 26+#
 27+# unittest.sh - Launch PHPUnit for specific test group(s).
 28+#
 29+################################################################################
 30+#
 31+# Debugging the script
 32+#
 33+# The set -x option causes sh to print each command to standard error before
 34+# executing it. Since this can generate a lot of output, you may want to turn
 35+# tracing on just before the section that you want to trace, and turn it off
 36+# immediately afterward:
 37+#set -x
 38+#
 39+################################################################################
 40+#
 41+# help()
 42+#
 43+################################################################################
 44+help()
 45+{
 46+ cat <<HELP
 47+
 48+NAME
 49+ unittest.sh -- Run phpunit
 50+
 51+SYNOPSIS
 52+ $0
 53+ [-h | --help] [help]
 54+ [-g | --list-groups] ["relative/path/to/file"]
 55+
 56+ [-d | --debug ]
 57+ [-nc | --no-configuration ]
 58+
 59+ [-cc | --coverage-clover ["/full/path/to/index.xml"] ]
 60+ [-ch | --coverage-html ["/full/path/to/folder"] ]
 61+ [-tdh | --testdox-html ["/full/path/to/testdox.html"] ]
 62+ [-tdt | --testdox-text ["/full/path/to/testdox.txt"] ]
 63+
 64+ [-ljs | --log-json ["/full/path/to/log.json"] ]
 65+ [-lju | --log-junit ["/full/path/to/log.xml"] ]
 66+
 67+ [-a | --all ]
 68+
 69+DESCRIPTION
 70+ The unittest.sh script is designed to facilitate running phpunit.
 71+
 72+EXAMPLES
 73+
 74+ # List all groups available for testing
 75+
 76+ $0 -g
 77+
 78+ # List all groups available for testing in the file PostTestCase
 79+
 80+ $0 -g GlobalCollect/AllTests.php
 81+
 82+ # List all groups available for testing in the file PostTestCase
 83+
 84+ $0 -g GlobalCollect/PostTestCase.php
 85+
 86+ # Run unit testing with html code coverage report to default path
 87+
 88+ $0 -ch
 89+
 90+ # Run unit testing with html code coverage report
 91+
 92+ $0 -ch GlobalCollect/AllTests
 93+
 94+ # Run unit testing with clover code coverage report to default path
 95+
 96+ $0 -cc
 97+
 98+ # Run unit testing with clover code coverage report
 99+
 100+ $0 -cc GlobalCollect/AllTests
 101+
 102+ # Generate testdox report
 103+
 104+ $0 -tdh
 105+ $0 --testdox-html
 106+
 107+ # Turn on PHPUnit debugging
 108+
 109+ $0 -d
 110+ $0 --debug
 111+
 112+ # Ignore the local phpunit.xml file
 113+
 114+ $0 -nc
 115+ $0 --no-configuration
 116+
 117+ # Run all testing options: -cc -ch -tdh -d -ljs -lju
 118+
 119+ $0 -a
 120+ $0 --all
 121+
 122+HELP
 123+ exit 0
 124+}
 125+################################################################################
 126+#
 127+# load_configuration()
 128+#
 129+# Load the configuration file
 130+#
 131+################################################################################
 132+load_configuration()
 133+{
 134+ CONFIGURATION_FILE="unittest.conf"
 135+
 136+ # Load the custom configuration file if it exists
 137+ if [ -f "${CONFIGURATION_FILE}" ]; then
 138+ echo "Loading the configuration file (${CONFIGURATION_FILE}) in: `pwd`"
 139+ . ${CONFIGURATION_FILE};
 140+ else
 141+
 142+ # Load the default configuration file
 143+ CONFIGURATION_FILE="${CONFIGURATION_FILE}.dist"
 144+
 145+ if [ -f "${CONFIGURATION_FILE}" ]; then
 146+ echo "Loading the default configuration file (${CONFIGURATION_FILE}.dist) in: `pwd`"
 147+ . ${CONFIGURATION_FILE};
 148+ else
 149+ echo "The default configuration file (${CONFIGURATION_FILE}) is missing from: `pwd`"
 150+ exit 1;
 151+ fi
 152+ fi
 153+}
 154+################################################################################
 155+#
 156+# Begin execution of script
 157+#
 158+################################################################################
 159+# Run help if needed.
 160+[ -z "${1}" ] && help
 161+[ "${1}" = "-h" ] && help
 162+[ "${1}" = "help" ] && help
 163+
 164+#
 165+# @var string $UNITTEST_DIRECTORY This is the relative path to the
 166+# configuration file.
 167+UNITTEST_DIRECTORY="`dirname $0`/"
 168+
 169+# Change to script directory to keep path variables consistent.
 170+cd ${UNITTEST_DIRECTORY}
 171+
 172+load_configuration
 173+################################################################################
 174+#
 175+# @var string $PHPUNIT_COVERAGE_HTML_LINK The link to html code coverage
 176+#
 177+PHPUNIT_COVERAGE_HTML_LINK=${UNITTEST_URL}
 178+#
 179+# @var string $PHPUNIT_COVERAGE_CLOVER_LINK The link to clover code coverage
 180+#
 181+PHPUNIT_COVERAGE_CLOVER_LINK=${UNITTEST_URL}
 182+#
 183+# @var string $PHPUNIT_COVERAGE_TESTDOX_LINK The link to testdox code coverage
 184+#
 185+PHPUNIT_COVERAGE_TESTDOX_LINK=${UNITTEST_URL}
 186+#
 187+# @var string $PHPUNIT_LOG_JSON_LINK The link to json log results
 188+#
 189+PHPUNIT_LOG_JSON_LINK=${UNITTEST_URL}
 190+#
 191+# @var string $PHPUNIT_LOG_JUNIT_LINK The link to junit log results
 192+#
 193+PHPUNIT_LOG_JUNIT_LINK=${UNITTEST_URL}
 194+#
 195+# @var string $PHPUNIT_LOG_TAP_LINK The link to tap log results
 196+#
 197+PHPUNIT_LOG_TAP_LINK=${UNITTEST_URL}
 198+
 199+# The flags that will be passed to phpunit.
 200+#
 201+# @var string $PHPUNIT_UNITTEST_FLAGS
 202+#
 203+PHPUNIT_UNITTEST_FLAGS=${1};
 204+
 205+# Run unit tests without the configuration
 206+#
 207+# @var integer $PHPUNIT_UNITTEST_WITHOUT_CONFIGURATION This will be equal to one if
 208+# phpunit.xml is not used. See the flag: -nc
 209+#
 210+PHPUNIT_UNITTEST_WITHOUT_CONFIGURATION=0;
 211+
 212+# These are the flags that will be run if -a | --all is specified
 213+#
 214+# @var integer $PHPUNIT_UNITTEST_ALL_FLAGS
 215+#
 216+PHPUNIT_UNITTEST_ALL_FLAGS="-cc -ch -tdh -d -ljs -lju";
 217+################################################################################
 218+
 219+################################################################################
 220+#
 221+# Loop through options to pass to phpunit.php
 222+#
 223+################################################################################
 224+
 225+#echo "Pre: ${PHPUNIT_UNITTEST_FLAGS}"
 226+
 227+# Check to see if all options will be ran.
 228+if [[ "${PHPUNIT_UNITTEST_FLAGS}" == "-a" ]]; then
 229+ echo "Running all options for testing: ${PHPUNIT_UNITTEST_ALL_FLAGS}"
 230+ PHPUNIT_UNITTEST_FLAGS=${PHPUNIT_UNITTEST_ALL_FLAGS};
 231+fi
 232+
 233+#echo "Post: ${PHPUNIT_UNITTEST_FLAGS}"
 234+
 235+PHPUNIT_SKIP_FLAG=0;
 236+
 237+for PHPUNIT_UNITTEST_FLAG in ${PHPUNIT_UNITTEST_FLAGS}
 238+do
 239+ if [[ "${PHPUNIT_SKIP_FLAG}" > 0 ]]; then
 240+ #echo "PHPUNIT_SKIP_FLAG: ${PHPUNIT_SKIP_FLAG}";
 241+ PHPUNIT_SKIP_FLAG=(${PHPUNIT_SKIP_FLAG} - 1);
 242+ continue;
 243+ fi
 244+
 245+ #echo "Loop: ${PHPUNIT_UNITTEST_FLAGS}"
 246+
 247+ case "${PHPUNIT_UNITTEST_FLAG}" in
 248+
 249+ # list-groups
 250+ -g|--list-groups)
 251+ PHPUNIT_LIST_GROUPS="--list-groups"
 252+ break ;;
 253+
 254+ # coverage-html
 255+ -ch)
 256+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-html ${PHPUNIT_COVERAGE_HTML}";
 257+ PHPUNIT_COVERAGE_HTML_LINK="${PHPUNIT_COVERAGE_HTML_LINK}${PHPUNIT_COVERAGE_HTML}";
 258+ PHPUNIT_UNITTEST_WITHOUT_CONFIGURATION=1;
 259+ continue ;;
 260+
 261+ --coverage-html)
 262+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-html $2";
 263+ PHPUNIT_COVERAGE_HTML_LINK="${PHPUNIT_COVERAGE_HTML_LINK}$2";
 264+ PHPUNIT_SKIP_FLAG=1;
 265+ continue ;;
 266+
 267+ # coverage-clover
 268+ -cc)
 269+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-clover ${PHPUNIT_COVERAGE_CLOVER}";
 270+ PHPUNIT_COVERAGE_CLOVER_LINK="${PHPUNIT_COVERAGE_CLOVER_LINK}${PHPUNIT_COVERAGE_CLOVER}";
 271+ continue ;;
 272+
 273+ --coverage-clover)
 274+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --coverage-clover $2";
 275+ PHPUNIT_COVERAGE_CLOVER_LINK="${PHPUNIT_COVERAGE_CLOVER_LINK}$2";
 276+ PHPUNIT_SKIP_FLAG=1;
 277+ continue ;;
 278+
 279+ # no-configuration
 280+ -nc|--no-configuration)
 281+ PHPUNIT_OPTS="${PHPUNIT_OPTS} --no-configuration";
 282+ continue ;;
 283+
 284+ # testdox-html
 285+ -tdh)
 286+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --testdox-html ${PHPUNIT_TESTDOX_HTML}";
 287+ PHPUNIT_COVERAGE_TESTDOX_LINK="${PHPUNIT_COVERAGE_TESTDOX_LINK}${PHPUNIT_TESTDOX_HTML}";
 288+ continue ;;
 289+
 290+ --testdox-html)
 291+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --testdox-html $2";
 292+ PHPUNIT_COVERAGE_TESTDOX_LINK="${PHPUNIT_COVERAGE_TESTDOX_LINK}$2";
 293+ PHPUNIT_SKIP_FLAG=1;
 294+ continue ;;
 295+
 296+ # log-json
 297+ -ljs)
 298+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --log-json ${PHPUNIT_LOG_JSON}";
 299+ PHPUNIT_LOG_JSON_LINK="${PHPUNIT_LOG_JSON_LINK}${PHPUNIT_LOG_JSON}";
 300+ PHPUNIT_UNITTEST_WITHOUT_CONFIGURATION=1;
 301+ continue ;;
 302+
 303+ --log-json)
 304+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --log-json $2";
 305+ PHPUNIT_LOG_JSON_LINK="${PHPUNIT_LOG_JSON_LINK}$2";
 306+ PHPUNIT_SKIP_FLAG=1;
 307+ continue ;;
 308+
 309+ # log-junit
 310+ -lju)
 311+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --log-junit ${PHPUNIT_LOG_JUNIT}";
 312+ PHPUNIT_LOG_JUNIT_LINK="${PHPUNIT_LOG_JUNIT_LINK}${PHPUNIT_LOG_JUNIT}";
 313+ PHPUNIT_UNITTEST_WITHOUT_CONFIGURATION=1;
 314+ continue ;;
 315+
 316+ --log-junit)
 317+ PHPUNIT_COVERAGE="${PHPUNIT_COVERAGE} --log-junit $2";
 318+ PHPUNIT_LOG_JUNIT_LINK="${PHPUNIT_LOG_JUNIT_LINK}$2";
 319+ PHPUNIT_SKIP_FLAG=1;
 320+ continue ;;
 321+
 322+ # debug
 323+ -d|--debug)
 324+ PHPUNIT_OPTS="${PHPUNIT_OPTS} --debug";
 325+ continue ;;
 326+
 327+ # file
 328+ -f|--file)
 329+ PHPUNIT_FILE="$2"
 330+ PHPUNIT_SKIP_FLAG=1;
 331+ continue ;;
 332+
 333+ *)
 334+ PHPUNIT_GROUPS="${PHPUNIT_GROUPS:+"$PHPUNIT_GROUPS,"}${PHPUNIT_UNITTEST_FLAGS}";
 335+ echo "-----------"
 336+ continue ;;
 337+ esac
 338+done
 339+################################################################################
 340+#
 341+# Information statements
 342+#
 343+################################################################################
 344+echo ""
 345+
 346+echo "SCRIPT PATH: ${PATH}"
 347+
 348+echo ""
 349+
 350+echo "PWD: `pwd`"
 351+
 352+echo ""
 353+
 354+COMMAND_OPTIONS="${PHPUNIT_OPTS} ${PHPUNIT_LIST_GROUPS} ${PHPUNIT_COVERAGE} ${PHPUNIT_GROUPS:+--group $PHPUNIT_GROUPS} ${PHPUNIT_FILE}"
 355+echo "COMMAND: ${PHPUNIT} ${COMMAND_OPTIONS}"
 356+
 357+echo ""
 358+
 359+echo "HTML code coverage link: ${PHPUNIT_COVERAGE_HTML_LINK}"
 360+
 361+echo ""
 362+
 363+echo "Clover code coverage link: ${PHPUNIT_COVERAGE_CLOVER_LINK}"
 364+
 365+echo ""
 366+
 367+echo "Testdox code coverage link: ${PHPUNIT_COVERAGE_TESTDOX_LINK}"
 368+
 369+echo ""
 370+
 371+echo "Log results json: ${PHPUNIT_LOG_JSON_LINK}"
 372+
 373+echo ""
 374+
 375+echo "Log results junit: ${PHPUNIT_LOG_JUNIT_LINK}"
 376+
 377+echo ""
 378+
 379+################################################################################
 380+# Debugging
 381+#
 382+# The set -n option causes sh to read the script but not execute any commands.
 383+# This is useful for checking syntax.
 384+#set -n
 385+################################################################################
 386+
 387+${PHPUNIT} ${PHPUNIT_OPTS} ${COMMAND_OPTIONS}
Property changes on: trunk/extensions/UnitTest/tools/tests-template/unittest.sh
___________________________________________________________________
Added: svn:keywords
1388 + Author Date HeadURL Header Id Revision
Added: svn:eol-style
2389 + native
Added: svn:executable
3390 + *
Property changes on: trunk/extensions/UnitTest/tools/tests-template
___________________________________________________________________
Added: svn:ignore
4391 + TestConfiguration.php
selenium.ini
unittest.conf

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109762Adding UnitTest Extensionjpostlethwaite21:45, 22 January 2012

Status & tagging log