summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/logging/MergeLogFormatterTest.php
blob: 2ff0ddf5e9338fcb44d3876e6a996331526b07a8 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

class MergeLogFormatterTest extends LogFormatterTestCase {

	/**
	 * Provide different rows from the logging table to test
	 * for backward compatibility.
	 * Do not change the existing data, just add a new database row
	 */
	public static function provideMergeLogDatabaseRows() {
		return array(
			// Current format
			array(
				array(
					'type' => 'merge',
					'action' => 'merge',
					'comment' => 'Merge comment',
					'namespace' => NS_MAIN,
					'title' => 'OldPage',
					'params' => array(
						'4::dest' => 'NewPage',
						'5::mergepoint' => '20140804160710',
					),
				),
				array(
					'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)',
					'api' => array(
						'dest_ns' => 0,
						'dest_title' => 'NewPage',
						'mergepoint' => '2014-08-04T16:07:10Z',
					),
				),
			),

			// Legacy format
			array(
				array(
					'type' => 'merge',
					'action' => 'merge',
					'comment' => 'merge comment',
					'namespace' => NS_MAIN,
					'title' => 'OldPage',
					'params' => array(
						'NewPage',
						'20140804160710',
					),
				),
				array(
					'legacy' => true,
					'text' => 'User merged OldPage into NewPage (revisions up to 16:07, 4 August 2014)',
					'api' => array(
						'dest_ns' => 0,
						'dest_title' => 'NewPage',
						'mergepoint' => '2014-08-04T16:07:10Z',
					),
				),
			),
		);
	}

	/**
	 * @dataProvider provideMergeLogDatabaseRows
	 */
	public function testMergeLogDatabaseRows( $row, $extra ) {
		$this->doTestLogFormatter( $row, $extra );
	}
}