2015-11-10 18:56:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
2021-05-05 00:03:26 +00:00
|
|
|
use MediaWiki\Tests\Unit\DummyServicesTrait;
|
2020-12-18 22:32:27 +00:00
|
|
|
|
2017-12-25 07:26:01 +00:00
|
|
|
/**
|
|
|
|
|
* @covers ImportLogFormatter
|
|
|
|
|
*/
|
2015-11-10 18:56:19 +00:00
|
|
|
class ImportLogFormatterTest extends LogFormatterTestCase {
|
2021-05-05 00:03:26 +00:00
|
|
|
use DummyServicesTrait;
|
2015-11-10 18:56:19 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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-11-10 18:56:19 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'type' => 'import',
|
|
|
|
|
'action' => 'upload',
|
|
|
|
|
'comment' => 'upload comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ImportPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-11-10 18:56:19 +00:00
|
|
|
'4:number:count' => '1',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'text' => 'User imported ImportPage by file upload (1 revision)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-11-10 18:56:19 +00:00
|
|
|
'count' => 1,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-11-10 18:56:19 +00:00
|
|
|
|
|
|
|
|
// old format - without details
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'type' => 'import',
|
|
|
|
|
'action' => 'upload',
|
|
|
|
|
'comment' => '1 revision: import comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ImportPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'text' => 'User imported ImportPage by file upload',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-11-10 18:56:19 +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 provideInterwikiLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-11-10 18:56:19 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'type' => 'import',
|
|
|
|
|
'action' => 'interwiki',
|
|
|
|
|
'comment' => 'interwiki comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ImportPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-11-10 18:56:19 +00:00
|
|
|
'4:number:count' => '1',
|
|
|
|
|
'5:title-link:interwiki' => 'importiw:PageImport',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'text' => 'User imported ImportPage from importiw:PageImport (1 revision)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-11-10 18:56:19 +00:00
|
|
|
'count' => 1,
|
|
|
|
|
'interwiki_ns' => 0,
|
|
|
|
|
'interwiki_title' => 'importiw:PageImport',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-11-10 18:56:19 +00:00
|
|
|
|
|
|
|
|
// old format - without details
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'type' => 'import',
|
|
|
|
|
'action' => 'interwiki',
|
|
|
|
|
'comment' => '1 revision from importiw:PageImport: interwiki comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ImportPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-11-10 18:56:19 +00:00
|
|
|
'text' => 'User imported ImportPage from another wiki',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-11-10 18:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideInterwikiLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testInterwikiLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
// Setup importiw: as interwiki prefix
|
2021-05-05 00:03:26 +00:00
|
|
|
// DummyServicesTrait::getDummyInterwikiLookup
|
|
|
|
|
$interwikiLookup = $this->getDummyInterwikiLookup( [ 'importiw' ] );
|
|
|
|
|
$this->setService( 'InterwikiLookup', $interwikiLookup );
|
2015-11-10 18:56:19 +00:00
|
|
|
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
}
|