Merge "Add Database::unionConditionPermutations()"
[lhc/web/wiklou.git] / tests / phpunit / includes / password / PasswordTestCase.php
index 9a142cb..80b9838 100644 (file)
@@ -78,8 +78,7 @@ abstract class PasswordTestCase extends MediaWikiTestCase {
 
        /**
         * @dataProvider providePasswordTests
-        * @covers InvalidPassword::equals
-        * @covers InvalidPassword::toString
+        * @covers InvalidPassword
         */
        public function testInvalidUnequalNormal( $shouldMatch, $hash, $password ) {
                $invalid = $this->passwordFactory->newFromCiphertext( null );
@@ -88,4 +87,26 @@ abstract class PasswordTestCase extends MediaWikiTestCase {
                $this->assertFalse( $invalid->equals( $normal ) );
                $this->assertFalse( $normal->equals( $invalid ) );
        }
+
+       protected function getValidTypes() {
+               return array_keys( $this->getTypeConfigs() );
+       }
+
+       public function provideTypes( $type ) {
+               $params = [];
+               foreach ( $this->getValidTypes() as $type ) {
+                       $params[] = [ $type ];
+               }
+               return $params;
+       }
+
+       /**
+        * @dataProvider provideTypes
+        */
+       public function testCrypt( $type ) {
+               $fromType = $this->passwordFactory->newFromType( $type );
+               $fromType->crypt( 'password' );
+               $fromPlaintext = $this->passwordFactory->newFromPlaintext( 'password', $fromType );
+               $this->assertTrue( $fromType->equals( $fromPlaintext ) );
+       }
 }