2015-04-09 09:09:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
2017-12-25 07:26:01 +00:00
|
|
|
/**
|
|
|
|
|
* @covers UploadLogFormatter
|
|
|
|
|
*/
|
2015-04-09 09:09:36 +00:00
|
|
|
class UploadLogFormatterTest extends LogFormatterTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provide different rows from the logging table to test
|
|
|
|
|
* for backward compatibility.
|
|
|
|
|
* Do not change the existing data, just add a new database row
|
|
|
|
|
*/
|
|
|
|
|
public static function provideUploadLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'upload',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '20150101000000',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'text' => 'User uploaded File:File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '2015-01-01T00:00:00Z',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Old format without params
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'upload',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'text' => 'User uploaded File:File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideUploadLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testUploadLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provide different rows from the logging table to test
|
|
|
|
|
* for backward compatibility.
|
|
|
|
|
* Do not change the existing data, just add a new database row
|
|
|
|
|
*/
|
|
|
|
|
public static function provideOverwriteLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'overwrite',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '20150101000000',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'text' => 'User uploaded a new version of File:File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '2015-01-01T00:00:00Z',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Old format without params
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'overwrite',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'text' => 'User uploaded a new version of File:File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideOverwriteLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testOverwriteLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provide different rows from the logging table to test
|
|
|
|
|
* for backward compatibility.
|
|
|
|
|
* Do not change the existing data, just add a new database row
|
|
|
|
|
*/
|
|
|
|
|
public static function provideRevertLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'revert',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '20150101000000',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2018-10-01 18:05:44 +00:00
|
|
|
'text' => 'User reverted File:File.png to an old version',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'img_sha1' => 'hash',
|
|
|
|
|
'img_timestamp' => '2015-01-01T00:00:00Z',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Old format without params
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'upload',
|
|
|
|
|
'action' => 'revert',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_FILE,
|
|
|
|
|
'title' => 'File.png',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2018-10-01 18:05:44 +00:00
|
|
|
'text' => 'User reverted File:File.png to an old version',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideRevertLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testRevertLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
}
|