6 class PasswordPolicyStructureTest
extends MediaWikiTestCase
{
8 public function provideChecks() {
9 global $wgPasswordPolicy;
11 foreach ( $wgPasswordPolicy['checks'] as $name => $callback ) {
16 public function provideFlags() {
17 global $wgPasswordPolicy;
19 // This won't actually find all flags, just the ones in use. Can't really be helped,
20 // other than adding the core flags here.
21 $flags = [ 'forceChange' ];
22 foreach ( $wgPasswordPolicy['policies'] as $group => $checks ) {
23 foreach ( $checks as $check => $settings ) {
24 if ( is_array( $settings ) ) {
25 $flags = array_merge( $flags, array_diff( $settings, [ 'value' ] ) );
29 foreach ( $flags as $flag ) {
34 /** @dataProvider provideChecks */
35 public function testCheckMessage( $check ) {
36 $msg = wfMessage( 'passwordpolicies-policy-' . strtolower( $check ) );
37 $this->assertTrue( $msg->exists() );
40 /** @dataProvider provideFlags */
41 public function testFlagMessage( $flag ) {
42 $msg = wfMessage( 'passwordpolicies-policyflag-' . strtolower( $flag ) );
43 $this->assertTrue( $msg->exists() );