Emarref\Jwt\Serialization\CompactTest::testSerialize PHP Метод

testSerialize() публичный Метод

public testSerialize ( )
    public function testSerialize()
    {
        // Configure payload
        $headerParameters = $this->getMockBuilder('Emarref\\Jwt\\Token\\PropertyList')->getMock();
        $headerParameters->expects($this->once())->method('jsonSerialize')->will($this->returnValue('{"a":"1"}'));
        $header = $this->getMockBuilder('Emarref\\Jwt\\Token\\Header')->getMock();
        $header->expects($this->once())->method('getParameters')->will($this->returnValue($headerParameters));
        // Configure payload
        $claims = $this->getMockBuilder('Emarref\\Jwt\\Token\\PropertyList')->getMock();
        $claims->expects($this->once())->method('jsonSerialize')->will($this->returnValue('{"b":"2"}'));
        $payload = $this->getMockBuilder('Emarref\\Jwt\\Token\\Payload')->getMock();
        $payload->expects($this->once())->method('getClaims')->will($this->returnValue($claims));
        // Configure token
        $token = $this->getMockBuilder('Emarref\\Jwt\\Token')->getMock();
        $token->expects($this->once())->method('getHeader')->will($this->returnValue($header));
        $token->expects($this->once())->method('getPayload')->will($this->returnValue($payload));
        $token->expects($this->once())->method('getSignature')->will($this->returnValue('c'));
        // Configure encoding
        $this->encoding->expects($this->exactly(3))->method('encode')->will($this->returnValueMap([['{"a":"1"}', 'a'], ['{"b":"2"}', 'b'], ['c', 'c']]));
        $jwt = $this->serializer->serialize($token);
        $this->assertSame('a.b.c', $jwt);
    }