summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/logging/ProtectLogFormatterTest.php
blob: 611b2dfc9ec128422c7b4ab0dd849ad07f7e8866 (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
<?php

class ProtectLogFormatterTest 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 provideMoveProtLogDatabaseRows() {
		return array(
			// Current format
			array(
				array(
					'type' => 'protect',
					'action' => 'move_prot',
					'comment' => 'Move comment',
					'namespace' => NS_MAIN,
					'title' => 'NewPage',
					'params' => array(
						'4::oldtitle' => 'OldPage',
					),
				),
				array(
					'text' => 'User moved protection settings from OldPage to NewPage',
					'api' => array(
						'oldtitle_ns' => 0,
						'oldtitle_title' => 'OldPage',
					),
				),
			),

			// Legacy format
			array(
				array(
					'type' => 'protect',
					'action' => 'move_prot',
					'comment' => 'Move comment',
					'namespace' => NS_MAIN,
					'title' => 'NewPage',
					'params' => array(
						'OldPage',
					),
				),
				array(
					'legacy' => true,
					'text' => 'User moved protection settings from OldPage to NewPage',
					'api' => array(
						'oldtitle_ns' => 0,
						'oldtitle_title' => 'OldPage',
					),
				),
			),
		);
	}

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