From ec104811c6a1f40d6031f3858ab50d397fe6e060 Mon Sep 17 00:00:00 2001 From: SBassett Date: Sat, 22 Jun 2019 12:25:14 +0000 Subject: [PATCH] Revert "Fix testsuites for LogFormatter" This reverts commit d0c2da82616a280f51feafa015dd67608c13e29b. Reason for revert: Original patch set appeared to work then began failing multiple CI builds post-merge. Simply reverting for now due for T226293. Big: T226293 Change-Id: I3e33300cecfe87926fcb8851689d67c3b1258b0f --- .../logging/BlockLogFormatterTest.php | 150 ---------- .../logging/DeleteLogFormatterTest.php | 263 ------------------ .../includes/logging/LogFormatterTestCase.php | 6 +- 3 files changed, 1 insertion(+), 418 deletions(-) diff --git a/tests/phpunit/includes/logging/BlockLogFormatterTest.php b/tests/phpunit/includes/logging/BlockLogFormatterTest.php index 1d653281e6..bc0ca2ad85 100644 --- a/tests/phpunit/includes/logging/BlockLogFormatterTest.php +++ b/tests/phpunit/includes/logging/BlockLogFormatterTest.php @@ -307,81 +307,6 @@ class BlockLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressBlockLogDatabaseRows */ public function testSuppressBlockLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', - [ - 'oversight' => [ - 'viewsuppressed' => true, - 'suppressionlog' => true, - ], - ] - ); - $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] ); - } - - /** - * 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 provideSuppressBlockLogDatabaseRowsNonPrivileged() { - return [ - // Current log format - [ - [ - 'type' => 'suppress', - 'action' => 'block', - 'comment' => 'Block comment', - 'user' => 0, - 'user_text' => 'Sysop', - 'namespace' => NS_USER, - 'title' => 'Logtestuser', - 'params' => [ - '5::duration' => 'infinite', - '6::flags' => 'anononly', - ], - ], - [ - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'duration' => 'infinite', - 'flags' => [ 'anononly' ], - ], - ], - ], - - // legacy log - [ - [ - 'type' => 'suppress', - 'action' => 'block', - 'comment' => 'Block comment', - 'user' => 0, - 'user_text' => 'Sysop', - 'namespace' => NS_USER, - 'title' => 'Logtestuser', - 'params' => [ - 'infinite', - 'anononly', - ], - ], - [ - 'legacy' => true, - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'duration' => 'infinite', - 'flags' => [ 'anononly' ], - ], - ], - ], - ]; - } - - /** - * @dataProvider provideSuppressBlockLogDatabaseRowsNonPrivileged - */ - public function testSuppressBlockLogDatabaseRowsNonPrivileged( $row, $extra ) { - $this->user = $this->getTestUser()->getUser(); $this->doTestLogFormatter( $row, $extra ); } @@ -449,81 +374,6 @@ class BlockLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressReblockLogDatabaseRows */ public function testSuppressReblockLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', - [ - 'oversight' => [ - 'viewsuppressed' => true, - 'suppressionlog' => true, - ], - ] - ); - $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] ); - } - - /** - * 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 provideSuppressReblockLogDatabaseRowsNonPrivileged() { - return [ - // Current log format - [ - [ - 'type' => 'suppress', - 'action' => 'reblock', - 'comment' => 'Block comment', - 'user' => 0, - 'user_text' => 'Sysop', - 'namespace' => NS_USER, - 'title' => 'Logtestuser', - 'params' => [ - '5::duration' => 'infinite', - '6::flags' => 'anononly', - ], - ], - [ - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'duration' => 'infinite', - 'flags' => [ 'anononly' ], - ], - ], - ], - - // Legacy format - [ - [ - 'type' => 'suppress', - 'action' => 'reblock', - 'comment' => 'Block comment', - 'user' => 0, - 'user_text' => 'Sysop', - 'namespace' => NS_USER, - 'title' => 'Logtestuser', - 'params' => [ - 'infinite', - 'anononly', - ], - ], - [ - 'legacy' => true, - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'duration' => 'infinite', - 'flags' => [ 'anononly' ], - ], - ], - ], - ]; - } - - /** - * @dataProvider provideSuppressReblockLogDatabaseRowsNonPrivileged - */ - public function testSuppressReblockLogDatabaseRowsNonPrivileged( $row, $extra ) { - $this->user = $this->getTestUser()->getUser(); $this->doTestLogFormatter( $row, $extra ); } diff --git a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php index f1d58fdf09..6648c31c25 100644 --- a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php +++ b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php @@ -409,109 +409,6 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressRevisionLogDatabaseRows */ public function testSuppressRevisionLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', - [ - 'oversight' => [ - 'viewsuppressed' => true, - 'suppressionlog' => true, - ], - ] - ); - $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] ); - } - - /** - * 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 provideSuppressRevisionLogDatabaseRowsNonPrivileged() { - return [ - // Current format - [ - [ - 'type' => 'suppress', - 'action' => 'revision', - 'comment' => 'Suppress comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [ - '4::type' => 'archive', - '5::ids' => [ '1', '3', '4' ], - '6::ofield' => '1', - '7::nfield' => '10', - ], - ], - [ - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'type' => 'archive', - 'ids' => [ '1', '3', '4' ], - 'old' => [ - 'bitmask' => 1, - 'content' => true, - 'comment' => false, - 'user' => false, - 'restricted' => false, - ], - 'new' => [ - 'bitmask' => 10, - 'content' => false, - 'comment' => true, - 'user' => false, - 'restricted' => true, - ], - ], - ], - ], - - // Legacy format - [ - [ - 'type' => 'suppress', - 'action' => 'revision', - 'comment' => 'Suppress comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [ - 'archive', - '1,3,4', - 'ofield=1', - 'nfield=10', - ], - ], - [ - 'legacy' => true, - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'type' => 'archive', - 'ids' => [ '1', '3', '4' ], - 'old' => [ - 'bitmask' => 1, - 'content' => true, - 'comment' => false, - 'user' => false, - 'restricted' => false, - ], - 'new' => [ - 'bitmask' => 10, - 'content' => false, - 'comment' => true, - 'user' => false, - 'restricted' => true, - ], - ], - ], - ], - ]; - } - - /** - * @dataProvider provideSuppressRevisionLogDatabaseRowsNonPrivileged - */ - public function testSuppressRevisionLogDatabaseRowsNonPrivileged( $row, $extra ) { - $this->user = $this->getTestUser()->getUser(); $this->doTestLogFormatter( $row, $extra ); } @@ -626,107 +523,6 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressEventLogDatabaseRows */ public function testSuppressEventLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', - [ - 'oversight' => [ - 'viewsuppressed' => true, - 'suppressionlog' => true, - ], - ] - ); - $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] ); - } - - /** - * 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 provideSuppressEventLogDatabaseRowsNonPrivileged() { - return [ - // Current format - [ - [ - 'type' => 'suppress', - 'action' => 'event', - 'comment' => 'Suppress comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [ - '4::ids' => [ '1', '3', '4' ], - '5::ofield' => '1', - '6::nfield' => '10', - ], - ], - [ - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'type' => 'logging', - 'ids' => [ '1', '3', '4' ], - 'old' => [ - 'bitmask' => 1, - 'content' => true, - 'comment' => false, - 'user' => false, - 'restricted' => false, - ], - 'new' => [ - 'bitmask' => 10, - 'content' => false, - 'comment' => true, - 'user' => false, - 'restricted' => true, - ], - ], - ], - ], - - // Legacy format - [ - [ - 'type' => 'suppress', - 'action' => 'event', - 'comment' => 'Suppress comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [ - '1,3,4', - 'ofield=1', - 'nfield=10', - ], - ], - [ - 'legacy' => true, - 'text' => '(username removed) (log details removed)', - 'api' => [ - 'type' => 'logging', - 'ids' => [ '1', '3', '4' ], - 'old' => [ - 'bitmask' => 1, - 'content' => true, - 'comment' => false, - 'user' => false, - 'restricted' => false, - ], - 'new' => [ - 'bitmask' => 10, - 'content' => false, - 'comment' => true, - 'user' => false, - 'restricted' => true, - ], - ], - ], - ], - ]; - } - - /** - * @dataProvider provideSuppressEventLogDatabaseRowsNonPrivileged - */ - public function testSuppressEventLogDatabaseRowsNonPrivileged( $row, $extra ) { - $this->user = $this->getTestUser()->getUser(); $this->doTestLogFormatter( $row, $extra ); } @@ -776,65 +572,6 @@ class DeleteLogFormatterTest extends LogFormatterTestCase { * @dataProvider provideSuppressDeleteLogDatabaseRows */ public function testSuppressDeleteLogDatabaseRows( $row, $extra ) { - $this->setMwGlobals( - 'wgGroupPermissions', - [ - 'oversight' => [ - 'viewsuppressed' => true, - 'suppressionlog' => true, - ], - ] - ); - $this->doTestLogFormatter( $row, $extra, [ 'oversight' ] ); - } - - /** - * 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 provideSuppressDeleteLogDatabaseRowsNonPrivileged() { - return [ - // Current format - [ - [ - 'type' => 'suppress', - 'action' => 'delete', - 'comment' => 'delete comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [], - ], - [ - 'text' => '(username removed) (log details removed)', - 'api' => [], - ], - ], - - // Legacy format - [ - [ - 'type' => 'suppress', - 'action' => 'delete', - 'comment' => 'delete comment', - 'namespace' => NS_MAIN, - 'title' => 'Page', - 'params' => [], - ], - [ - 'legacy' => true, - 'text' => '(username removed) (log details removed)', - 'api' => [], - ], - ], - ]; - } - - /** - * @dataProvider provideSuppressDeleteLogDatabaseRowsNonPrivileged - */ - public function testSuppressDeleteLogDatabaseRowsNonPrivileged( $row, $extra ) { - $this->user = $this->getTestUser()->getUser(); $this->doTestLogFormatter( $row, $extra ); } } diff --git a/tests/phpunit/includes/logging/LogFormatterTestCase.php b/tests/phpunit/includes/logging/LogFormatterTestCase.php index 71ab14783a..883af71240 100644 --- a/tests/phpunit/includes/logging/LogFormatterTestCase.php +++ b/tests/phpunit/includes/logging/LogFormatterTestCase.php @@ -5,15 +5,11 @@ */ abstract class LogFormatterTestCase extends MediaWikiLangTestCase { - public function doTestLogFormatter( $row, $extra, $userGroups = [] ) { + public function doTestLogFormatter( $row, $extra ) { RequestContext::resetMain(); $row = $this->expandDatabaseRow( $row, $this->isLegacy( $extra ) ); - $context = new RequestContext(); - $context->setUser( $this->getTestUser( $userGroups )->getUser() ); - $formatter = LogFormatter::newFromRow( $row ); - $formatter->setContext( $context ); $this->assertEquals( $extra['text'], -- 2.20.1