* Base class that store and restore the Language objects
*/
abstract class MediaWikiLangTestCase extends MediaWikiTestCase {
-
protected function setUp() {
global $wgLanguageCode, $wgContLang;
parent::setUp();
<?php
-class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
+class MediaWikiPHPUnitTestListener implements PHPUnit_Framework_TestListener {
/**
* @var string
*/
* @param float $time
*/
public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
- wfDebugLog( $this->logChannel, 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+ wfDebugLog(
+ $this->logChannel,
+ 'ERROR in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+ );
}
/**
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
- public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
- wfDebugLog( $this->logChannel, 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+ public function addFailure( PHPUnit_Framework_Test $test,
+ PHPUnit_Framework_AssertionFailedError $e, $time
+ ) {
+ wfDebugLog(
+ $this->logChannel,
+ 'FAILURE in ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+ );
}
/**
* @param float $time
*/
public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
- wfDebugLog( $this->logChannel, 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+ wfDebugLog(
+ $this->logChannel,
+ 'Incomplete test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+ );
}
/**
* @since Method available since Release 3.0.0
*/
public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
- wfDebugLog( $this->logChannel, 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e ) );
+ wfDebugLog(
+ $this->logChannel,
+ 'Skipped test ' . $this->getTestName( $test ) . ': ' . $this->getErrorName( $e )
+ );
}
/**
* @since 1.18
*/
abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
-
/**
* $called tracks whether the setUp and tearDown method has been called.
* class extending MediaWikiTestCase usually override setUp and tearDown
$oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
$newHex = strtoupper( dechex( $phpErrorLevel ) );
- $message = "PHP error_reporting setting was left dirty: was 0x$oldHex before test, 0x$newHex after test!";
+ $message = "PHP error_reporting setting was left dirty: "
+ . "was 0x$oldHex before test, 0x$newHex after test!";
$this->fail( $message );
}
* @param bool $ordered If the order of the values should match
* @param bool $named If the keys should match
*/
- protected function assertArrayEquals( array $expected, array $actual, $ordered = false, $named = false ) {
+ protected function assertArrayEquals( array $expected, array $actual,
+ $ordered = false, $named = false
+ ) {
if ( !$ordered ) {
$this->objectAssociativeSort( $expected );
$this->objectAssociativeSort( $actual );
$this->assertEmpty( $errors, implode( "\n", $errors ) );
}
-
}
<?php
abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
-
protected static function getResourceLoaderContext() {
$resourceLoader = new ResourceLoader();
$request = new FauxRequest( array(
/* Stubs */
class ResourceLoaderTestModule extends ResourceLoaderModule {
-
protected $dependencies = array();
protected $group = null;
protected $source = 'local';
}
}
-class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {}
+class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {
+}
}
/**
- * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
+ * Checks for the existence of the backwards compatibility static functions
+ * (forwarders to WikiPage class)
+ *
* @covers Article::selectFields
* @covers Article::onArticleCreate
* @covers Article::onArticleDelete
* @covers Block::newFromTarget
*/
public function testINewFromTargetReturnsCorrectBlock() {
- $this->assertTrue( $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ), "newFromTarget() returns the same block as the one that was made" );
+ $this->assertTrue(
+ $this->block->equals( Block::newFromTarget( 'UTBlockee' ) ),
+ "newFromTarget() returns the same block as the one that was made"
+ );
}
/**
* @covers Block::newFromID
*/
public function testINewFromIDReturnsCorrectBlock() {
- $this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made" );
+ $this->assertTrue(
+ $this->block->equals( Block::newFromID( $this->blockId ) ),
+ "newFromID() returns the same block as the one that was made"
+ );
}
/**
public function testBug26425BlockTimestampDefaultsToTime() {
// delta to stop one-off errors when things happen to go over a second mark.
$delta = abs( $this->madeAt - $this->block->mTimestamp );
- $this->assertLessThan( 2, $delta, "If no timestamp is specified, the block is recorded as time()" );
+ $this->assertLessThan(
+ 2,
+ $delta,
+ "If no timestamp is specified, the block is recorded as time()"
+ );
}
/**
*/
public function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
$block = Block::newFromTarget( 'UTBlockee', $vagueTarget );
- $this->assertTrue( $this->block->equals( $block ), "newFromTarget() returns the same block as the one that was made when given empty vagueTarget param " . var_export( $vagueTarget, true ) );
+ $this->assertTrue(
+ $this->block->equals( $block ),
+ "newFromTarget() returns the same block as the one that was made when "
+ . "given empty vagueTarget param " . var_export( $vagueTarget, true )
+ );
}
public static function provideBug29116Data() {
$user = null; // clear
$block = Block::newFromID( $res['id'] );
- $this->assertEquals( 'UserOnForeignWiki', $block->getTarget()->getName(), 'Correct blockee name' );
+ $this->assertEquals(
+ 'UserOnForeignWiki',
+ $block->getTarget()->getName(),
+ 'Correct blockee name'
+ );
$this->assertEquals( '14146', $block->getTarget()->getId(), 'Correct blockee id' );
$this->assertEquals( 'MetaWikiUser', $block->getBlocker(), 'Correct blocker name' );
$this->assertEquals( 'MetaWikiUser', $block->getByName(), 'Correct blocker name' );
* * wpTextbox1: the text to submit
* * wpSummary: the edit summary
* * wpEditToken: the edit token (will be inserted if not provided)
- * * wpEdittime: timestamp of the edit's base revision (will be inserted if not provided)
+ * * wpEdittime: timestamp of the edit's base revision (will be inserted
+ * if not provided)
* * wpStarttime: timestamp when the edit started (will be inserted if not provided)
* * wpSectionTitle: the section to edit
* * wpMinorEdit: mark as minor edit
}
$starttime = wfTimestampNow();
- $adamsTime = wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$adamsEdit['wpStarttime'] );
- $bertasTime = wfTimestamp( TS_MW, (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$bertasEdit['wpStarttime'] );
+ $adamsTime = wfTimestamp(
+ TS_MW,
+ (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$adamsEdit['wpStarttime']
+ );
+ $bertasTime = wfTimestamp(
+ TS_MW,
+ (int)wfTimestamp( TS_UNIX, $starttime ) + (int)$bertasEdit['wpStarttime']
+ );
$adamsEdit['wpStarttime'] = $adamsTime;
$bertasEdit['wpStarttime'] = $bertasTime;
return null;
}
- if ( $itemID !== false && is_array( $this->data[$cluster][$id] ) && isset( $this->data[$cluster][$id][$itemID] ) ) {
+ if ( $itemID !== false
+ && is_array( $this->data[$cluster][$id] )
+ && isset( $this->data[$cluster][$id][$itemID] )
+ ) {
return $this->data[$cluster][$id][$itemID];
}
* @covers Parser::getSection
*/
public function testGetSection() {
- $outputText2 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 2 );
- $outputText1 = $this->parser->getSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1 );
+ $outputText2 = $this->parser->getSection(
+ "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+ . "Section 2\n== Heading 3 ==\nSection 3\n",
+ 2
+ );
+ $outputText1 = $this->parser->getSection(
+ "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+ . "Section 2\n== Heading 3 ==\nSection 3\n",
+ 1
+ );
$this->assertEquals( "=== Heading 2 ===\nSection 2", $outputText2 );
$this->assertEquals( "== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2", $outputText1 );
* @covers Parser::replaceSection
*/
public function testReplaceSection() {
- $outputText = $this->parser->replaceSection( "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection 3\n", 1, "New section 1" );
+ $outputText = $this->parser->replaceSection(
+ "Section 0\n== Heading 1 ==\nSection 1\n=== Heading 2 ===\n"
+ . "Section 2\n== Heading 3 ==\nSection 3\n",
+ 1,
+ "New section 1"
+ );
$this->assertEquals( "Section 0\nNew section 1\n\n== Heading 3 ==\nSection 3", $outputText );
}
*/
public function testGetPreloadText() {
$title = Title::newFromText( __FUNCTION__ );
- $outputText = $this->parser->getPreloadText( "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->", $title, $this->options );
+ $outputText = $this->parser->getPreloadText(
+ "{{Foo}}<noinclude> censored</noinclude> information <!-- is very secret -->",
+ $title,
+ $this->options
+ );
$this->assertEquals( "{{Foo}} information <!-- is very secret -->", $outputText );
}