Merge "Implement HTMLComboboxField"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / ImportLogFormatterTest.php
1 <?php
2
3 class ImportLogFormatterTest extends LogFormatterTestCase {
4
5 /**
6 * Provide different rows from the logging table to test
7 * for backward compatibility.
8 * Do not change the existing data, just add a new database row
9 */
10 public static function provideUploadLogDatabaseRows() {
11 return array(
12 // Current format
13 array(
14 array(
15 'type' => 'import',
16 'action' => 'upload',
17 'comment' => 'upload comment',
18 'namespace' => NS_MAIN,
19 'title' => 'ImportPage',
20 'params' => array(
21 '4:number:count' => '1',
22 ),
23 ),
24 array(
25 'text' => 'User imported ImportPage by file upload (1 revision)',
26 'api' => array(
27 'count' => 1,
28 ),
29 ),
30 ),
31
32 // old format - without details
33 array(
34 array(
35 'type' => 'import',
36 'action' => 'upload',
37 'comment' => '1 revision: import comment',
38 'namespace' => NS_MAIN,
39 'title' => 'ImportPage',
40 'params' => array(),
41 ),
42 array(
43 'text' => 'User imported ImportPage by file upload',
44 'api' => array(),
45 ),
46 ),
47 );
48 }
49
50 /**
51 * @dataProvider provideUploadLogDatabaseRows
52 */
53 public function testUploadLogDatabaseRows( $row, $extra ) {
54 $this->doTestLogFormatter( $row, $extra );
55 }
56
57 /**
58 * Provide different rows from the logging table to test
59 * for backward compatibility.
60 * Do not change the existing data, just add a new database row
61 */
62 public static function provideInterwikiLogDatabaseRows() {
63 return array(
64 // Current format
65 array(
66 array(
67 'type' => 'import',
68 'action' => 'interwiki',
69 'comment' => 'interwiki comment',
70 'namespace' => NS_MAIN,
71 'title' => 'ImportPage',
72 'params' => array(
73 '4:number:count' => '1',
74 '5:title-link:interwiki' => 'importiw:PageImport',
75 ),
76 ),
77 array(
78 'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
79 'api' => array(
80 'count' => 1,
81 'interwiki_ns' => 0,
82 'interwiki_title' => 'importiw:PageImport',
83 ),
84 ),
85 ),
86
87 // old format - without details
88 array(
89 array(
90 'type' => 'import',
91 'action' => 'interwiki',
92 'comment' => '1 revision from importiw:PageImport: interwiki comment',
93 'namespace' => NS_MAIN,
94 'title' => 'ImportPage',
95 'params' => array(),
96 ),
97 array(
98 'text' => 'User imported ImportPage from another wiki',
99 'api' => array(),
100 ),
101 ),
102 );
103 }
104
105 /**
106 * @dataProvider provideInterwikiLogDatabaseRows
107 */
108 public function testInterwikiLogDatabaseRows( $row, $extra ) {
109 // Setup importiw: as interwiki prefix
110 $this->setMwGlobals( 'wgHooks', array(
111 'InterwikiLoadPrefix' => array(
112 function ( $prefix, &$data ) {
113 if ( $prefix == 'importiw' ) {
114 $data = array( 'iw_url' => 'wikipedia' );
115 }
116 return false;
117 }
118 )
119 ) );
120
121 $this->doTestLogFormatter( $row, $extra );
122 }
123 }