summaryrefslogtreecommitdiffstats
path: root/tests/JWTTest.php
diff options
context:
space:
mode:
authorBrendan Abbott <brendan@vuid.com>2014-11-13 12:46:11 +1000
committerBrendan Abbott <brendan@vuid.com>2014-11-13 12:46:11 +1000
commitea4db8dbf2d74ed75ff1e5c89ac42e55a9ff1d6f (patch)
tree2e77e77faec11516aedf6914cd92f816350064fa /tests/JWTTest.php
parent0b01cd0b1727c4652b4529289ddddb599ef6ca6a (diff)
downloadphp-jwt-ea4db8dbf2d74ed75ff1e5c89ac42e55a9ff1d6f.zip
php-jwt-ea4db8dbf2d74ed75ff1e5c89ac42e55a9ff1d6f.tar.gz
php-jwt-ea4db8dbf2d74ed75ff1e5c89ac42e55a9ff1d6f.tar.bz2
Add specific exceptions for checking claims. Fix bad tests for exp and nbf. RE: firebase/php-jwt#20
Diffstat (limited to 'tests/JWTTest.php')
-rw-r--r--tests/JWTTest.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/JWTTest.php b/tests/JWTTest.php
index 0a739f8..d9abe4e 100644
--- a/tests/JWTTest.php
+++ b/tests/JWTTest.php
@@ -37,22 +37,22 @@ class JWTTest extends PHPUnit_Framework_TestCase
public function testExpiredToken()
{
- $this->setExpectedException('UnexpectedValueException');
+ $this->setExpectedException('ExpiredException');
$payload = array(
"message" => "abc",
"exp" => time() - 20); // time in the past
$encoded = JWT::encode($payload, 'my_key');
- JWT::decode($encoded);
+ JWT::decode($encoded, 'my_key');
}
public function testTooEarlyToken()
{
- $this->setExpectedException('UnexpectedValueException');
+ $this->setExpectedException('TooEarlyException');
$payload = array(
"message" => "abc",
"nbf" => time() + 20); // time in the past
$encoded = JWT::encode($payload, 'my_key');
- JWT::decode($encoded);
+ JWT::decode($encoded, 'my_key');
}
public function testValidToken()
@@ -82,7 +82,7 @@ class JWTTest extends PHPUnit_Framework_TestCase
"message" => "abc",
"exp" => time() + 20); // time in the future
$encoded = JWT::encode($payload, 'my_key');
- $this->setExpectedException('UnexpectedValueException');
+ $this->setExpectedException('SignatureInvalidException');
$decoded = JWT::decode($encoded, 'my_key2');
}