* @since 0.1.0 */ class EncoderTest extends \PHPUnit_Framework_TestCase { /** * @test * * @covers Lcobucci\JWT\Parsing\Encoder::jsonEncode */ public function jsonEncodeMustReturnAJSONString() { $encoder = new Encoder(); $this->assertEquals('{"test":"test"}', $encoder->jsonEncode(['test' => 'test'])); } /** * @test * * @covers Lcobucci\JWT\Parsing\Encoder::jsonEncode * * @expectedException \RuntimeException */ public function jsonEncodeMustRaiseExceptionWhenAnErrorHasOccured() { $encoder = new Encoder(); $encoder->jsonEncode("\xB1\x31"); } /** * @test * * @covers Lcobucci\JWT\Parsing\Encoder::base64UrlEncode */ public function base64UrlEncodeMustReturnAnUrlSafeBase64() { $data = base64_decode('0MB2wKB+L3yvIdzeggmJ+5WOSLaRLTUPXbpzqUe0yuo='); $encoder = new Encoder(); $this->assertEquals('0MB2wKB-L3yvIdzeggmJ-5WOSLaRLTUPXbpzqUe0yuo', $encoder->base64UrlEncode($data)); } }