* @dataProvider providePasswordTests
*/
public function testHashing( $shouldMatch, $hash, $password ) {
- $hash = $this->passwordFactory->newFromCiphertext( $hash );
- $password = $this->passwordFactory->newFromPlaintext( $password, $hash );
- $this->assertSame( $shouldMatch, $hash->equals( $password ) );
+ $passwordObj = $this->passwordFactory->newFromCiphertext( $hash );
+ $this->assertSame( $shouldMatch, $passwordObj->verify( $password ) );
}
/**
$hashObj = $this->passwordFactory->newFromCiphertext( $hash );
$serialized = $hashObj->toString();
$unserialized = $this->passwordFactory->newFromCiphertext( $serialized );
- $this->assertTrue( $hashObj->equals( $unserialized ) );
+ $this->assertEquals( $hashObj->toString(), $unserialized->toString() );
}
/**
$invalid = $this->passwordFactory->newFromCiphertext( null );
$normal = $this->passwordFactory->newFromCiphertext( $hash );
- $this->assertFalse( $invalid->equals( $normal ) );
- $this->assertFalse( $normal->equals( $invalid ) );
+ $this->assertFalse( $invalid->verify( $hash ) );
}
protected function getValidTypes() {
$fromType = $this->passwordFactory->newFromType( $type );
$fromType->crypt( 'password' );
$fromPlaintext = $this->passwordFactory->newFromPlaintext( 'password', $fromType );
- $this->assertTrue( $fromType->equals( $fromPlaintext ) );
+ $this->assertTrue( $fromType->verify( 'password' ) );
+ $this->assertTrue( $fromPlaintext->verify( 'password' ) );
+ $this->assertFalse( $fromType->verify( 'different password' ) );
+ $this->assertFalse( $fromPlaintext->verify( 'different password' ) );
+ $this->assertEquals( get_class( $fromType ),
+ get_class( $fromPlaintext ),
+ 'newFromPlaintext() should produce instance of the same class as newFromType()'
+ );
}
}