public function testDeserialize()
{
$jwt = 'a.b.c';
// Configure encoding
$this->encoding->expects($this->at(0))->method('decode')->with('a')->will($this->returnValue('{"a":"1"}'));
$this->encoding->expects($this->at(1))->method('decode')->with('b')->will($this->returnValue('{"b":"2"}'));
$this->encoding->expects($this->at(2))->method('decode')->with('c')->will($this->returnValue('c'));
// Configure headers
$headerParameter = $this->getMockBuilder('Emarref\\Jwt\\HeaderParameter\\Custom')->getMock();
$headerParameter->expects($this->once())->method('setValue')->with('1');
$headerParameter->expects($this->once())->method('getValue')->will($this->returnValue('1'));
$headerParameter->expects($this->exactly(2))->method('getName')->will($this->returnValue('a'));
$this->headerParameterFactory->expects($this->once())->method('get')->with('a')->will($this->returnValue($headerParameter));
// Configure claims
$claim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\PrivateClaim')->getMock();
$claim->expects($this->once())->method('setValue')->with('2');
$claim->expects($this->once())->method('getValue')->will($this->returnValue('2'));
$claim->expects($this->exactly(2))->method('getName')->will($this->returnValue('b'));
$this->claimFactory->expects($this->once())->method('get')->with('b')->will($this->returnValue($claim));
// Assert
$token = $this->serializer->deserialize($jwt);
$this->assertSame('{"a":"1"}', $token->getHeader()->jsonSerialize());
$this->assertSame('{"b":"2"}', $token->getPayload()->jsonSerialize());
$this->assertSame('c', $token->getSignature());
}