diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-10 16:24:19 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-10 16:24:19 +0100 |
| commit | 60bd1edcb5e5992e6e693d0f68db47e678f7d54a (patch) | |
| tree | dffc10407f0ef6a85d034415d7e30407ccf3f21a /tests/test_framework | |
| parent | d9567f121b11d3f5b068b85e7c862c27fc495005 (diff) | |
| download | forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.gz forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.bz2 forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.tar.xz forums-60bd1edcb5e5992e6e693d0f68db47e678f7d54a.zip | |
[develop-olympus] Backported 3.1 unit tests to 3.0.
Start adding unit tests for bugs you fix! Tests for anything are
welcome really. We have to work on these a lot.
Diffstat (limited to 'tests/test_framework')
| -rw-r--r-- | tests/test_framework/framework.php | 36 | ||||
| -rw-r--r-- | tests/test_framework/phpbb_test_case.php | 37 |
2 files changed, 73 insertions, 0 deletions
diff --git a/tests/test_framework/framework.php b/tests/test_framework/framework.php new file mode 100644 index 0000000000..5913d20ca0 --- /dev/null +++ b/tests/test_framework/framework.php @@ -0,0 +1,36 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +define('IN_PHPBB', true); +$phpbb_root_path = '../phpBB/'; +$phpEx = 'php'; +$table_prefix = ''; + +// If we are on PHP >= 6.0.0 we do not need some code +if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) +{ + define('STRIP', false); +} +else +{ + @set_magic_quotes_runtime(0); + define('STRIP', (get_magic_quotes_gpc()) ? true : false); +} + +require_once $phpbb_root_path . 'includes/constants.php'; + +// require at least PHPUnit 3.3.0 +require_once 'PHPUnit/Runner/Version.php'; +if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<')) +{ + trigger_error('PHPUnit >= 3.3.0 required'); +} + +require_once 'PHPUnit/Framework.php'; +require_once 'test_framework/phpbb_test_case.php'; diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php new file mode 100644 index 0000000000..3cf2a9d442 --- /dev/null +++ b/tests/test_framework/phpbb_test_case.php @@ -0,0 +1,37 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2008 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +class phpbb_test_case extends PHPUnit_Framework_TestCase +{ + protected $expectedTriggerError = false; + + public function setExpectedTriggerError($errno, $message = '') + { + $exceptionName = ''; + switch ($errno) + { + case E_NOTICE: + case E_STRICT: + PHPUnit_Framework_Error_Notice::$enabled = true; + $exceptionName = 'PHPUnit_Framework_Error_Notice'; + break; + + case E_WARNING: + PHPUnit_Framework_Error_Warning::$enabled = true; + $exceptionName = 'PHPUnit_Framework_Error_Warning'; + break; + + default: + $exceptionName = 'PHPUnit_Framework_Error'; + break; + } + $this->expectedTriggerError = true; + $this->setExpectedException($exceptionName, (string) $message, $errno); + } +} |
