MediaWiki REL1_32
ImportLogFormatterTest.php
Go to the documentation of this file.
1<?php
2
7
13 public static function provideUploadLogDatabaseRows() {
14 return [
15 // Current format
16 [
17 [
18 'type' => 'import',
19 'action' => 'upload',
20 'comment' => 'upload comment',
21 'namespace' => NS_MAIN,
22 'title' => 'ImportPage',
23 'params' => [
24 '4:number:count' => '1',
25 ],
26 ],
27 [
28 'text' => 'User imported ImportPage by file upload (1 revision)',
29 'api' => [
30 'count' => 1,
31 ],
32 ],
33 ],
34
35 // old format - without details
36 [
37 [
38 'type' => 'import',
39 'action' => 'upload',
40 'comment' => '1 revision: import comment',
41 'namespace' => NS_MAIN,
42 'title' => 'ImportPage',
43 'params' => [],
44 ],
45 [
46 'text' => 'User imported ImportPage by file upload',
47 'api' => [],
48 ],
49 ],
50 ];
51 }
52
56 public function testUploadLogDatabaseRows( $row, $extra ) {
57 $this->doTestLogFormatter( $row, $extra );
58 }
59
65 public static function provideInterwikiLogDatabaseRows() {
66 return [
67 // Current format
68 [
69 [
70 'type' => 'import',
71 'action' => 'interwiki',
72 'comment' => 'interwiki comment',
73 'namespace' => NS_MAIN,
74 'title' => 'ImportPage',
75 'params' => [
76 '4:number:count' => '1',
77 '5:title-link:interwiki' => 'importiw:PageImport',
78 ],
79 ],
80 [
81 'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
82 'api' => [
83 'count' => 1,
84 'interwiki_ns' => 0,
85 'interwiki_title' => 'importiw:PageImport',
86 ],
87 ],
88 ],
89
90 // old format - without details
91 [
92 [
93 'type' => 'import',
94 'action' => 'interwiki',
95 'comment' => '1 revision from importiw:PageImport: interwiki comment',
96 'namespace' => NS_MAIN,
97 'title' => 'ImportPage',
98 'params' => [],
99 ],
100 [
101 'text' => 'User imported ImportPage from another wiki',
102 'api' => [],
103 ],
104 ],
105 ];
106 }
107
111 public function testInterwikiLogDatabaseRows( $row, $extra ) {
112 // Setup importiw: as interwiki prefix
113 $this->setMwGlobals( 'wgHooks', [
114 'InterwikiLoadPrefix' => [
115 function ( $prefix, &$data ) {
116 if ( $prefix == 'importiw' ) {
117 $data = [ 'iw_url' => 'wikipedia' ];
118 }
119 return false;
120 }
121 ]
122 ] );
123
124 $this->doTestLogFormatter( $row, $extra );
125 }
126}
testInterwikiLogDatabaseRows( $row, $extra)
provideInterwikiLogDatabaseRows
static provideUploadLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideInterwikiLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testUploadLogDatabaseRows( $row, $extra)
provideUploadLogDatabaseRows
doTestLogFormatter( $row, $extra)
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
const NS_MAIN
Definition Defines.php:64
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37