diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jest/mediawiki.special.block/stores/block.test.js | 34 | ||||
-rw-r--r-- | tests/phpunit/includes/logging/BlockLogFormatterTest.php | 41 | ||||
-rw-r--r-- | tests/phpunit/includes/page/ParserOutputAccessTest.php | 6 | ||||
-rw-r--r-- | tests/phpunit/includes/session/PHPSessionHandlerTest.php | 2 | ||||
-rw-r--r-- | tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlOutputRendererHelperTest.php | 3 | ||||
-rw-r--r-- | tests/phpunit/integration/includes/filerepo/file/ForeignDBFileTest.php (renamed from tests/phpunit/unit/includes/filerepo/file/ForeignDBFileTest.php) | 2 |
6 files changed, 83 insertions, 5 deletions
diff --git a/tests/jest/mediawiki.special.block/stores/block.test.js b/tests/jest/mediawiki.special.block/stores/block.test.js index 1547f684526f..53e83d7c46a9 100644 --- a/tests/jest/mediawiki.special.block/stores/block.test.js +++ b/tests/jest/mediawiki.special.block/stores/block.test.js @@ -103,6 +103,40 @@ describe( 'Block store', () => { expect( store.formDisabled ).toBeFalsy(); } ); + it( 'should not send the allowusertalk API param when the disableUTEdit field is hidden', () => { + const jQuery = jest.requireActual( '../../../../resources/lib/jquery/jquery.js' ); + mw.Api.prototype.postWithEditToken.mockReturnValue( jQuery.Deferred().resolve().promise() ); + mockMwConfigGet( { blockDisableUTEditVisible: true } ); + const store = useBlockStore(); + + // Sitewide block can disable user talk page editing. + store.type = 'sitewide'; + store.disableUTEdit = true; + store.doBlock(); + const spy = jest.spyOn( mw.Api.prototype, 'postWithEditToken' ); + const expected = { + action: 'block', + nocreate: 1, + autoblock: 1, + errorlang: 'en', + errorsuselocal: true, + expiry: '', + format: 'json', + reason: '', + uselang: 'en', + user: '' + }; + expect( spy ).toHaveBeenCalledWith( expected ); + + // But a partial block cannot. + store.type = 'partial'; + store.doBlock(); + expected.partial = 1; + expected.actionrestrictions = ''; + expected.allowusertalk = 1; + expect( spy ).toHaveBeenCalledWith( expected ); + } ); + afterEach( () => { jest.clearAllMocks(); } ); diff --git a/tests/phpunit/includes/logging/BlockLogFormatterTest.php b/tests/phpunit/includes/logging/BlockLogFormatterTest.php index 422575e4cb28..4274fe3e7c97 100644 --- a/tests/phpunit/includes/logging/BlockLogFormatterTest.php +++ b/tests/phpunit/includes/logging/BlockLogFormatterTest.php @@ -704,4 +704,45 @@ class BlockLogFormatterTest extends LogFormatterTestCase { public function testPartialBlockLogDatabaseRows( $row, $extra ) { $this->doTestLogFormatter( $row, $extra ); } + + public static function provideMultiblocksDatabaseRows() { + return [ + // Sitewide multiblock with expiry + [ + [ + 'type' => 'block', + 'action' => 'block', + 'comment' => 'multiblock', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'Target', + 'timestamp' => '20240101000000', + 'params' => [ + '5::duration' => '1 day', + '6::flags' => '', + 'sitewide' => true, + 'finalTargetCount' => 2, + ] + ], + [ + 'text' => 'Sysop added a block for Target with an expiration time of 1 day', + 'api' => [ + 'duration' => '1 day', + 'flags' => [], + 'finalTargetCount' => 2, + 'sitewide' => true, + 'expiry' => '2024-01-02T00:00:00Z', + ] + ] + ], + ]; + } + + /** + * @dataProvider provideMultiblocksDatabaseRows + */ + public function testMultiblocksDatabaseRows( $row, $extra ) { + $this->doTestLogFormatter( $row, $extra ); + } } diff --git a/tests/phpunit/includes/page/ParserOutputAccessTest.php b/tests/phpunit/includes/page/ParserOutputAccessTest.php index b83e048ce1c9..eb357e6242c8 100644 --- a/tests/phpunit/includes/page/ParserOutputAccessTest.php +++ b/tests/phpunit/includes/page/ParserOutputAccessTest.php @@ -33,6 +33,7 @@ use Wikimedia\ObjectCache\WANObjectCache; use Wikimedia\Rdbms\ChronologyProtector; use Wikimedia\Rdbms\ILBFactory; use Wikimedia\Stats\StatsFactory; +use Wikimedia\Telemetry\TracerInterface; use Wikimedia\TestingAccessWrapper; /** @@ -210,6 +211,7 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase { LoggerFactory::getProvider(), $this->getServiceContainer()->getWikiPageFactory(), $this->getServiceContainer()->getTitleFormatter(), + $this->getServiceContainer()->getTracer(), $this ) extends ParserOutputAccess { private ParserOutputAccessTest $test; @@ -224,6 +226,7 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase { LoggerSpi $loggerSpi, WikiPageFactory $wikiPageFactory, TitleFormatter $titleFormatter, + TracerInterface $tracer, ParserOutputAccessTest $test ) { parent::__construct( @@ -235,7 +238,8 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase { $chronologyProtector, $loggerSpi, $wikiPageFactory, - $titleFormatter + $titleFormatter, + $tracer ); $this->test = $test; diff --git a/tests/phpunit/includes/session/PHPSessionHandlerTest.php b/tests/phpunit/includes/session/PHPSessionHandlerTest.php index d2b595adf1c2..e215697edf01 100644 --- a/tests/phpunit/includes/session/PHPSessionHandlerTest.php +++ b/tests/phpunit/includes/session/PHPSessionHandlerTest.php @@ -74,7 +74,6 @@ class PHPSessionHandlerTest extends MediaWikiIntegrationTestCase { session_write_close(); ini_set( 'session.use_cookies', 1 ); - ini_set( 'session.use_trans_sid', 1 ); $store = new TestBagOStuff(); // Tolerate debug message, anything else is unexpected @@ -91,7 +90,6 @@ class PHPSessionHandlerTest extends MediaWikiIntegrationTestCase { $this->assertTrue( PHPSessionHandler::isInstalled() ); $this->assertFalse( wfIniGetBool( 'session.use_cookies' ) ); - $this->assertFalse( wfIniGetBool( 'session.use_trans_sid' ) ); $this->assertNotNull( $staticAccess->instance ); $priv = TestingAccessWrapper::newFromObject( $staticAccess->instance ); diff --git a/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlOutputRendererHelperTest.php b/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlOutputRendererHelperTest.php index 8852b2002882..31966155af8b 100644 --- a/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlOutputRendererHelperTest.php +++ b/tests/phpunit/integration/includes/Rest/Handler/Helper/HtmlOutputRendererHelperTest.php @@ -860,7 +860,8 @@ class HtmlOutputRendererHelperTest extends MediaWikiIntegrationTestCase { $services->getChronologyProtector(), $this->getLoggerSpi(), $services->getWikiPageFactory(), - $services->getTitleFormatter() + $services->getTitleFormatter(), + $services->getTracer() ); return [ 'ParserOutputAccess' => $parserOutputAccess, diff --git a/tests/phpunit/unit/includes/filerepo/file/ForeignDBFileTest.php b/tests/phpunit/integration/includes/filerepo/file/ForeignDBFileTest.php index 770d44cdffcf..fb890e656d9d 100644 --- a/tests/phpunit/unit/includes/filerepo/file/ForeignDBFileTest.php +++ b/tests/phpunit/integration/includes/filerepo/file/ForeignDBFileTest.php @@ -3,7 +3,7 @@ use MediaWiki\Title\Title; /** @covers \ForeignDBFile */ -class ForeignDBFileTest extends MediaWikiUnitTestCase { +class ForeignDBFileTest extends MediaWikiIntegrationTestCase { public function testShouldConstructCorrectInstanceFromTitle() { $title = Title::makeTitle( NS_FILE, 'Awesome_file' ); |