/** * @expectedException \RuntimeException * @expectedExceptionMessage Cannot use "bar" algorithm to decrypt token encrypted with algorithm "foo". */ public function testAlgorithmMismatch() { $algorithmParameter = $this->getMockBuilder('Emarref\\Jwt\\HeaderParameter\\Algorithm')->getMock(); $algorithmParameter->expects($this->exactly(2))->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->exactly(2))->method('getAlgorithmName')->will($this->returnValue('bar')); $verifier = new EncryptionVerifier($this->encryption, $this->encoder); $verifier->verify($this->token); }