https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen > Given all called methods are de-facto and liberally claimed, and > that we keep the coverage limited to the subject class, it maintains > the spirit and intent by listing the class explicitly instead. > > PHPUnit offers a more precise tool when you need it (i.e. when testing > legacy monster/god classes), but for well-written code, the > class-wide tag is exactly what you want. > > We lose useful coverage and waste valuable time on keeping tags > accurate through refactors (or worse, forget to do so). > Tracking tiny per-method details wastes time in realizing (and > fixing) when people inevitably don't keep them in sync, and time > lost in finding uncovered code to write tests to realize it was > already covered but "not yet claimed". While at it, also fix PHPUnit warnings in CssContentHandlerIntegrationTest and JavaScriptContentHandlerIntegrationTest about not having any `@covers` annotations. Change-Id: I5afd9fe0bca0fa86cc096f6e5e79f2ba1cfbfa77
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Content\CssContent;
|
|
use MediaWiki\Content\CssContentHandler;
|
|
use MediaWiki\MainConfigNames;
|
|
use MediaWiki\Title\Title;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Content\CssContentHandler
|
|
*/
|
|
class CssContentHandlerTest extends MediaWikiLangTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideMakeRedirectContent
|
|
*/
|
|
public function testMakeRedirectContent( int $namespace, string $title, $expected ) {
|
|
$this->overrideConfigValues( [
|
|
MainConfigNames::Server => '//example.org',
|
|
MainConfigNames::Script => '/w/index.php',
|
|
] );
|
|
$ch = new CssContentHandler();
|
|
$content = $ch->makeRedirectContent( Title::makeTitle( $namespace, $title ) );
|
|
$this->assertInstanceOf( CssContent::class, $content );
|
|
$this->assertEquals( $expected, $content->serialize( CONTENT_FORMAT_CSS ) );
|
|
}
|
|
|
|
/**
|
|
* Keep this in sync with CssContentTest::provideGetRedirectTarget()
|
|
*/
|
|
public static function provideMakeRedirectContent() {
|
|
return [
|
|
[
|
|
NS_MEDIAWIKI,
|
|
'MonoBook.css',
|
|
"/* #REDIRECT */@import url(//example.org/w/index.php?title=MediaWiki:MonoBook.css&action=raw&ctype=text/css);"
|
|
],
|
|
[
|
|
NS_USER,
|
|
'FooBar/common.css',
|
|
"/* #REDIRECT */@import url(//example.org/w/index.php?title=User:FooBar/common.css&action=raw&ctype=text/css);"
|
|
],
|
|
[
|
|
NS_USER,
|
|
'😂/unicode.css',
|
|
'/* #REDIRECT */@import url(//example.org/w/index.php?title=User:%F0%9F%98%82/unicode.css&action=raw&ctype=text/css);'
|
|
],
|
|
];
|
|
// phpcs:enable
|
|
}
|
|
}
|