Skip to content

Commit 2154a8b

Browse files
committed
added support for class alias if php ver > 7
to fix alias issues with 5.3
1 parent 9cdb56d commit 2154a8b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/csrfprotector_test.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
date_default_timezone_set('UTC');
33
require_once __DIR__ .'/../libs/csrf/csrfprotector.php';
44

5-
if (!class_exists('\PHPUnit\Framework\TestCase', true)) {
6-
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
7-
} elseif (!class_exists('\PHPUnit_Framework_TestCase', true)) {
5+
if (intval(phpversion('tidy')) >= 7 && !class_exists('\PHPUnit_Framework_TestCase', true)) {
86
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
97
}
108

@@ -79,8 +77,11 @@ public function setUp()
7977
$_SERVER['REQUEST_SCHEME'] = 'http'; // For authorizePost
8078
$_SERVER['HTTP_HOST'] = 'test'; // For isUrlAllowed
8179
$_SERVER['PHP_SELF'] = '/index.php'; // For authorizePost
82-
$_POST[csrfprotector::$config['CSRFP_TOKEN']] = $_GET[csrfprotector::$config['CSRFP_TOKEN']] = '123';
83-
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('abc'); //token mismatch - leading to failed validation
80+
$_POST[csrfprotector::$config['CSRFP_TOKEN']]
81+
= $_GET[csrfprotector::$config['CSRFP_TOKEN']] = '123';
82+
83+
//token mismatch - leading to failed validation
84+
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('abc');
8485
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
8586
$_SERVER['HTTPS'] = null;
8687

@@ -106,7 +107,6 @@ public function tearDown()
106107
*/
107108
public function testRefreshToken()
108109
{
109-
110110
$val = $_COOKIE[csrfprotector::$config['CSRFP_TOKEN']] = '123abcd';
111111
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('123abcd');
112112
csrfProtector::$config['tokenLength'] = 20;

0 commit comments

Comments
 (0)