MediaWiki  1.30.0
ImportLogFormatterTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10  public static function provideUploadLogDatabaseRows() {
11  return [
12  // Current format
13  [
14  [
15  'type' => 'import',
16  'action' => 'upload',
17  'comment' => 'upload comment',
18  'namespace' => NS_MAIN,
19  'title' => 'ImportPage',
20  'params' => [
21  '4:number:count' => '1',
22  ],
23  ],
24  [
25  'text' => 'User imported ImportPage by file upload (1 revision)',
26  'api' => [
27  'count' => 1,
28  ],
29  ],
30  ],
31 
32  // old format - without details
33  [
34  [
35  'type' => 'import',
36  'action' => 'upload',
37  'comment' => '1 revision: import comment',
38  'namespace' => NS_MAIN,
39  'title' => 'ImportPage',
40  'params' => [],
41  ],
42  [
43  'text' => 'User imported ImportPage by file upload',
44  'api' => [],
45  ],
46  ],
47  ];
48  }
49 
53  public function testUploadLogDatabaseRows( $row, $extra ) {
54  $this->doTestLogFormatter( $row, $extra );
55  }
56 
62  public static function provideInterwikiLogDatabaseRows() {
63  return [
64  // Current format
65  [
66  [
67  'type' => 'import',
68  'action' => 'interwiki',
69  'comment' => 'interwiki comment',
70  'namespace' => NS_MAIN,
71  'title' => 'ImportPage',
72  'params' => [
73  '4:number:count' => '1',
74  '5:title-link:interwiki' => 'importiw:PageImport',
75  ],
76  ],
77  [
78  'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
79  'api' => [
80  'count' => 1,
81  'interwiki_ns' => 0,
82  'interwiki_title' => 'importiw:PageImport',
83  ],
84  ],
85  ],
86 
87  // old format - without details
88  [
89  [
90  'type' => 'import',
91  'action' => 'interwiki',
92  'comment' => '1 revision from importiw:PageImport: interwiki comment',
93  'namespace' => NS_MAIN,
94  'title' => 'ImportPage',
95  'params' => [],
96  ],
97  [
98  'text' => 'User imported ImportPage from another wiki',
99  'api' => [],
100  ],
101  ],
102  ];
103  }
104 
108  public function testInterwikiLogDatabaseRows( $row, $extra ) {
109  // Setup importiw: as interwiki prefix
110  $this->setMwGlobals( 'wgHooks', [
111  'InterwikiLoadPrefix' => [
112  function ( $prefix, &$data ) {
113  if ( $prefix == 'importiw' ) {
114  $data = [ 'iw_url' => 'wikipedia' ];
115  }
116  return false;
117  }
118  ]
119  ] );
120 
121  $this->doTestLogFormatter( $row, $extra );
122  }
123 }
ImportLogFormatterTest\provideUploadLogDatabaseRows
static provideUploadLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: ImportLogFormatterTest.php:10
php
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:35
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
LogFormatterTestCase
Definition: LogFormatterTestCase.php:6
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:672
ImportLogFormatterTest
Definition: ImportLogFormatterTest.php:3
ImportLogFormatterTest\testInterwikiLogDatabaseRows
testInterwikiLogDatabaseRows( $row, $extra)
provideInterwikiLogDatabaseRows
Definition: ImportLogFormatterTest.php:108
LogFormatterTestCase\doTestLogFormatter
doTestLogFormatter( $row, $extra)
Definition: LogFormatterTestCase.php:8
ImportLogFormatterTest\testUploadLogDatabaseRows
testUploadLogDatabaseRows( $row, $extra)
provideUploadLogDatabaseRows
Definition: ImportLogFormatterTest.php:53
ImportLogFormatterTest\provideInterwikiLogDatabaseRows
static provideInterwikiLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
Definition: ImportLogFormatterTest.php:62