Inheritance: implements JsonSerializable
Example #1
0
 public function testValid()
 {
     $future = new \DateTime('5 minutes', new \DateTimeZone('UTC'));
     $expirationClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\Expiration')->getMock();
     $expirationClaim->expects($this->once())->method('getValue')->will($this->returnValue($future->getTimestamp()));
     $this->payload->expects($this->once())->method('findClaimByName')->will($this->returnValue($expirationClaim));
     $this->verifier->verify($this->token);
 }
Example #2
0
 public function testValid()
 {
     $past = new \DateTime('5 minutes ago', new \DateTimeZone('UTC'));
     $notBeforeClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\NotBefore')->getMock();
     $notBeforeClaim->expects($this->exactly(2))->method('getValue')->will($this->returnValue($past->getTimestamp()));
     $this->payload->expects($this->once())->method('findClaimByName')->with(NotBefore::NAME)->will($this->returnValue($notBeforeClaim));
     $this->verifier->verify($this->token);
 }
Example #3
0
 public function testStringAudience()
 {
     $audienceClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\Audience')->getMock();
     $audienceClaim->expects($this->once())->method('getValue')->will($this->returnValue('urn://audienceone'));
     $this->payload->expects($this->once())->method('findClaimByName')->with(Claim\Audience::NAME)->will($this->returnValue($audienceClaim));
     $this->token->expects($this->once())->method('getPayload')->will($this->returnValue($this->payload));
     $verifier = new AudienceVerifier('urn://audienceone');
     $verifier->verify($this->token);
 }
Example #4
0
 public function testSuccess()
 {
     $issuerClaim = $this->getMockBuilder('Emarref\\Jwt\\Claim\\Issuer')->getMock();
     $issuerClaim->expects($this->once())->method('getValue')->will($this->returnValue('an_issuer'));
     $this->token->expects($this->once())->method('getPayload')->will($this->returnValue($this->payload));
     $this->payload->expects($this->once())->method('findClaimByName')->with(Claim\Issuer::NAME)->will($this->returnValue($issuerClaim));
     $verifier = new IssuerVerifier('an_issuer');
     $verifier->verify($this->token);
 }
Example #5
0
 /**
  * @param Claim\ClaimInterface $claim
  */
 public function addClaim(Claim\ClaimInterface $claim)
 {
     $this->payload->setClaim($claim);
 }