* @since 0.1.0 */ class DecoderTest extends \PHPUnit_Framework_TestCase { /** * @test * * @covers Lcobucci\JWT\Parsing\Decoder::jsonDecode */ public function jsonDecodeMustReturnTheDecodedData() { $decoder = new Decoder(); $this->assertEquals( (object) ['test' => 'test'], $decoder->jsonDecode('{"test":"test"}') ); } /** * @test * * @covers Lcobucci\JWT\Parsing\Decoder::jsonDecode * * @expectedException \RuntimeException */ public function jsonDecodeMustRaiseExceptionWhenAnErrorHasOccured() { $decoder = new Decoder(); $decoder->jsonDecode('{"test":\'test\'}'); } /** * @test * * @covers Lcobucci\JWT\Parsing\Decoder::base64UrlDecode */ public function base64UrlDecodeMustReturnTheRightData() { $data = base64_decode('0MB2wKB+L3yvIdzeggmJ+5WOSLaRLTUPXbpzqUe0yuo='); $decoder = new Decoder(); $this->assertEquals($data, $decoder->base64UrlDecode('0MB2wKB-L3yvIdzeggmJ-5WOSLaRLTUPXbpzqUe0yuo')); } }