Skip to content

Commit 1f73285

Browse files
committed
chore: cleanup tests
1 parent 83b6090 commit 1f73285

16 files changed

+29
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ phpunit.phar
33
phpunit.phar.asc
44
composer.phar
55
composer.lock
6+
.phpunit.result.cache

tests/JWKTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,34 @@ public function testParsePrivateKey()
3838
'UnexpectedValueException',
3939
'RSA private keys are not supported'
4040
);
41-
41+
4242
$jwkSet = json_decode(
43-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
43+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
4444
true
4545
);
4646
$jwkSet['keys'][0]['d'] = 'privatekeyvalue';
47-
47+
4848
JWK::parseKeySet($jwkSet);
4949
}
50-
50+
5151
public function testParseKeyWithEmptyDValue()
5252
{
5353
$jwkSet = json_decode(
54-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
54+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
5555
true
5656
);
57-
57+
5858
// empty or null values are ok
5959
$jwkSet['keys'][0]['d'] = null;
60-
60+
6161
$keys = JWK::parseKeySet($jwkSet);
6262
$this->assertTrue(is_array($keys));
6363
}
6464

6565
public function testParseJwkKeySet()
6666
{
6767
$jwkSet = json_decode(
68-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
68+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
6969
true
7070
);
7171
$keys = JWK::parseKeySet($jwkSet);
@@ -93,7 +93,7 @@ public function testParseJwkKeySet_empty()
9393
*/
9494
public function testDecodeByJwkKeySetTokenExpired()
9595
{
96-
$privKey1 = file_get_contents(__DIR__ . '/rsa1-private.pem');
96+
$privKey1 = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
9797
$payload = array('exp' => strtotime('-1 hour'));
9898
$msg = JWT::encode($payload, $privKey1, 'RS256', 'jwk1');
9999

@@ -107,7 +107,7 @@ public function testDecodeByJwkKeySetTokenExpired()
107107
*/
108108
public function testDecodeByJwkKeySet()
109109
{
110-
$privKey1 = file_get_contents(__DIR__ . '/rsa1-private.pem');
110+
$privKey1 = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
111111
$payload = array('sub' => 'foo', 'exp' => strtotime('+10 seconds'));
112112
$msg = JWT::encode($payload, $privKey1, 'RS256', 'jwk1');
113113

@@ -121,7 +121,7 @@ public function testDecodeByJwkKeySet()
121121
*/
122122
public function testDecodeByMultiJwkKeySet()
123123
{
124-
$privKey2 = file_get_contents(__DIR__ . '/rsa2-private.pem');
124+
$privKey2 = file_get_contents(__DIR__ . '/data/rsa2-private.pem');
125125
$payload = array('sub' => 'bar', 'exp' => strtotime('+10 seconds'));
126126
$msg = JWT::encode($payload, $privKey2, 'RS256', 'jwk2');
127127

tests/JWTTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function testInvalidEdDsaEncodeDecode()
316316
public function testRSEncodeDecodeWithPassphrase()
317317
{
318318
$privateKey = openssl_pkey_get_private(
319-
file_get_contents(__DIR__ . '/rsa-with-passphrase.pem'),
319+
file_get_contents(__DIR__ . '/data/rsa-with-passphrase.pem'),
320320
'passphrase'
321321
);
322322

@@ -375,18 +375,18 @@ public function testArrayAccessKIDChooserWithKeyObject()
375375
public function provideEncodeDecode()
376376
{
377377
return array(
378-
array(__DIR__ . '/ecdsa-private.pem', __DIR__ . '/ecdsa-public.pem', 'ES256'),
379-
array(__DIR__ . '/ecdsa384-private.pem', __DIR__ . '/ecdsa384-public.pem', 'ES384'),
380-
array(__DIR__ . '/rsa1-private.pem', __DIR__ . '/rsa1-public.pub', 'RS512'),
381-
array(__DIR__ . '/ed25519-1.sec', __DIR__ . '/ed25519-1.pub', 'EdDSA'),
378+
array(__DIR__ . '/data/ecdsa-private.pem', __DIR__ . '/data/ecdsa-public.pem', 'ES256'),
379+
array(__DIR__ . '/data/ecdsa384-private.pem', __DIR__ . '/data/ecdsa384-public.pem', 'ES384'),
380+
array(__DIR__ . '/data/rsa1-private.pem', __DIR__ . '/data/rsa1-public.pub', 'RS512'),
381+
array(__DIR__ . '/data/ed25519-1.sec', __DIR__ . '/data/ed25519-1.pub', 'EdDSA'),
382382
);
383383
}
384384

385385
public function testEncodeDecodeWithResource()
386386
{
387-
$pem = file_get_contents(__DIR__ . '/rsa1-public.pub');
387+
$pem = file_get_contents(__DIR__ . '/data/rsa1-public.pub');
388388
$resource = openssl_pkey_get_public($pem);
389-
$privateKey = file_get_contents(__DIR__ . '/rsa1-private.pem');
389+
$privateKey = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
390390

391391
$payload = array('foo' => 'bar');
392392
$encoded = JWT::encode($payload, $privateKey, 'RS512');

tests/autoload.php.dist

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/bootstrap.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?php
22

3-
if (file_exists($file = __DIR__ . '/autoload.php')) {
4-
require_once $file;
5-
} elseif (file_exists($file = __DIR__ . '/autoload.php.dist')) {
3+
if (file_exists($file = __DIR__ . '/../vendor/autoload.php')) {
64
require_once $file;
5+
} else {
6+
die('Unable to find autoload.php file, please use composer to load dependencies:
7+
8+
wget http://getcomposer.org/composer.phar
9+
php composer.phar install
10+
11+
Visit http://getcomposer.org/ for more information.
12+
13+
');
714
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)