With PHPUnit 9, tests without @covers tags are considered risky and emit warnings. Not having @covers is bad practice anyway, so use @coversNothing instead to make the intention clear, and re-enable the phpcs rule. Also rewrite an assertion in ResourcesTest that was bothering me. Bug: T243600 Change-Id: I6dd683f93b6b2faed5f107be2ca7860602277fbc
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @coversNothing
|
|
*/
|
|
class PasswordPolicyStructureTest extends MediaWikiIntegrationTestCase {
|
|
|
|
public function provideChecks() {
|
|
global $wgPasswordPolicy;
|
|
|
|
foreach ( $wgPasswordPolicy['checks'] as $name => $callback ) {
|
|
yield [ $name ];
|
|
}
|
|
}
|
|
|
|
public 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() );
|
|
}
|
|
|
|
}
|