From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../includes/logging/RightsLogFormatterTest.php | 157 +++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 tests/phpunit/includes/logging/RightsLogFormatterTest.php (limited to 'tests/phpunit/includes/logging/RightsLogFormatterTest.php') diff --git a/tests/phpunit/includes/logging/RightsLogFormatterTest.php b/tests/phpunit/includes/logging/RightsLogFormatterTest.php new file mode 100644 index 00000000..e9577f11 --- /dev/null +++ b/tests/phpunit/includes/logging/RightsLogFormatterTest.php @@ -0,0 +1,157 @@ + 'rights', + 'action' => 'rights', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'User', + 'params' => array( + '4::oldgroups' => array(), + '5::newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + array( + 'text' => 'Sysop changed group membership for User:User from (none) to ' + . 'administrator and bureaucrat', + 'api' => array( + 'oldgroups' => array(), + 'newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + ), + + // Legacy format + array( + array( + 'type' => 'rights', + 'action' => 'rights', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'User', + 'params' => array( + '', + 'sysop, bureaucrat', + ), + ), + array( + 'legacy' => true, + 'text' => 'Sysop changed group membership for User:User from (none) to ' + . 'administrator and bureaucrat', + 'api' => array( + 'oldgroups' => array(), + 'newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + ), + + // Really old entry + array( + array( + 'type' => 'rights', + 'action' => 'rights', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'User', + 'params' => array(), + ), + array( + 'legacy' => true, + 'text' => 'Sysop changed group membership for User:User', + 'api' => array(), + ), + ), + ); + } + + /** + * @dataProvider provideRightsLogDatabaseRows + */ + public function testRightsLogDatabaseRows( $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 provideAutopromoteLogDatabaseRows() { + return array( + // Current format + array( + array( + 'type' => 'rights', + 'action' => 'autopromote', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'Sysop', + 'params' => array( + '4::oldgroups' => array( 'sysop' ), + '5::newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + array( + 'text' => 'Sysop was automatically promoted from administrator to ' + . 'administrator and bureaucrat', + 'api' => array( + 'oldgroups' => array( 'sysop' ), + 'newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + ), + + // Legacy format + array( + array( + 'type' => 'rights', + 'action' => 'autopromote', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'Sysop', + 'params' => array( + 'sysop', + 'sysop, bureaucrat', + ), + ), + array( + 'legacy' => true, + 'text' => 'Sysop was automatically promoted from administrator to ' + . 'administrator and bureaucrat', + 'api' => array( + 'oldgroups' => array( 'sysop' ), + 'newgroups' => array( 'sysop', 'bureaucrat' ), + ), + ), + ), + ); + } + + /** + * @dataProvider provideAutopromoteLogDatabaseRows + */ + public function testAutopromoteLogDatabaseRows( $row, $extra ) { + $this->doTestLogFormatter( $row, $extra ); + } +} -- cgit v1.2.3-54-g00ecf