MoveLogFormatterTest.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. /**
  3. * @covers MoveLogFormatter
  4. */
  5. class MoveLogFormatterTest extends LogFormatterTestCase {
  6. /**
  7. * Provide different rows from the logging table to test
  8. * for backward compatibility.
  9. * Do not change the existing data, just add a new database row
  10. */
  11. public static function provideMoveLogDatabaseRows() {
  12. return [
  13. // Current format - with redirect
  14. [
  15. [
  16. 'type' => 'move',
  17. 'action' => 'move',
  18. 'comment' => 'move comment with redirect',
  19. 'namespace' => NS_MAIN,
  20. 'title' => 'OldPage',
  21. 'params' => [
  22. '4::target' => 'NewPage',
  23. '5::noredir' => '0',
  24. ],
  25. ],
  26. [
  27. 'text' => 'User moved page OldPage to NewPage',
  28. 'api' => [
  29. 'target_ns' => 0,
  30. 'target_title' => 'NewPage',
  31. 'suppressredirect' => false,
  32. ],
  33. ],
  34. ],
  35. // Current format - without redirect
  36. [
  37. [
  38. 'type' => 'move',
  39. 'action' => 'move',
  40. 'comment' => 'move comment',
  41. 'namespace' => NS_MAIN,
  42. 'title' => 'OldPage',
  43. 'params' => [
  44. '4::target' => 'NewPage',
  45. '5::noredir' => '1',
  46. ],
  47. ],
  48. [
  49. 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
  50. 'api' => [
  51. 'target_ns' => 0,
  52. 'target_title' => 'NewPage',
  53. 'suppressredirect' => true,
  54. ],
  55. ],
  56. ],
  57. // legacy format - with redirect
  58. [
  59. [
  60. 'type' => 'move',
  61. 'action' => 'move',
  62. 'comment' => 'move comment',
  63. 'namespace' => NS_MAIN,
  64. 'title' => 'OldPage',
  65. 'params' => [
  66. 'NewPage',
  67. '',
  68. ],
  69. ],
  70. [
  71. 'legacy' => true,
  72. 'text' => 'User moved page OldPage to NewPage',
  73. 'api' => [
  74. 'target_ns' => 0,
  75. 'target_title' => 'NewPage',
  76. 'suppressredirect' => false,
  77. ],
  78. ],
  79. ],
  80. // legacy format - without redirect
  81. [
  82. [
  83. 'type' => 'move',
  84. 'action' => 'move',
  85. 'comment' => 'move comment',
  86. 'namespace' => NS_MAIN,
  87. 'title' => 'OldPage',
  88. 'params' => [
  89. 'NewPage',
  90. '1',
  91. ],
  92. ],
  93. [
  94. 'legacy' => true,
  95. 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
  96. 'api' => [
  97. 'target_ns' => 0,
  98. 'target_title' => 'NewPage',
  99. 'suppressredirect' => true,
  100. ],
  101. ],
  102. ],
  103. // old format without flag for redirect suppression
  104. [
  105. [
  106. 'type' => 'move',
  107. 'action' => 'move',
  108. 'comment' => 'move comment',
  109. 'namespace' => NS_MAIN,
  110. 'title' => 'OldPage',
  111. 'params' => [
  112. 'NewPage',
  113. ],
  114. ],
  115. [
  116. 'legacy' => true,
  117. 'text' => 'User moved page OldPage to NewPage',
  118. 'api' => [
  119. 'target_ns' => 0,
  120. 'target_title' => 'NewPage',
  121. 'suppressredirect' => false,
  122. ],
  123. ],
  124. ],
  125. ];
  126. }
  127. /**
  128. * @dataProvider provideMoveLogDatabaseRows
  129. */
  130. public function testMoveLogDatabaseRows( $row, $extra ) {
  131. $this->doTestLogFormatter( $row, $extra );
  132. }
  133. /**
  134. * Provide different rows from the logging table to test
  135. * for backward compatibility.
  136. * Do not change the existing data, just add a new database row
  137. */
  138. public static function provideMoveRedirLogDatabaseRows() {
  139. return [
  140. // Current format - with redirect
  141. [
  142. [
  143. 'type' => 'move',
  144. 'action' => 'move_redir',
  145. 'comment' => 'move comment with redirect',
  146. 'namespace' => NS_MAIN,
  147. 'title' => 'OldPage',
  148. 'params' => [
  149. '4::target' => 'NewPage',
  150. '5::noredir' => '0',
  151. ],
  152. ],
  153. [
  154. 'text' => 'User moved page OldPage to NewPage over redirect',
  155. 'api' => [
  156. 'target_ns' => 0,
  157. 'target_title' => 'NewPage',
  158. 'suppressredirect' => false,
  159. ],
  160. ],
  161. ],
  162. // Current format - without redirect
  163. [
  164. [
  165. 'type' => 'move',
  166. 'action' => 'move_redir',
  167. 'comment' => 'move comment',
  168. 'namespace' => NS_MAIN,
  169. 'title' => 'OldPage',
  170. 'params' => [
  171. '4::target' => 'NewPage',
  172. '5::noredir' => '1',
  173. ],
  174. ],
  175. [
  176. 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
  177. 'api' => [
  178. 'target_ns' => 0,
  179. 'target_title' => 'NewPage',
  180. 'suppressredirect' => true,
  181. ],
  182. ],
  183. ],
  184. // legacy format - with redirect
  185. [
  186. [
  187. 'type' => 'move',
  188. 'action' => 'move_redir',
  189. 'comment' => 'move comment',
  190. 'namespace' => NS_MAIN,
  191. 'title' => 'OldPage',
  192. 'params' => [
  193. 'NewPage',
  194. '',
  195. ],
  196. ],
  197. [
  198. 'legacy' => true,
  199. 'text' => 'User moved page OldPage to NewPage over redirect',
  200. 'api' => [
  201. 'target_ns' => 0,
  202. 'target_title' => 'NewPage',
  203. 'suppressredirect' => false,
  204. ],
  205. ],
  206. ],
  207. // legacy format - without redirect
  208. [
  209. [
  210. 'type' => 'move',
  211. 'action' => 'move_redir',
  212. 'comment' => 'move comment',
  213. 'namespace' => NS_MAIN,
  214. 'title' => 'OldPage',
  215. 'params' => [
  216. 'NewPage',
  217. '1',
  218. ],
  219. ],
  220. [
  221. 'legacy' => true,
  222. 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
  223. 'api' => [
  224. 'target_ns' => 0,
  225. 'target_title' => 'NewPage',
  226. 'suppressredirect' => true,
  227. ],
  228. ],
  229. ],
  230. // old format without flag for redirect suppression
  231. [
  232. [
  233. 'type' => 'move',
  234. 'action' => 'move_redir',
  235. 'comment' => 'move comment',
  236. 'namespace' => NS_MAIN,
  237. 'title' => 'OldPage',
  238. 'params' => [
  239. 'NewPage',
  240. ],
  241. ],
  242. [
  243. 'legacy' => true,
  244. 'text' => 'User moved page OldPage to NewPage over redirect',
  245. 'api' => [
  246. 'target_ns' => 0,
  247. 'target_title' => 'NewPage',
  248. 'suppressredirect' => false,
  249. ],
  250. ],
  251. ],
  252. ];
  253. }
  254. /**
  255. * @dataProvider provideMoveRedirLogDatabaseRows
  256. */
  257. public function testMoveRedirLogDatabaseRows( $row, $extra ) {
  258. $this->doTestLogFormatter( $row, $extra );
  259. }
  260. }