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