/** * @param string $data * @param DigestParamsInterface $digestParams * @return string */ public function digest($data, DigestParamsInterface $digestParams) { if ($digestParams instanceof Pbkdf2Params) { return $this->pbkdf2->hash($data, $digestParams); } throw new \RuntimeException('Unknown or unsupported digest algorithm'); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Unknown algorithm */ public function testMockWithUnknownInteralHashAlgo() { $mock = $this->getMockBuilder(Pbkdf2Params::class)->disableOriginalConstructor()->setMethods(['getMethod', 'getKeyLength', 'getSalt', 'getIterationCount'])->getMock(); $mock->expects($this->any())->method('getMethod')->willReturn('unknown'); $pbkdf2 = new Pbkdf2Digest(); $pbkdf2->hash('test', $mock); }