public function testValidSignature() { $algorithmParameter = $this->getMockBuilder('Emarref\\Jwt\\HeaderParameter\\Algorithm')->getMock(); $algorithmParameter->expects($this->once())->method('getValue')->will($this->returnValue('foo')); $this->header->expects($this->once())->method('findParameterByName')->with(HeaderParameter\Algorithm::NAME)->will($this->returnValue($algorithmParameter)); $this->encryption->expects($this->once())->method('getAlgorithmName')->will($this->returnValue('foo')); $this->encryption->expects($this->once())->method('verify')->will($this->returnValue(true)); $this->signer->expects($this->once())->method('getUnsignedValue')->will($this->returnValue('bar')); $this->token->expects($this->once())->method('getSignature')->will($this->returnValue('bar')); $verifier = new EncryptionVerifierStub($this->encryption, $this->encoder, $this->signer); $verifier->verify($this->token); }
/** * @param HeaderParameter\ParameterInterface $parameter * @param bool $critical */ public function addHeader(HeaderParameter\ParameterInterface $parameter, $critical = false) { $this->header->setParameter($parameter, $critical); }