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