38 lines
805 B
PHP
38 lines
805 B
PHP
<?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());
|
|
|
|
}
|
|
} |