Do not insert page titles into querycache.qc_value
[lhc/web/wiklou.git] / tests / phpunit / includes / password / PasswordTestCase.php
index 7afdd0a..4557ace 100644 (file)
@@ -60,9 +60,8 @@ abstract class PasswordTestCase extends MediaWikiTestCase {
         * @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 ) );
        }
 
        /**
@@ -72,7 +71,7 @@ abstract class PasswordTestCase extends MediaWikiTestCase {
                $hashObj = $this->passwordFactory->newFromCiphertext( $hash );
                $serialized = $hashObj->toString();
                $unserialized = $this->passwordFactory->newFromCiphertext( $serialized );
-               $this->assertTrue( $hashObj->equals( $unserialized ) );
+               $this->assertEquals( $hashObj->toString(), $unserialized->toString() );
        }
 
        /**
@@ -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()'
+               );
        }
 }