* @covers Fallback
*/
class FallbackTest extends MediaWikiTestCase {
-
public function testFallbackMbstringFunctions() {
-
if ( !extension_loaded( 'mbstring' ) ) {
- $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" );
+ $this->markTestSkipped(
+ "The mb_string functions must be installed to test the fallback functions"
+ );
}
$sampleUTF = "Östergötland_coat_of_arms.png";
<?php
class FauxRequestTest extends MediaWikiTestCase {
-
/**
* @covers FauxRequest::setHeader
* @covers FauxRequest::getHeader
$this->assertEquals( null, $this->response->getheader( 'Location' ), 'Non-existing header' );
$this->response->header( 'Location: http://localhost/' );
- $this->assertEquals( 'http://localhost/', $this->response->getheader( 'Location' ), 'Set header' );
+ $this->assertEquals(
+ 'http://localhost/',
+ $this->response->getheader( 'Location' ),
+ 'Set header'
+ );
$this->response->header( 'Location: http://127.0.0.1/' );
- $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header' );
+ $this->assertEquals(
+ 'http://127.0.0.1/',
+ $this->response->getheader( 'Location' ),
+ 'Same header'
+ );
$this->response->header( 'Location: http://127.0.0.2/', false );
- $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header with override disabled' );
+ $this->assertEquals(
+ 'http://127.0.0.1/',
+ $this->response->getheader( 'Location' ),
+ 'Same header with override disabled'
+ );
$this->response->header( 'Location: http://localhost/' );
- $this->assertEquals( 'http://localhost/', $this->response->getheader( 'LOCATION' ), 'Get header case insensitive' );
+ $this->assertEquals(
+ 'http://localhost/',
+ $this->response->getheader( 'LOCATION' ),
+ 'Get header case insensitive'
+ );
}
/**
$this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
$this->response->header( 'HTTP/1.x 201' );
- $this->assertEquals( 201, $this->response->getStatusCode(), 'Header with no message and protocol 1.x' );
+ $this->assertEquals(
+ 201,
+ $this->response->getStatusCode(),
+ 'Header with no message and protocol 1.x'
+ );
$this->response->header( 'HTTP/1.1 202 OK' );
$this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
$this->response->header( 'HTTP/1.x 203 OK' );
- $this->assertEquals( 203, $this->response->getStatusCode(), 'Normal header with no message and protocol 1.x' );
+ $this->assertEquals(
+ 203,
+ $this->response->getStatusCode(),
+ 'Normal header with no message and protocol 1.x'
+ );
$this->response->header( 'HTTP/1.x 204 OK', false, 205 );
- $this->assertEquals( 205, $this->response->getStatusCode(), 'Third parameter overrides the HTTP/... header' );
+ $this->assertEquals(
+ 205,
+ $this->response->getStatusCode(),
+ 'Third parameter overrides the HTTP/... header'
+ );
$this->response->header( 'Location: http://localhost/', false, 206 );
- $this->assertEquals( 206, $this->response->getStatusCode(), 'Third parameter with another header' );
+ $this->assertEquals(
+ 206,
+ $this->response->getStatusCode(),
+ 'Third parameter with another header'
+ );
}
}
$i = new NothingClass();
return array(
- array( 'Object and method', array( $i, 'someNonStatic' ), 'changed-nonstatic', 'changed-nonstatic' ),
+ array(
+ 'Object and method',
+ array( $i, 'someNonStatic' ),
+ 'changed-nonstatic',
+ 'changed-nonstatic'
+ ),
array( 'Object and no method', array( $i ), 'changed-onevent', 'original' ),
- array( 'Object and method with data', array( $i, 'someNonStaticWithData', 'data' ), 'data', 'original' ),
+ array(
+ 'Object and method with data',
+ array( $i, 'someNonStaticWithData', 'data' ),
+ 'data',
+ 'original'
+ ),
array( 'Object and static method', array( $i, 'someStatic' ), 'changed-static', 'original' ),
- array( 'Class::method static call', array( 'NothingClass::someStatic' ), 'changed-static', 'original' ),
+ array(
+ 'Class::method static call',
+ array( 'NothingClass::someStatic' ),
+ 'changed-static',
+ 'original'
+ ),
array( 'Global function', array( 'NothingFunction' ), 'changed-func', 'original' ),
array( 'Global function with data', array( 'NothingFunctionData', 'data' ), 'data', 'original' ),
array( 'Closure', array( function ( &$foo, $bar ) {
$b = new NothingClass();
$wgHooks['MediaWikiHooksTest001'][] = $a;
- $this->assertTrue( Hooks::isRegistered( 'MediaWikiHooksTest001' ), 'Hook registered via $wgHooks should be noticed by Hooks::isRegistered' );
+ $this->assertTrue(
+ Hooks::isRegistered( 'MediaWikiHooksTest001' ),
+ 'Hook registered via $wgHooks should be noticed by Hooks::isRegistered'
+ );
Hooks::register( 'MediaWikiHooksTest001', $b );
- $this->assertEquals( 2, count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ), 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register' );
+ $this->assertEquals(
+ 2,
+ count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ),
+ 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register'
+ );
$foo = 'quux';
$bar = 'qaax';
Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
- $this->assertEquals( 1, $a->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
- $this->assertEquals( 1, $b->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
+ $this->assertEquals(
+ 1,
+ $a->calls,
+ 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+ );
+ $this->assertEquals(
+ 1,
+ $b->calls,
+ 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+ );
}
/**
* @dataProvider getHtmlData
* @covers HtmlFormatter::getText
*/
- public function testTransform( $input, $expectedText, $expectedRemoved = array(), $callback = false ) {
+ public function testTransform( $input, $expectedText,
+ $expectedRemoved = array(), $callback = false
+ ) {
$input = self::normalize( $input );
$formatter = new HtmlFormatter( HtmlFormatter::wrapHTML( $input ) );
if ( $callback ) {
),
// basic tag removal
array(
+ // @codingStandardsIgnoreStart Ignore long line warnings.
'<table><tr><td>foo</td></tr></table><div class="foo">foo</div><div class="foo quux">foo</div><span id="bar">bar</span>
<strong class="foo" id="bar">foobar</strong><div class="notfoo">test</div><div class="baz"/>
<span class="baz">baz</span>',
+ // @codingStandardsIgnoreEnd
'<div class="notfoo">test</div>
<span class="baz">baz</span>',
array(
),
// https://bugzilla.wikimedia.org/show_bug.cgi?id=53086
array(
- 'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
- 'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup> <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
+ 'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>'
+ . ' <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
+ 'Foo<sup id="cite_ref-1" class="reference"><a href="#cite_note-1">[1]</a></sup>'
+ . ' <a href="/wiki/Bar" title="Bar" class="mw-redirect">Bar</a>',
),
);
}
# see remarks on http://msdn.microsoft.com/en-us/library/ie/ms535211%28v=vs.85%29.aspx
$cases[] = array( '<button type=submit></button>',
'button', array( 'type' => 'submit' ),
- 'According to standard the default type is "submit". Depending on compatibility mode IE might use "button", instead.',
+ 'According to standard the default type is "submit". '
+ . 'Depending on compatibility mode IE might use "button", instead.',
);
# <select> specifc handling
*/
public function testFormValidationBlacklist() {
$this->assertEmpty(
- Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 2 ) ),
+ Html::expandAttributes( array(
+ 'min' => 1,
+ 'max' => 100,
+ 'pattern' => 'abc',
+ 'required' => true,
+ 'step' => 2
+ ) ),
'Blacklist form validation attributes.'
);
$this->assertEquals(
' step=any',
- Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 'any' ) ),
+ Html::expandAttributes( array(
+ 'min' => 1,
+ 'max' => 100,
+ 'pattern' => 'abc',
+ 'required' => true,
+ 'step' => 'any'
+ ) ,
'Allow special case "step=any".'
- );
+ ) );
}
}
* Class to let us overwrite MWHttpRequest respHeaders variable
*/
class MWHttpRequestTester extends MWHttpRequest {
-
// function derived from the MWHttpRequest factory function but
// returns appropriate tester class here
public static function factory( $url, $options = null ) {
return new CurlHttpRequestTester( $url, $options );
case 'php':
if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
- throw new MWException( __METHOD__ . ': allow_url_fopen needs to be enabled for pure PHP' .
- ' http requests to work. If possible, curl should be used instead. See http://php.net/curl.' );
+ throw new MWException( __METHOD__ .
+ ': allow_url_fopen needs to be enabled for pure PHP HTTP requests to work. '
+ . 'If possible, curl should be used instead. See http://php.net/curl.' );
}
return new PhpHttpRequestTester( $url, $options );
### ANONYMOUS USER ########################################
array(
- '<a href="/wiki/Special:Contributions/JohnDoe" title="Special:Contributions/JohnDoe" class="mw-userlink mw-anonuserlink">JohnDoe</a>',
+ '<a href="/wiki/Special:Contributions/JohnDoe" '
+ . 'title="Special:Contributions/JohnDoe" '
+ . 'class="mw-userlink mw-anonuserlink">JohnDoe</a>',
0, 'JohnDoe', false,
),
array(
- '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink mw-anonuserlink">::1</a>',
+ '<a href="/wiki/Special:Contributions/::1" '
+ . 'title="Special:Contributions/::1" '
+ . 'class="mw-userlink mw-anonuserlink">::1</a>',
0, '::1', false,
'Anonymous with pretty IPv6'
),
array(
- '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" title="Special:Contributions/0:0:0:0:0:0:0:1" class="mw-userlink mw-anonuserlink">::1</a>',
+ '<a href="/wiki/Special:Contributions/0:0:0:0:0:0:0:1" '
+ . 'title="Special:Contributions/0:0:0:0:0:0:0:1" '
+ . 'class="mw-userlink mw-anonuserlink">::1</a>',
0, '0:0:0:0:0:0:0:1', false,
'Anonymous with almost pretty IPv6'
),
array(
- '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" class="mw-userlink mw-anonuserlink">::1</a>',
+ '<a href="/wiki/Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
+ . 'title="Special:Contributions/0000:0000:0000:0000:0000:0000:0000:0001" '
+ . 'class="mw-userlink mw-anonuserlink">::1</a>',
0, '0000:0000:0000:0000:0000:0000:0000:0001', false,
'Anonymous with full IPv6'
),
array(
- '<a href="/wiki/Special:Contributions/::1" title="Special:Contributions/::1" class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
+ '<a href="/wiki/Special:Contributions/::1" '
+ . 'title="Special:Contributions/::1" '
+ . 'class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
0, '::1', 'AlternativeUsername',
'Anonymous with pretty IPv6 and an alternative username'
),
# IPV4
array(
- '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink mw-anonuserlink">127.0.0.1</a>',
+ '<a href="/wiki/Special:Contributions/127.0.0.1" '
+ . 'title="Special:Contributions/127.0.0.1" '
+ . 'class="mw-userlink mw-anonuserlink">127.0.0.1</a>',
0, '127.0.0.1', false,
'Anonymous with IPv4'
),
array(
- '<a href="/wiki/Special:Contributions/127.0.0.1" title="Special:Contributions/127.0.0.1" class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
+ '<a href="/wiki/Special:Contributions/127.0.0.1" '
+ . 'title="Special:Contributions/127.0.0.1" '
+ . 'class="mw-userlink mw-anonuserlink">AlternativeUsername</a>',
0, '127.0.0.1', 'AlternativeUsername',
'Anonymous with IPv4 and an alternative username'
),
$po->addLink( Title::newFromText( "linksupdatetest:Foo" ) ); // interwiki link should be ignored
$po->addLink( Title::newFromText( "#Foo" ) ); // hash link should be ignored
- $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
- array( NS_MAIN, 'Foo' ),
- ) );
+ $update = $this->assertLinksUpdate(
+ $t,
+ $po,
+ 'pagelinks',
+ 'pl_namespace,
+ pl_title',
+ 'pl_from = 111',
+ array( array( NS_MAIN, 'Foo' ) )
+ );
$this->assertArrayEquals( array(
Title::makeTitle( NS_MAIN, 'Foo' ), // newFromText doesn't yield the same internal state....
), $update->getAddedLinks() );
$po->addLink( Title::newFromText( "Bar" ) );
$po->addLink( Title::newFromText( "Talk:Bar" ) );
- $update = $this->assertLinksUpdate( $t, $po, 'pagelinks', 'pl_namespace, pl_title', 'pl_from = 111', array(
- array( NS_MAIN, 'Bar' ),
- array( NS_TALK, 'Bar' ),
- ) );
+ $update = $this->assertLinksUpdate(
+ $t,
+ $po,
+ 'pagelinks',
+ 'pl_namespace,
+ pl_title',
+ 'pl_from = 111',
+ array(
+ array( NS_MAIN, 'Bar' ),
+ array( NS_TALK, 'Bar' ),
+ )
+ );
$this->assertArrayEquals( array(
Title::makeTitle( NS_MAIN, 'Bar' ),
Title::makeTitle( NS_TALK, 'Bar' ),
$po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
- $this->assertLinksUpdate( $t, $po, 'templatelinks', 'tl_namespace, tl_title', 'tl_from = 111', array(
- array( NS_TEMPLATE, 'Foo' ),
- ) );
+ $this->assertLinksUpdate(
+ $t,
+ $po,
+ 'templatelinks',
+ 'tl_namespace,
+ tl_title',
+ 'tl_from = 111',
+ array( array( NS_TEMPLATE, 'Foo' ) )
+ );
}
/**
// @todo test recursive, too!
- protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows ) {
+ protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput,
+ $table, $fields, $condition, array $expectedRows
+ ) {
$update = new LinksUpdate( $title, $parserOutput );
//NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
return $this->$method( $args );
}
- if ( preg_match( '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/', $method, $m ) ) {
+ if ( preg_match(
+ '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
+ $method,
+ $m
+ ) ) {
# Interprets arguments:
$ns = $args[0];
$msg = isset( $args[1] ) ? $args[1] : " dummy message";