File: WikiBirthdayTest.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (43 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

namespace MediaWiki\Tests\Maintenance;

use MediaWiki\Title\Title;
use WikiBirthday;
use Wikimedia\Timestamp\ConvertibleTimestamp;

/**
 * @covers \WikiBirthday
 * @group Database
 * @author Dreamy Jazz
 */
class WikiBirthdayTest extends MaintenanceBaseTestCase {

	protected function getMaintenanceClass() {
		return WikiBirthday::class;
	}

	public function testExecuteForOneRevision() {
		// Create a fake revision with a set timestamp
		ConvertibleTimestamp::setFakeTime( '20230405060708' );
		$this->editPage( Title::newFromText( 'Testing1234' ), 'Test1234' );
		// Set the timestamp to a year in advance
		ConvertibleTimestamp::setFakeTime( '20240405060708' );
		$this->maintenance->execute();
		$this->expectOutputRegex( '/Wiki was created on: 5 April 2023.*age: 1 yr.*0 month.*0 day.*old/' );
	}

	public function testExecuteForDeletedRevision() {
		// Create a fake revision with a set timestamp, and then delete the associated page
		ConvertibleTimestamp::setFakeTime( '20230505060708' );
		$editStatus = $this->editPage( Title::newFromText( 'Testing1234' ), 'Test1234' );
		ConvertibleTimestamp::setFakeTime( '20230505060709' );
		$this->deletePage( $this->getServiceContainer()->getWikiPageFactory()->newFromTitle(
			$editStatus->getNewRevision()->getPage()
		) );
		// Set the timestamp to 3 months and 3 days in advance
		ConvertibleTimestamp::setFakeTime( '20230708060708' );
		$this->maintenance->execute();
		$this->expectOutputRegex( '/Wiki was created on: 5 May.*age: 0 yr.*2 month.*3 day.*old/' );
	}
}