3 namespace MediaWiki\Tests\Maintenance
;
5 use ExpireTemporaryAccounts
;
6 use MediaWiki\Auth\AuthManager
;
7 use MediaWiki\Tests\User\TempUser\TempUserTestTrait
;
10 * @covers \ExpireTemporaryAccounts
14 class ExpireTemporaryAccountsTest
extends MaintenanceBaseTestCase
{
15 use TempUserTestTrait
;
17 protected function getMaintenanceClass() {
18 return ExpireTemporaryAccounts
::class;
21 public function testExecuteWhenTemporaryAccountsNotKnown() {
22 $this->disableAutoCreateTempUser();
23 $this->expectOutputRegex( '/Temporary accounts are disabled/' );
24 $this->maintenance
->execute();
27 public function testExecuteWhenTemporaryAccountsNeverExpire() {
28 $this->enableAutoCreateTempUser( [ 'expireAfterDays' => null, 'notifyBeforeExpirationDays' => null ] );
29 $this->expectOutputRegex( '/Temporary account expiry is not enabled/' );
30 $this->maintenance
->execute();
33 public function testExecuteWithNoExistingTemporaryAccounts() {
34 // Create a no-op mock AuthManager, as no accounts should be expired by the script.
35 $this->setService( 'AuthManager', $this->createNoOpMock( AuthManager
::class ) );
36 $this->enableAutoCreateTempUser();
37 $this->expectOutputRegex( '/Revoked access for 0 temporary users/' );
38 $this->maintenance
->execute();