Skip to content

Commit

Permalink
Push missing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Gnatyo committed Aug 18, 2017
1 parent 597c088 commit 01885e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/.idea/
/tests/
/var/
/vendor/

Expand Down
39 changes: 39 additions & 0 deletions tests/FreeElephants/Jwt/FirebaseJwtAdapterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php


namespace FreeElephants\Jwt;


use FreeElephants\Jwt\Exception\InvalidArgumentException;
use FreeElephants\Jwt\Exception\OutOfBoundsException;
use PHPUnit\Framework\TestCase;

class FirebaseJwtAdapterTest extends TestCase
{

public function testDecode()
{
$decoder = new FirebaseJwtDecoderAdapter('example_key', ['HS256', 'HS384']);

$signature = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoaWQiOiJqb2UiLCJhdXRocm9sZXMiOlsic3Vic2NyaWJlciJdfQ.Lxyy1H3gfs1FV5UJLGxfAYvS1TJeiJhVInu5GIlccg4';
$expected = new \stdClass();
$expected->authid = 'joe';
$expected->authroles = [
'subscriber'
];

$this->assertEquals($expected, $decoder->decode($signature));
}

public function testUseEmptyAllowedAlgorithmsListInvalidArgumentException()
{
$this->expectException(InvalidArgumentException::class);
new FirebaseJwtDecoderAdapter('example_key', []);
}

public function testSetAllowedAlgorithmsOutOfBoundsException()
{
$this->expectException(OutOfBoundsException::class);
new FirebaseJwtDecoderAdapter('example_key', ['foo bar']);
}
}

0 comments on commit 01885e3

Please sign in to comment.