Skip to content

Commit 9cdb56d

Browse files
committed
Added support for phpunit+php7
1 parent c275a1a commit 9cdb56d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/csrfprotector_test.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
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)) {
8+
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
9+
}
10+
511
/**
612
* Wrapper class for testing purpose
713
*/
@@ -79,12 +85,12 @@ public function setUp()
7985
$_SERVER['HTTPS'] = null;
8086

8187
$this->config = include(__DIR__ .'/../libs/config.sample.php');
82-
88+
8389
// Create an instance of config file -- for testing
8490
$data = file_get_contents(__DIR__ .'/../libs/config.sample.php');
85-
file_put_contents(__DIR__ .'/../libs/config.php', $data);
91+
file_put_contents(__DIR__ .'/../libs/config.php', $data);
8692

87-
if (!defined('__TESTING_CSRFP__')) define('__TESTING_CSRFP__', true);
93+
if (!defined('__TESTING_CSRFP__')) define('__TESTING_CSRFP__', true);
8894
}
8995

9096
/**
@@ -100,7 +106,7 @@ public function tearDown()
100106
*/
101107
public function testRefreshToken()
102108
{
103-
109+
104110
$val = $_COOKIE[csrfprotector::$config['CSRFP_TOKEN']] = '123abcd';
105111
$_SESSION[csrfprotector::$config['CSRFP_TOKEN']] = array('123abcd');
106112
csrfProtector::$config['tokenLength'] = 20;
@@ -439,4 +445,4 @@ public function testModCSRFPEnabledException()
439445
$this->assertTrue($temp == $_SESSION[csrfprotector::$config['CSRFP_TOKEN']][0]);
440446
$this->assertTrue($temp == $_COOKIE[csrfprotector::$config['CSRFP_TOKEN']]);
441447
}
442-
}
448+
}

0 commit comments

Comments
 (0)