X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fpassword%2FPasswordTestCase.php;h=4557aceeec6e6d7754557d49962847dba9390ee6;hb=6a63b37c293a014a575099d2431b842bbcb20e7f;hp=384db5fa4f39bdce2e0f13879e4ddfaa3b007167;hpb=4465113b4787344078a0a8f13d322847ea9b3e83;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/password/PasswordTestCase.php b/tests/phpunit/includes/password/PasswordTestCase.php index 384db5fa4f..4557aceeec 100644 --- a/tests/phpunit/includes/password/PasswordTestCase.php +++ b/tests/phpunit/includes/password/PasswordTestCase.php @@ -60,9 +60,8 @@ abstract class PasswordTestCase extends MediaWikiTestCase { * @dataProvider providePasswordTests */ public function testHashing( $shouldMatch, $hash, $password ) { - $fromHash = $this->passwordFactory->newFromCiphertext( $hash ); - $fromPassword = $this->passwordFactory->newFromPlaintext( $password, $fromHash ); - $this->assertSame( $shouldMatch, $fromHash->equals( $fromPassword ) ); + $passwordObj = $this->passwordFactory->newFromCiphertext( $hash ); + $this->assertSame( $shouldMatch, $passwordObj->verify( $password ) ); } /** @@ -83,8 +82,7 @@ abstract class PasswordTestCase extends MediaWikiTestCase { $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() { @@ -106,6 +104,13 @@ abstract class PasswordTestCase extends MediaWikiTestCase { $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()' + ); } }