123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <?php
- /**
- * @covers MoveLogFormatter
- */
- class MoveLogFormatterTest 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 provideMoveLogDatabaseRows() {
- return [
- // Current format - with redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move',
- 'comment' => 'move comment with redirect',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- '4::target' => 'NewPage',
- '5::noredir' => '0',
- ],
- ],
- [
- 'text' => 'User moved page OldPage to NewPage',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- // Current format - without redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- '4::target' => 'NewPage',
- '5::noredir' => '1',
- ],
- ],
- [
- 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => true,
- ],
- ],
- ],
- // legacy format - with redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- '',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- // legacy format - without redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- '1',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => true,
- ],
- ],
- ],
- // old format without flag for redirect suppression
- [
- [
- 'type' => 'move',
- 'action' => 'move',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- ];
- }
- /**
- * @dataProvider provideMoveLogDatabaseRows
- */
- public function testMoveLogDatabaseRows( $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 provideMoveRedirLogDatabaseRows() {
- return [
- // Current format - with redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move_redir',
- 'comment' => 'move comment with redirect',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- '4::target' => 'NewPage',
- '5::noredir' => '0',
- ],
- ],
- [
- 'text' => 'User moved page OldPage to NewPage over redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- // Current format - without redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move_redir',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- '4::target' => 'NewPage',
- '5::noredir' => '1',
- ],
- ],
- [
- 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => true,
- ],
- ],
- ],
- // legacy format - with redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move_redir',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- '',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage over redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- // legacy format - without redirect
- [
- [
- 'type' => 'move',
- 'action' => 'move_redir',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- '1',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => true,
- ],
- ],
- ],
- // old format without flag for redirect suppression
- [
- [
- 'type' => 'move',
- 'action' => 'move_redir',
- 'comment' => 'move comment',
- 'namespace' => NS_MAIN,
- 'title' => 'OldPage',
- 'params' => [
- 'NewPage',
- ],
- ],
- [
- 'legacy' => true,
- 'text' => 'User moved page OldPage to NewPage over redirect',
- 'api' => [
- 'target_ns' => 0,
- 'target_title' => 'NewPage',
- 'suppressredirect' => false,
- ],
- ],
- ],
- ];
- }
- /**
- * @dataProvider provideMoveRedirLogDatabaseRows
- */
- public function testMoveRedirLogDatabaseRows( $row, $extra ) {
- $this->doTestLogFormatter( $row, $extra );
- }
- }
|