"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/phpunit/includes/LinkerTest.php" between
mediawiki-1.31.1.tar.gz and mediawiki-1.32.0.tar.gz

About: MediaWiki is a wiki engine (the collaborative editing software that runs for e.g. Wikipedia, the free encyclopedia).

LinkerTest.php  (mediawiki-1.31.1):LinkerTest.php  (mediawiki-1.32.0)
<?php <?php
use MediaWiki\MediaWikiServices;
/** /**
* @group Database * @group Database
*/ */
class LinkerTest extends MediaWikiLangTestCase { class LinkerTest extends MediaWikiLangTestCase {
/** /**
* @dataProvider provideCasesForUserLink * @dataProvider provideCasesForUserLink
* @covers Linker::userLink * @covers Linker::userLink
*/ */
public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) { public function testUserLink( $expected, $userId, $userName, $altUserName = false, $msg = '' ) {
skipping to change at line 299 skipping to change at line 297
public static function provideCasesForFormatLinksInComment() { public static function provideCasesForFormatLinksInComment() {
// phpcs:disable Generic.Files.LineLength // phpcs:disable Generic.Files.LineLength
return [ return [
[ [
'foo bar <a href="/wiki/Special:BlankPage" title= "Special:BlankPage">Special:BlankPage</a>', 'foo bar <a href="/wiki/Special:BlankPage" title= "Special:BlankPage">Special:BlankPage</a>',
'foo bar [[Special:BlankPage]]', 'foo bar [[Special:BlankPage]]',
null, null,
], ],
[ [
'<a href="/wiki/Special:BlankPage" title="Special
:BlankPage">Special:BlankPage</a>',
'[[ :Special:BlankPage]]',
null,
],
[
'<a class="external" rel="nofollow" href="//en.ex ample.org/w/Foo%27bar">Foo\'bar</a>', '<a class="external" rel="nofollow" href="//en.ex ample.org/w/Foo%27bar">Foo\'bar</a>',
"[[Foo'bar]]", "[[Foo'bar]]",
'enwiki', 'enwiki',
], ],
[ [
'foo bar <a class="external" rel="nofollow" href= "//en.example.org/w/Special:BlankPage">Special:BlankPage</a>', 'foo bar <a class="external" rel="nofollow" href= "//en.example.org/w/Special:BlankPage">Special:BlankPage</a>',
'foo bar [[Special:BlankPage]]', 'foo bar [[Special:BlankPage]]',
'enwiki', 'enwiki',
], ],
[ [
skipping to change at line 373 skipping to change at line 376
], ],
]; ];
// phpcs:enable // phpcs:enable
} }
/** /**
* @covers MediaWiki\Linker\LinkRenderer::runLegacyBeginHook * @covers MediaWiki\Linker\LinkRenderer::runLegacyBeginHook
* @dataProvider provideLinkBeginHook * @dataProvider provideLinkBeginHook
*/ */
public function testLinkBeginHook( $callback, $expected ) { public function testLinkBeginHook( $callback, $expected ) {
$this->hideDeprecated( 'LinkBegin hook (used in hook-LinkBegin-cl osure)' );
$this->setMwGlobals( [ $this->setMwGlobals( [
'wgArticlePath' => '/wiki/$1', 'wgArticlePath' => '/wiki/$1',
'wgServer' => '//example.org', 'wgServer' => '//example.org',
'wgCanonicalServer' => 'http://example.org', 'wgCanonicalServer' => 'http://example.org',
'wgScriptPath' => '/w', 'wgScriptPath' => '/w',
'wgScript' => '/w/index.php', 'wgScript' => '/w/index.php',
] ); ] );
$this->setMwGlobals( 'wgHooks', [ 'LinkBegin' => [ $callback ] ] ); $this->setMwGlobals( 'wgHooks', [ 'LinkBegin' => [ $callback ] ] );
$title = SpecialPage::getTitleFor( 'Blankpage' ); $title = SpecialPage::getTitleFor( 'Blankpage' );
skipping to change at line 420 skipping to change at line 424
], ],
]; ];
} }
/** /**
* @covers MediaWiki\Linker\LinkRenderer::buildAElement * @covers MediaWiki\Linker\LinkRenderer::buildAElement
* @dataProvider provideLinkEndHook * @dataProvider provideLinkEndHook
*/ */
public function testLinkEndHook( $callback, $expected ) { public function testLinkEndHook( $callback, $expected ) {
$this->hideDeprecated( 'LinkEnd hook (used in hook-LinkEnd-closur e)' );
$this->setMwGlobals( [ $this->setMwGlobals( [
'wgArticlePath' => '/wiki/$1', 'wgArticlePath' => '/wiki/$1',
] ); ] );
$this->setMwGlobals( 'wgHooks', [ 'LinkEnd' => [ $callback ] ] ); $this->setMwGlobals( 'wgHooks', [ 'LinkEnd' => [ $callback ] ] );
$title = SpecialPage::getTitleFor( 'Blankpage' ); $title = SpecialPage::getTitleFor( 'Blankpage' );
$out = Linker::link( $title ); $out = Linker::link( $title );
$this->assertEquals( $expected, $out ); $this->assertEquals( $expected, $out );
} }
/**
* @covers Linker::getLinkColour
*/
public function testGetLinkColour() {
$this->hideDeprecated( 'Linker::getLinkColour' );
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
$foobarTitle = Title::makeTitle( NS_MAIN, 'FooBar' );
$redirectTitle = Title::makeTitle( NS_MAIN, 'Redirect' );
$userTitle = Title::makeTitle( NS_USER, 'Someuser' );
$linkCache->addGoodLinkObj(
1, // id
$foobarTitle,
10, // len
0 // redir
);
$linkCache->addGoodLinkObj(
2, // id
$redirectTitle,
10, // len
1 // redir
);
$linkCache->addGoodLinkObj(
3, // id
$userTitle,
10, // len
0 // redir
);
$this->assertEquals(
'',
Linker::getLinkColour( $foobarTitle, 0 )
);
$this->assertEquals(
'stub',
Linker::getLinkColour( $foobarTitle, 20 )
);
$this->assertEquals(
'mw-redirect',
Linker::getLinkColour( $redirectTitle, 0 )
);
$this->assertEquals(
'',
Linker::getLinkColour( $userTitle, 20 )
);
}
} }
 End of changes. 5 change blocks. 
52 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)