37 $this->passwordFactory->register(
$type, $config );
62 public function testHashing( $shouldMatch, $hash, $password ) {
63 $passwordObj = $this->passwordFactory->newFromCiphertext( $hash );
64 $this->assertSame( $shouldMatch, $passwordObj->verify( $password ) );
71 $hashObj = $this->passwordFactory->newFromCiphertext( $hash );
73 $unserialized = $this->passwordFactory->newFromCiphertext(
$serialized );
74 $this->assertEquals( $hashObj->toString(), $unserialized->toString() );
82 $invalid = $this->passwordFactory->newFromCiphertext(
null );
83 $normal = $this->passwordFactory->newFromCiphertext( $hash );
85 $this->assertFalse( $invalid->equals( $normal ) );
86 $this->assertFalse( $normal->equals( $invalid ) );
87 $this->assertFalse( $invalid->verify( $hash ) );
106 $fromType = $this->passwordFactory->newFromType(
$type );
107 $fromType->crypt(
'password' );
108 $fromPlaintext = $this->passwordFactory->newFromPlaintext(
'password', $fromType );
109 $this->assertTrue( $fromType->verify(
'password' ) );
110 $this->assertTrue( $fromPlaintext->verify(
'password' ) );
111 $this->assertFalse( $fromType->verify(
'different password' ) );
112 $this->assertFalse( $fromPlaintext->verify(
'different password' ) );
113 $this->assertEquals( get_class( $fromType ),
114 get_class( $fromPlaintext ),
115 'newFromPlaintext() should produce instance of the same class as newFromType()'