Initial commit
This commit is contained in:
38
tests/JwtTokenTest.php
Normal file
38
tests/JwtTokenTest.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\SimpleJwt;
|
||||
|
||||
use NoccyLabs\SimpleJwt\Key\JwtPlaintextKey;
|
||||
|
||||
class JwtTokenTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testGeneratingTokens()
|
||||
{
|
||||
$key = new JwtPlaintextKey("test");
|
||||
|
||||
$tok = new JwtToken($key);
|
||||
$tok->addClaim("foo", true);
|
||||
|
||||
$token = $tok->getSignedToken();
|
||||
|
||||
$this->assertNotNull($token);
|
||||
$this->assertTrue($tok->isGenerated());
|
||||
}
|
||||
|
||||
public function testParsingTokens()
|
||||
{
|
||||
$key = new JwtPlaintextKey("test");
|
||||
|
||||
$tok = new JwtToken($key);
|
||||
$tok->addClaim("foo", true);
|
||||
|
||||
$token = $tok->getSignedToken();
|
||||
|
||||
$parsed = new JwtToken($key, $token);
|
||||
|
||||
$this->assertTrue($parsed->isValid());
|
||||
$this->assertFalse($parsed->isGenerated());
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user