MediaWiki REL1_31
UploadLogFormatterTest.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' => 'upload',
19 'action' => 'upload',
20 'comment' => 'upload comment',
21 'namespace' => NS_FILE,
22 'title' => 'File.png',
23 'params' => [
24 'img_sha1' => 'hash',
25 'img_timestamp' => '20150101000000',
26 ],
27 ],
28 [
29 'text' => 'User uploaded File:File.png',
30 'api' => [
31 'img_sha1' => 'hash',
32 'img_timestamp' => '2015-01-01T00:00:00Z',
33 ],
34 ],
35 ],
36
37 // Old format without params
38 [
39 [
40 'type' => 'upload',
41 'action' => 'upload',
42 'comment' => 'upload comment',
43 'namespace' => NS_FILE,
44 'title' => 'File.png',
45 'params' => [],
46 ],
47 [
48 'text' => 'User uploaded File:File.png',
49 'api' => [],
50 ],
51 ],
52 ];
53 }
54
58 public function testUploadLogDatabaseRows( $row, $extra ) {
59 $this->doTestLogFormatter( $row, $extra );
60 }
61
67 public static function provideOverwriteLogDatabaseRows() {
68 return [
69 // Current format
70 [
71 [
72 'type' => 'upload',
73 'action' => 'overwrite',
74 'comment' => 'upload comment',
75 'namespace' => NS_FILE,
76 'title' => 'File.png',
77 'params' => [
78 'img_sha1' => 'hash',
79 'img_timestamp' => '20150101000000',
80 ],
81 ],
82 [
83 'text' => 'User uploaded a new version of File:File.png',
84 'api' => [
85 'img_sha1' => 'hash',
86 'img_timestamp' => '2015-01-01T00:00:00Z',
87 ],
88 ],
89 ],
90
91 // Old format without params
92 [
93 [
94 'type' => 'upload',
95 'action' => 'overwrite',
96 'comment' => 'upload comment',
97 'namespace' => NS_FILE,
98 'title' => 'File.png',
99 'params' => [],
100 ],
101 [
102 'text' => 'User uploaded a new version of File:File.png',
103 'api' => [],
104 ],
105 ],
106 ];
107 }
108
112 public function testOverwriteLogDatabaseRows( $row, $extra ) {
113 $this->doTestLogFormatter( $row, $extra );
114 }
115
121 public static function provideRevertLogDatabaseRows() {
122 return [
123 // Current format
124 [
125 [
126 'type' => 'upload',
127 'action' => 'revert',
128 'comment' => 'upload comment',
129 'namespace' => NS_FILE,
130 'title' => 'File.png',
131 'params' => [
132 'img_sha1' => 'hash',
133 'img_timestamp' => '20150101000000',
134 ],
135 ],
136 [
137 'text' => 'User uploaded File:File.png',
138 'api' => [
139 'img_sha1' => 'hash',
140 'img_timestamp' => '2015-01-01T00:00:00Z',
141 ],
142 ],
143 ],
144
145 // Old format without params
146 [
147 [
148 'type' => 'upload',
149 'action' => 'revert',
150 'comment' => 'upload comment',
151 'namespace' => NS_FILE,
152 'title' => 'File.png',
153 'params' => [],
154 ],
155 [
156 'text' => 'User uploaded File:File.png',
157 'api' => [],
158 ],
159 ],
160 ];
161 }
162
166 public function testRevertLogDatabaseRows( $row, $extra ) {
167 $this->doTestLogFormatter( $row, $extra );
168 }
169}
doTestLogFormatter( $row, $extra)
testUploadLogDatabaseRows( $row, $extra)
provideUploadLogDatabaseRows
static provideOverwriteLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
testOverwriteLogDatabaseRows( $row, $extra)
provideOverwriteLogDatabaseRows
testRevertLogDatabaseRows( $row, $extra)
provideRevertLogDatabaseRows
static provideUploadLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
static provideRevertLogDatabaseRows()
Provide different rows from the logging table to test for backward compatibility.
const NS_FILE
Definition Defines.php:80
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