Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / maintenance / WikiBirthdayTest.php
blob8e84a61c2babac0eba711478dd625ba800fb28b6
1 <?php
3 namespace MediaWiki\Tests\Maintenance;
5 use MediaWiki\Title\Title;
6 use WikiBirthday;
7 use Wikimedia\Timestamp\ConvertibleTimestamp;
9 /**
10 * @covers \WikiBirthday
11 * @group Database
12 * @author Dreamy Jazz
14 class WikiBirthdayTest extends MaintenanceBaseTestCase {
16 protected function getMaintenanceClass() {
17 return WikiBirthday::class;
20 public function testExecuteForOneRevision() {
21 // Create a fake revision with a set timestamp
22 ConvertibleTimestamp::setFakeTime( '20230405060708' );
23 $this->editPage( Title::newFromText( 'Testing1234' ), 'Test1234' );
24 // Set the timestamp to a year in advance
25 ConvertibleTimestamp::setFakeTime( '20240405060708' );
26 $this->maintenance->execute();
27 $this->expectOutputRegex( '/Wiki was created on: 5 April 2023.*age: 1 yr.*0 month.*0 day.*old/' );
30 public function testExecuteForDeletedRevision() {
31 // Create a fake revision with a set timestamp, and then delete the associated page
32 ConvertibleTimestamp::setFakeTime( '20230505060708' );
33 $editStatus = $this->editPage( Title::newFromText( 'Testing1234' ), 'Test1234' );
34 ConvertibleTimestamp::setFakeTime( '20230505060709' );
35 $this->deletePage( $this->getServiceContainer()->getWikiPageFactory()->newFromTitle(
36 $editStatus->getNewRevision()->getPage()
37 ) );
38 // Set the timestamp to 3 months and 3 days in advance
39 ConvertibleTimestamp::setFakeTime( '20230708060708' );
40 $this->maintenance->execute();
41 $this->expectOutputRegex( '/Wiki was created on: 5 May.*age: 0 yr.*2 month.*3 day.*old/' );