Skip to content

Commit

Permalink
dummy config.php created for each test
Browse files Browse the repository at this point in the history
  • Loading branch information
mebjas committed Jul 25, 2014
1 parent 8d18a56 commit e130f7c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/csrfprotector_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public function setUp()
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';

$this->config = include(__DIR__ .'/../libs/config.sample.php');

// Create an instance of config file -- for testing
$data = file_get_contents(__DIR__ .'/../libs/config.sample.php');
file_put_contents(__DIR__ .'/../libs/config.php', $data);
}

/**
* tearDown()
*/
public function tearDown()
{
unlink(__DIR__ .'/../libs/config.php');
}

/**
Expand All @@ -79,13 +91,12 @@ public function testRefreshToken()
*/
public function testUseCachedVersion()
{
if (filemtime(__DIR__ .'/../js/csrfprotector.js') < filemtime(__DIR__ .'/../libs/config.sample.php')) {
//$this->assertFalse(csrfprotector::useCachedVersion());
if (filemtime(__DIR__ .'/../js/csrfprotector.js') < filemtime(__DIR__ .'/../libs/config.php')) {
$this->assertFalse(csrfprotector::useCachedVersion());
} else {
//$this->assertTrue(csrfprotector::useCachedVersion());
$this->assertTrue(csrfprotector::useCachedVersion());
}
$this->markTestSkipped('Cant test as config.php doesn\'t exist by default');


$temp = csrfprotector::$config['jsPath'];
csrfprotector::$config['jsPath'] = 'some_random_name';
$this->assertFalse(csrfprotector::useCachedVersion());
Expand Down Expand Up @@ -312,8 +323,6 @@ public function testGenerateAuthToken()
*/
public function testob_handler()
{
$this->markTestSkipped('Config.php doesn\'t exist -- replaced with config.sample.php ');
return;
csrfprotector::$config['disabledJavascriptMessage'] = 'test message';
csrfprotector::$config['jsUrl'] = 'http://localhost/test/csrf/js/csrfprotector.js';

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

Expand Down

0 comments on commit e130f7c

Please sign in to comment.