wiki.techinc.nl/tests/phpunit/includes/api/query/ApiQueryLogEventsTest.php
Dreamy Jazz 102424bfb3 Update wgAutoCreateTempUser config defaults
Why:
* The default value of wgAutoCreateTempUser has not changed since
  the decision to use a different prefix for temporary accounts
  (T332805).
* The default needs to be updated to reduce the number of overrides
  in operations/mediawiki-config and also to make the development
  experience more consistent with what is happening on WMF
  production.

What:
* Update the wgAutoCreateTempUser default in the following ways:
** Set expireAfterDays as 365
** Set notifyBeforeExpirationDays as 10
** Set genPattern and reservedPattern to '~$1'
** Set matchPattern to null, which will mean that the genPattern
   is used as the value.
* Update RealTempUserConfig::getPlaceholderName to add the year to
  the placeholder name so that if the match pattern includes the
  first digit of the year, then the placeholder name still is
  considered a valid temporary account username.
* Replace modifications of the wgAutoCreateTempUser config in
  integration tests with a use of the TempUserTestTrait to make
  the code cleaner and make it easier to find tests that relies on
  the values in wgAutoCreateTempUser.
* Update multiple tests to handle the new defaults for the config.

Bug: T359335
Change-Id: Ifa5a0123cd915bdb7c87e473c51fb93321622f12
2024-04-03 16:25:47 +00:00

41 lines
989 B
PHP

<?php
namespace MediaWiki\Tests\Api\Query;
use MediaWiki\Permissions\UltimateAuthority;
use MediaWiki\Tests\Api\ApiTestCase;
use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
use MediaWiki\User\UserIdentityValue;
/**
* @covers \ApiQueryLogEvents
* @group API
* @group Database
* @group medium
*/
class ApiQueryLogEventsTest extends ApiTestCase {
use TempUserTestTrait;
/**
* @group Database
*/
public function testLogEventByTempUser() {
$this->enableAutoCreateTempUser();
$tempUser = new UserIdentityValue( 1236764321, '~1' );
$title = $this->getNonexistingTestPage( 'TestPage1' )->getTitle();
$this->editPage(
$title,
'Some Content',
'Create Page',
NS_MAIN,
new UltimateAuthority( $tempUser )
);
[ $result, ] = $this->doApiRequest( [
'action' => 'query',
'list' => 'logevents',
] );
$this->assertArrayHasKey( 'temp', $result[ 'query' ][ 'logevents' ][0] );
$this->assertTrue( $result[ 'query' ][ 'logevents' ][0]['temp'] );
}
}