1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<?php
/**
* @coversNothing
*/
class PasswordPolicyStructureTest extends MediaWikiIntegrationTestCase {
public static function provideChecks() {
global $wgPasswordPolicy;
foreach ( $wgPasswordPolicy['checks'] as $name => $callback ) {
yield [ $name ];
}
}
public static function provideFlags() {
global $wgPasswordPolicy;
// This won't actually find all flags, just the ones in use. Can't really be helped,
// other than adding the core flags here.
$flags = [ 'forceChange', 'suggestChangeOnLogin' ];
foreach ( $wgPasswordPolicy['policies'] as $group => $checks ) {
foreach ( $checks as $check => $settings ) {
if ( is_array( $settings ) ) {
$flags = array_unique(
array_merge( $flags, array_diff( array_keys( $settings ), [ 'value' ] ) )
);
}
}
}
foreach ( $flags as $flag ) {
yield [ $flag ];
}
}
/** @dataProvider provideChecks */
public function testCheckMessage( $check ) {
$msg = wfMessage( 'passwordpolicies-policy-' . strtolower( $check ) );
$this->assertTrue( $msg->exists() );
}
/** @dataProvider provideFlags */
public function testFlagMessage( $flag ) {
$msg = wfMessage( 'passwordpolicies-policyflag-' . strtolower( $flag ) );
$this->assertTrue( $msg->exists() );
}
}
|