summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/logging/MoveLogFormatterTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
commit6dc1997577fab2c366781fd7048144935afa0012 (patch)
tree8918d28c7ab4342f0738985e37af1dfc42d0e93a /tests/phpunit/includes/logging/MoveLogFormatterTest.php
parent150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff)
parentfa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff)
Merge commit 'fa89acd'
# Conflicts: # .gitignore # extensions/ArchInterWiki.sql
Diffstat (limited to 'tests/phpunit/includes/logging/MoveLogFormatterTest.php')
-rw-r--r--tests/phpunit/includes/logging/MoveLogFormatterTest.php270
1 files changed, 270 insertions, 0 deletions
diff --git a/tests/phpunit/includes/logging/MoveLogFormatterTest.php b/tests/phpunit/includes/logging/MoveLogFormatterTest.php
new file mode 100644
index 00000000..fdc4b7e1
--- /dev/null
+++ b/tests/phpunit/includes/logging/MoveLogFormatterTest.php
@@ -0,0 +1,270 @@
+<?php
+
+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 array(
+ // Current format - with redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move',
+ 'comment' => 'move comment with redirect',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ '4::target' => 'NewPage',
+ '5::noredir' => '0',
+ ),
+ ),
+ array(
+ 'text' => 'User moved page OldPage to NewPage',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => false,
+ ),
+ ),
+ ),
+
+ // Current format - without redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ '4::target' => 'NewPage',
+ '5::noredir' => '1',
+ ),
+ ),
+ array(
+ 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => true,
+ ),
+ ),
+ ),
+
+ // legacy format - with redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ '',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => false,
+ ),
+ ),
+ ),
+
+ // legacy format - without redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ '1',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage without leaving a redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => true,
+ ),
+ ),
+ ),
+
+ // old format without flag for redirect suppression
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage',
+ 'api' => array(
+ '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 array(
+ // Current format - with redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move_redir',
+ 'comment' => 'move comment with redirect',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ '4::target' => 'NewPage',
+ '5::noredir' => '0',
+ ),
+ ),
+ array(
+ 'text' => 'User moved page OldPage to NewPage over redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => false,
+ ),
+ ),
+ ),
+
+ // Current format - without redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move_redir',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ '4::target' => 'NewPage',
+ '5::noredir' => '1',
+ ),
+ ),
+ array(
+ 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => true,
+ ),
+ ),
+ ),
+
+ // legacy format - with redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move_redir',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ '',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage over redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => false,
+ ),
+ ),
+ ),
+
+ // legacy format - without redirect
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move_redir',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ '1',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage over a redirect without leaving a redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => true,
+ ),
+ ),
+ ),
+
+ // old format without flag for redirect suppression
+ array(
+ array(
+ 'type' => 'move',
+ 'action' => 'move_redir',
+ 'comment' => 'move comment',
+ 'namespace' => NS_MAIN,
+ 'title' => 'OldPage',
+ 'params' => array(
+ 'NewPage',
+ ),
+ ),
+ array(
+ 'legacy' => true,
+ 'text' => 'User moved page OldPage to NewPage over redirect',
+ 'api' => array(
+ 'target_ns' => 0,
+ 'target_title' => 'NewPage',
+ 'suppressredirect' => false,
+ ),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider provideMoveRedirLogDatabaseRows
+ */
+ public function testMoveRedirLogDatabaseRows( $row, $extra ) {
+ $this->doTestLogFormatter( $row, $extra );
+ }
+}