diff options
author | Aaron Hedges <aaron@vimeo.com> | 2015-07-01 14:18:43 -0400 |
---|---|---|
committer | Aaron Hedges <aaron@vimeo.com> | 2015-07-01 14:18:43 -0400 |
commit | 3a6b01aab96aeab6d360f42729d89122a7314d33 (patch) | |
tree | c4ca104e8315242173bd3bdf16f3225d3856b04a | |
parent | d4fa25d9afd52cc1cdfe00b9d3dac33b30aa3877 (diff) | |
download | php-jwt-3a6b01aab96aeab6d360f42729d89122a7314d33.zip php-jwt-3a6b01aab96aeab6d360f42729d89122a7314d33.tar.gz php-jwt-3a6b01aab96aeab6d360f42729d89122a7314d33.tar.bz2 |
fix unexpectedvalueexceptions and add unit tests
-rw-r--r-- | src/JWT.php | 1 | ||||
-rw-r--r-- | tests/JWTTest.php | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/JWT.php b/src/JWT.php index 855b742..d1a108f 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -2,6 +2,7 @@ namespace Firebase\JWT; use \DomainException; +use \UnexpectedValueException; use \DateTime; /** diff --git a/tests/JWTTest.php b/tests/JWTTest.php index 6c996b2..f06f34e 100644 --- a/tests/JWTTest.php +++ b/tests/JWTTest.php @@ -235,4 +235,10 @@ class JWTTest extends PHPUnit_Framework_TestCase $msg = JWT::encode('abc', 'my_key', 'HS256', null, array('cty' => 'test-eit;v=1')); $this->assertEquals(JWT::decode($msg, 'my_key', array('HS256')), 'abc'); } + + public function testInvalidSegmentCount() + { + $this->setExpectedException('UnexpectedValueException'); + JWT::decode('brokenheader.brokenbody', 'my_key', array('HS256')); + } } |