Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Revision;
|
|
|
|
use MediaWiki\Page\PageIdentity;
|
|
use MediaWiki\Page\PageIdentityValue;
|
|
use MediaWiki\Revision\MutableRevisionRecord;
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
use MediaWiki\Title\Title;
|
|
use MediaWiki\Title\TitleValue;
|
|
use MediaWikiIntegrationTestCase;
|
|
use MockTitleTrait;
|
|
use Wikimedia\Assert\PreconditionException;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Revision\MutableRevisionRecord
|
|
* @covers \MediaWiki\Revision\RevisionRecord
|
|
*/
|
|
class MutableRevisionRecordTest extends MediaWikiIntegrationTestCase {
|
|
use MockTitleTrait;
|
|
|
|
public static function provideConstructor() {
|
|
$title = Title::makeTitle( NS_MAIN, 'Dummy' );
|
|
$title->resetArticleID( 17 );
|
|
yield 'local wiki, with title' => [ $title, PageIdentity::LOCAL ];
|
|
yield 'local wiki' => [
|
|
new PageIdentityValue( 17, NS_MAIN, 'Dummy', PageIdentity::LOCAL ),
|
|
PageIdentity::LOCAL,
|
|
];
|
|
yield 'foreign wiki' => [
|
|
new PageIdentityValue( 17, NS_MAIN, 'Dummy', 'acmewiki' ),
|
|
'acmewiki',
|
|
PreconditionException::class
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideConstructor
|
|
*
|
|
* @param PageIdentity $page
|
|
* @param string|false $wikiId
|
|
* @param string|null $expectedException
|
|
*/
|
|
public function testConstructorAndGetters(
|
|
PageIdentity $page,
|
|
$wikiId = RevisionRecord::LOCAL,
|
|
?string $expectedException = null
|
|
) {
|
|
$rec = new MutableRevisionRecord( $page, $wikiId );
|
|
|
|
$this->assertTrue( $page->isSamePageAs( $rec->getPage() ), 'getPage' );
|
|
$this->assertSame( $wikiId, $rec->getWikiId(), 'getWikiId' );
|
|
|
|
if ( $expectedException ) {
|
|
$this->expectException( $expectedException );
|
|
$rec->getPageAsLinkTarget();
|
|
} else {
|
|
$this->assertTrue(
|
|
TitleValue::newFromPage( $page )->isSameLinkAs( $rec->getPageAsLinkTarget() ),
|
|
'getPageAsLinkTarget'
|
|
);
|
|
}
|
|
}
|
|
}
|