/** * Tests that the password only needs to be re-built according to the first hasher * * @return void */ public function testNeedsRehash() { $hasher = new FallbackPasswordHasher(['hashers' => ['Default', 'Weak']]); $weak = new WeakPasswordHasher(); $otherHash = $weak->hash('foo'); $this->assertTrue($hasher->needsRehash($otherHash)); $simple = new DefaultPasswordHasher(); $hash = $simple->hash('foo'); $this->assertFalse($hasher->needsRehash($hash)); }
/** * Tests hash() and check() * * @return void */ public function testHashAndCheck() { $hasher = new WeakPasswordHasher(); $hasher->config('hashType', 'md5'); $password = $hasher->hash('foo'); $this->assertTrue($hasher->check('foo', $password)); $this->assertFalse($hasher->check('bar', $password)); $hasher->config('hashType', 'sha1'); $this->assertFalse($hasher->check('foo', $password)); }