From 28516c209d3ada8508455b405d759f516c23aaab Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 3 Oct 2010 21:25:33 +0000 Subject: [PATCH] Changed phpunit Makefile to require 'make destructive' to run the test suites as a temporary safety check. Looks like somebody's snuck a bunch of destructive tests into the default PHPUnit test suite; this is unsafe and could cause admins and developers to damage their wikis contents accidentally, not realizing that their main page will be deleted etc. Tests should be split up into those which alter the live database and those that don't; only those which are non-destructive should run unless explicitly requested. --- maintenance/tests/phpunit/Makefile | 16 ++++++++++++++-- maintenance/tests/phpunit/README | 6 ++++++ maintenance/tests/phpunit/TODO | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/maintenance/tests/phpunit/Makefile b/maintenance/tests/phpunit/Makefile index 1f6539ee07..d57ee5d3c1 100644 --- a/maintenance/tests/phpunit/Makefile +++ b/maintenance/tests/phpunit/Makefile @@ -1,11 +1,23 @@ -.PHONY: help test phpunit install coverage +.PHONY: help test phpunit install coverage warning destructive SHELL = /bin/sh CONFIG_FILE = $(shell pwd)/suite.xml FLAGS = PU = phpunit --configuration ${CONFIG_FILE} -all test: phpunit +all test: warning + +warning: + @echo "WARNING -- these tests are DESTRUCTIVE and will alter your wiki." + @echo "DO NOT RUN THESE TESTS on a production wiki." + @echo "" + @echo "Until the default suites are made non-destructive, you can run" + @echo "the destructive tests like so:" + @echo "" + @echo " make destructive" + @echo "" + +destructive: phpunit phpunit: ${PU} diff --git a/maintenance/tests/phpunit/README b/maintenance/tests/phpunit/README index f0f84c3961..ce78270dc0 100644 --- a/maintenance/tests/phpunit/README +++ b/maintenance/tests/phpunit/README @@ -3,6 +3,12 @@ Some quickie unit tests done with the PHPUnit testing framework. To run the test suite, run 'make test' in this (maintenance/tests/phpunit) directory. +=== WARNING === + +The current versions of some of these tests are DESTRUCTIVE AND WILL ALTER +YOUR WIKI'S CONTENTS. DO NOT RUN ON A PRODUCTION SYSTEM OR ONE WHERE YOU +NEED TO RETAIN YOUR DATA. + === Installation === PHPUnit is no longer maintained by PEAR. To get the current version of diff --git a/maintenance/tests/phpunit/TODO b/maintenance/tests/phpunit/TODO index b9f3a3a6e5..76f38c1dcc 100644 --- a/maintenance/tests/phpunit/TODO +++ b/maintenance/tests/phpunit/TODO @@ -1,5 +1,9 @@ == Things To Do == +* DEFAULT TESTS NEED TO MADE NON-DESTRUCTIVE. Any destructive tests which alter the contents of the live wiki need to +be protected with an explicit confirmation so people exploring their system don't accidentally destroy their main page +or register user accounts with default passwords. + * Most of the tests are named poorly; naming should describe a use case in story-like language, not simply identify the unit under test. An example would be the difference between testCalculate and testAddingIntegersTogetherWorks. * Many of the tests make multiple assertions, and are thus not unitary tests. By using data-providers and more use-case -- 2.20.1