X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fpassword%2FPasswordTestCase.php;h=80b9838d8eba111846d2f78c5e47d8e8706f46b6;hb=a9911b2582a20d9fe0569439d0d22a8c3135c249;hp=ef16f1c48ddd3be107b06198e2bce2fb1b45aeee;hpb=7319c450f3a3f560ed73feab60bd3323b1e02f46;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/password/PasswordTestCase.php b/tests/phpunit/includes/password/PasswordTestCase.php index ef16f1c48d..80b9838d8e 100644 --- a/tests/phpunit/includes/password/PasswordTestCase.php +++ b/tests/phpunit/includes/password/PasswordTestCase.php @@ -49,10 +49,13 @@ abstract class PasswordTestCase extends MediaWikiTestCase { * An array of tests in the form of (bool, string, string), where the first * element is whether the second parameter (a password hash) and the third * parameter (a password) should match. - * * @return array + * @throws MWException + * @abstract */ - abstract public static function providePasswordTests(); + public static function providePasswordTests() { + throw new MWException( "Not implemented" ); + } /** * @dataProvider providePasswordTests @@ -75,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 ); @@ -85,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 ) ); + } }