diff options
author | RobThree <rob@devcorner.nl> | 2017-02-17 14:59:44 +0100 |
---|---|---|
committer | RobThree <rob@devcorner.nl> | 2017-02-17 14:59:44 +0100 |
commit | c114772d014beb705f6a0639369a3324edbef651 (patch) | |
tree | 0ecf560163175286d5e69bc67454b013f5923503 | |
parent | 9735116635f2394273b716db0c5165a5ca09037e (diff) | |
download | TwoFactorAuth-c114772d014beb705f6a0639369a3324edbef651.zip TwoFactorAuth-c114772d014beb705f6a0639369a3324edbef651.tar.gz TwoFactorAuth-c114772d014beb705f6a0639369a3324edbef651.tar.bz2 |
* Fix PHP 5.3 array syntax in unittests
-rw-r--r-- | lib/Providers/Time/HttpTimeProvider.php | 18 | ||||
-rw-r--r-- | tests/TwoFactorAuthTest.php | 10 |
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/Providers/Time/HttpTimeProvider.php b/lib/Providers/Time/HttpTimeProvider.php index db75db0..d50c6d8 100644 --- a/lib/Providers/Time/HttpTimeProvider.php +++ b/lib/Providers/Time/HttpTimeProvider.php @@ -17,23 +17,23 @@ class HttpTimeProvider implements ITimeProvider public function getTime() { try { $host = parse_url($this->url, PHP_URL_HOST); - $context = stream_context_create([ - 'http' => [ + $context = stream_context_create(array( + 'http' => array( 'method' => 'HEAD', 'follow_location' => false, 'ignore_errors' => true, 'max_redirects' => 0, 'request_fulluri' => true, - 'header' => [ + 'header' => array( 'Connection: close', 'User-agent: TwoFactorAuth HttpTimeProvider (https://github.com/RobThree/TwoFactorAuth)' - ] - ], - 'ssl' => [ + ) + ), + 'ssl' => array( 'SNI_enabled' => true, - 'SNI_server_name' => $host - ] - ]); + 'peer_name' => $host + ) + )); $fd = fopen($this->url, 'rb', false, $context); $headers = stream_get_meta_data($fd)['wrapper_data']; fclose($fd); diff --git a/tests/TwoFactorAuthTest.php b/tests/TwoFactorAuthTest.php index b81ca57..587b19b 100644 --- a/tests/TwoFactorAuthTest.php +++ b/tests/TwoFactorAuthTest.php @@ -101,7 +101,7 @@ class TwoFactorAuthTest extends PHPUnit_Framework_TestCase $tpr2 = new TestTimeProvider(128); $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime([$tpr2]); // 128 - 123 = 5 => within default leniency + $tfa->ensureCorrectTime(array($tpr2)); // 128 - 123 = 5 => within default leniency } /** @@ -112,23 +112,23 @@ class TwoFactorAuthTest extends PHPUnit_Framework_TestCase $tpr2 = new TestTimeProvider(124); $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1', null, null, $tpr1); - $tfa->ensureCorrectTime([$tpr2], 0); // We force a leniency of 0, 124-123 = 1 so this should throw + $tfa->ensureCorrectTime(array($tpr2), 0); // We force a leniency of 0, 124-123 = 1 so this should throw } public function testEnsureDefaultTimeProviderReturnsCorrectTime() { $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime([new TestTimeProvider(time())], 1); // Use a leniency of 1, should the time change between both time() calls + $tfa->ensureCorrectTime(array(new TestTimeProvider(time())), 1); // Use a leniency of 1, should the time change between both time() calls } public function testEnsureAllTimeProvidersReturnCorrectTime() { $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); - $tfa->ensureCorrectTime([ + $tfa->ensureCorrectTime(array( new RobThree\Auth\Providers\Time\ConvertUnixTimeDotComTimeProvider(), new RobThree\Auth\Providers\Time\HttpTimeProvider(), // Uses google.com by default new RobThree\Auth\Providers\Time\HttpTimeProvider('https://github.com'), new RobThree\Auth\Providers\Time\HttpTimeProvider('https://yahoo.com'), - ]); + )); } public function testVerifyCodeWorksCorrectly() { |