Skip to content

Commit e130f7c

Browse files
committed
dummy config.php created for each test
1 parent 8d18a56 commit e130f7c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/csrfprotector_test.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ public function setUp()
5353
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
5454

5555
$this->config = include(__DIR__ .'/../libs/config.sample.php');
56+
57+
// Create an instance of config file -- for testing
58+
$data = file_get_contents(__DIR__ .'/../libs/config.sample.php');
59+
file_put_contents(__DIR__ .'/../libs/config.php', $data);
60+
}
61+
62+
/**
63+
* tearDown()
64+
*/
65+
public function tearDown()
66+
{
67+
unlink(__DIR__ .'/../libs/config.php');
5668
}
5769

5870
/**
@@ -79,13 +91,12 @@ public function testRefreshToken()
7991
*/
8092
public function testUseCachedVersion()
8193
{
82-
if (filemtime(__DIR__ .'/../js/csrfprotector.js') < filemtime(__DIR__ .'/../libs/config.sample.php')) {
83-
//$this->assertFalse(csrfprotector::useCachedVersion());
94+
if (filemtime(__DIR__ .'/../js/csrfprotector.js') < filemtime(__DIR__ .'/../libs/config.php')) {
95+
$this->assertFalse(csrfprotector::useCachedVersion());
8496
} else {
85-
//$this->assertTrue(csrfprotector::useCachedVersion());
97+
$this->assertTrue(csrfprotector::useCachedVersion());
8698
}
87-
$this->markTestSkipped('Cant test as config.php doesn\'t exist by default');
88-
99+
89100
$temp = csrfprotector::$config['jsPath'];
90101
csrfprotector::$config['jsPath'] = 'some_random_name';
91102
$this->assertFalse(csrfprotector::useCachedVersion());
@@ -312,8 +323,6 @@ public function testGenerateAuthToken()
312323
*/
313324
public function testob_handler()
314325
{
315-
$this->markTestSkipped('Config.php doesn\'t exist -- replaced with config.sample.php ');
316-
return;
317326
csrfprotector::$config['disabledJavascriptMessage'] = 'test message';
318327
csrfprotector::$config['jsUrl'] = 'http://localhost/test/csrf/js/csrfprotector.js';
319328

@@ -342,8 +351,6 @@ public function testob_handler()
342351
*/
343352
public function testob_handler_positioning()
344353
{
345-
$this->markTestSkipped('Config.php doesn\'t exist -- replaced with config.sample.php ');
346-
return;
347354
csrfprotector::$config['disabledJavascriptMessage'] = 'test message';
348355
csrfprotector::$config['jsUrl'] = 'http://localhost/test/csrf/js/csrfprotector.js';
349356

0 commit comments

Comments
 (0)