diff options
| author | Nils Adermann <naderman@naderman.de> | 2008-11-24 00:27:18 +0000 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2008-11-24 00:27:18 +0000 |
| commit | c8cba06910c1f30469cc301c03afa1d5a431c568 (patch) | |
| tree | cb783744224e5ba05213faaf105eafc6dff5bc12 /tests | |
| parent | bcfcf9b0483b2b37ed0698f9e943e9a241ccb5d0 (diff) | |
| download | forums-c8cba06910c1f30469cc301c03afa1d5a431c568.tar forums-c8cba06910c1f30469cc301c03afa1d5a431c568.tar.gz forums-c8cba06910c1f30469cc301c03afa1d5a431c568.tar.bz2 forums-c8cba06910c1f30469cc301c03afa1d5a431c568.tar.xz forums-c8cba06910c1f30469cc301c03afa1d5a431c568.zip | |
- updated security/redirect test to use new framework functionality
git-svn-id: file:///svn/phpbb/trunk@9104 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/security/redirect.php | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/tests/security/redirect.php b/tests/security/redirect.php index 0cf67b7aef..24ad60b0d1 100644 --- a/tests/security/redirect.php +++ b/tests/security/redirect.php @@ -10,8 +10,7 @@ define('IN_PHPBB', true); -require_once 'PHPUnit/Framework.php'; -require_once 'PHPUnit/Extensions/OutputTestCase.php'; +require_once 'test_framework/framework.php'; define('PHPBB_ROOT_PATH', './../phpBB/'); define('PHP_EXT', 'php'); @@ -19,10 +18,8 @@ define('PHP_EXT', 'php'); require_once '../phpBB/includes/functions.php'; require_once '../phpBB/includes/session.php'; -class phpbb_security_redirect_test extends PHPUnit_Extensions_OutputTestCase +class phpbb_security_redirect_test extends phpbb_test_case { - protected $error_triggered = false; - public static function provider() { // array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) @@ -44,49 +41,24 @@ class phpbb_security_redirect_test extends PHPUnit_Extensions_OutputTestCase } /** - * Own error handler to catch trigger_error() calls within phpBB - */ - public function own_error_handler($errno, $errstr, $errfile, $errline) - { - echo $errstr; - $this->error_triggered = true; - } - - /** * @dataProvider provider */ public function test_redirect($test, $expected_error, $expected_result) { global $user; - set_error_handler(array($this, 'own_error_handler')); - $result = redirect($test, true); - - // If we expect no error and a returned result, we set the output string to be expected and check if an error was triggered (then fail instantly) - if ($expected_error === false) + if ($expected_error !== false) { - $this->expectOutputString($expected_result); - print $result; - - if ($this->error_triggered) - { - $this->fail(); - } + $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); } - // If we expect an error, we set the expected output string to the error and check if there was an error triggered. - else - { - $this->expectOutputString($expected_error); - if (!$this->error_triggered) - { - $this->fail(); - } + $result = redirect($test, true); - $this->error_triggered = false; + // only verify result if we did not expect an error + if ($expected_error === false) + { + $this->assertEquals($expected_result, $result); } - - restore_error_handler(); } } |
