/**
* @covers Title::getTemplateLinksFrom
* @covers Title::getLinksFrom
+ * @todo give this test a real name explaining what is being tested here
*/
public function testbug14404() {
- global $wgContLang, $wgLanguageCode, $wgLang;
-
$title = Title::newFromText( 'Bug 14404' );
$page = WikiPage::factory( $title );
$user = new User();
$user->mRights = array( 'createpage', 'edit', 'purge' );
- $wgLanguageCode = 'es';
- $wgContLang = Language::factory( 'es' );
+ $this->setMwGlobals( 'wgLanguageCode', 'es' );
+ $this->setMwGlobals( 'wgContLang', Language::factory( 'es' ) );
+ $this->setMwGlobals( 'wgLang', Language::factory( 'fr' ) );
- $wgLang = Language::factory( 'fr' );
- $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', 0, false, $user );
+ $page->doEditContent(
+ new WikitextContent( '{{:{{int:history}}}}' ),
+ 'Test code for bug 14404',
+ 0,
+ false,
+ $user
+ );
$templates1 = $title->getTemplateLinksFrom();
- $wgLang = Language::factory( 'de' );
- $page = WikiPage::factory( $title ); // In order to force the rerendering of the same wikitext
+ $this->setMwGlobals( 'wgLang', Language::factory( 'de' ) );
+ $page = WikiPage::factory( $title ); // In order to force the re-rendering of the same wikitext
// We need an edit, a purge is not enough to regenerate the tables
- $page->doEditContent( new WikitextContent( '{{:{{int:history}}}}' ), 'Test code for bug 14404', EDIT_UPDATE, false, $user );
+ $page->doEditContent(
+ new WikitextContent( '{{:{{int:history}}}}' ),
+ 'Test code for bug 14404',
+ EDIT_UPDATE,
+ false,
+ $user
+ );
$templates2 = $title->getTemplateLinksFrom();
+ /**
+ * @var Title[] $templates1
+ * @var Title[] $templates2
+ */
$this->assertEquals( $templates1, $templates2 );
$this->assertEquals( $templates1[0]->getFullText(), 'Historial' );
}
}
/**
- * Bug 8689 - Long numeric lines kill the parser
+ * @see Bug 8689
* @covers Parser::parse
*/
- public function testBug8689() {
- global $wgUser;
+ public function testLongNumericLinesDontKillTheParser() {
$longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
- $t = Title::newFromText( 'Unit test' );
- $options = ParserOptions::newFromUser( $wgUser );
+ $title = Title::newFromText( 'Unit test' );
+ $options = ParserOptions::newFromUser( new User() );
$this->assertEquals( "<p>$longLine</p>",
- $this->parser->parse( $longLine, $t, $options )->getText() );
+ $this->parser->parse( $longLine, $title, $options )->getText() );
}
/**
public function testParse() {
$title = Title::newFromText( __FUNCTION__ );
$parserOutput = $this->parser->parse( "Test\n{{Foo}}\n{{Bar}}", $title, $this->options );
- $this->assertEquals( "<p>Test\nContent of <i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>", $parserOutput->getText() );
+ $this->assertEquals(
+ "<p>Test\nContent of <i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>",
+ $parserOutput->getText()
+ );
}
/**
* @covers Parser::preSaveTransform
*/
public function testPreSaveTransform() {
- global $wgUser;
$title = Title::newFromText( __FUNCTION__ );
- $outputText = $this->parser->preSaveTransform( "Test\r\n{{subst:Foo}}\n{{Bar}}", $title, $wgUser, $this->options );
+ $outputText = $this->parser->preSaveTransform(
+ "Test\r\n{{subst:Foo}}\n{{Bar}}",
+ $title,
+ new User(),
+ $this->options
+ );
$this->assertEquals( "Test\nContent of ''Template:Foo''\n{{Bar}}", $outputText );
}
$title = Title::newFromText( __FUNCTION__ );
$outputText = $this->parser->preprocess( "Test\n{{Foo}}\n{{Bar}}", $title, $this->options );
- $this->assertEquals( "Test\nContent of ''Template:Foo''\nContent of ''Template:Bar''", $outputText );
+ $this->assertEquals(
+ "Test\nContent of ''Template:Foo''\nContent of ''Template:Bar''",
+ $outputText
+ );
}
/**
$this->assertEquals( "{{Foo}} information <!-- is very secret -->", $outputText );
}
+ /**
+ * @param Title $title
+ * @param bool $parser
+ *
+ * @return array
+ */
static function statelessFetchTemplate( $title, $parser = false ) {
$text = "Content of ''" . $title->getFullText() . "''";
$deps = array();
/**
* @dataProvider provideBug31100
* @covers Title::fixSpecialName
+ * @todo give this test a real name explaining what is being tested here
*/
public function testBug31100FixSpecialName( $text, $expectedParam ) {
$title = Title::newFromText( $text );
* @group medium
*/
class ApiQueryAllPagesTest extends ApiTestCase {
+
protected function setUp() {
parent::setUp();
$this->doLogin();
}
- function testBug25702() {
+ /**
+ * @todo give this test a real name explaining what is being tested here
+ */
+ public function testBug25702() {
$title = Title::newFromText( 'Category:Template:xyz' );
$page = WikiPage::factory( $title );
$page->doEdit( 'Some text', 'inserting content' );
/**
* @dataProvider provideBug32548
* @covers JavaScriptMinifier::minify
+ * @todo give this test a real name explaining what is being tested here
*/
public function testBug32548Exponent( $num ) {
// Long line breaking was being incorrectly done between the base and
$this->setMwGlobals( 'wgSearchType', 'MockSearch' );
}
- function updateText( $text ) {
+ public function updateText( $text ) {
return trim( SearchUpdate::updateText( $text ) );
}
/**
* @covers SearchUpdate::updateText
+ * @todo give this test a real name explaining what is being tested here
*/
public function testBug32712() {
$text = "text „http://example.com“ text";
* is not throwing a fatal error.
*
* Test specifications by Alexandre "ialex" Emsenhuber.
+ * @todo give this test a real name explaining what is being tested here
*/
public function testBug41337() {
)
) );
- # Validate the mock (FIXME should probably be removed)
- $this->assertFalse( $user->isAnon() );
- $this->assertEquals( array(),
- $user->getEffectiveGroups() );
- $this->assertEquals( 'superlongnickname',
- $user->getOption( 'nickname' ) );
-
# Forge a request to call the special page
$context = new RequestContext();
$context->setRequest( new FauxRequest() );
<?php
+
/**
* @group Database
*
*/
public static $users;
+ /**
+ * @var string
+ */
+ private $bug29408File;
+
protected function setUp() {
parent::setUp();
parent::tearDown();
}
+ /**
+ * @todo give this test a real name explaining what is being tested here
+ */
public function testBug29408() {
$this->setMwGlobals( 'wgUser', self::$users['uploader']->user );
$stash->removeFile( $file->getFileKey() );
}
- public function testValidRequest() {
- $request = new FauxRequest( array( 'wpFileKey' => 'foo' ) );
- $this->assertFalse( UploadFromStash::isValidRequest( $request ), 'Check failure on bad wpFileKey' );
-
- $request = new FauxRequest( array( 'wpSessionKey' => 'foo' ) );
- $this->assertFalse( UploadFromStash::isValidRequest( $request ), 'Check failure on bad wpSessionKey' );
-
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) );
- $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check good wpFileKey' );
+ public function provideInvalidRequests() {
+ return array(
+ 'Check failure on bad wpFileKey' =>
+ array( new FauxRequest( array( 'wpFileKey' => 'foo' ) ) ),
+ 'Check failure on bad wpSessionKey' =>
+ array( new FauxRequest( array( 'wpSessionKey' => 'foo' ) ) ),
+ );
+ }
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) );
- $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check good wpSessionKey' );
+ /**
+ * @dataProvider provideInvalidRequests
+ */
+ public function testValidRequestWithInvalidRequests( $request ) {
+ $this->assertFalse( UploadFromStash::isValidRequest( $request ) );
+ }
- $request = new FauxRequest( array( 'wpFileKey' => 'testkey-test.test', 'wpSessionKey' => 'foo' ) );
- $this->assertTrue( UploadFromStash::isValidRequest( $request ), 'Check key precedence' );
+ public function provideValidRequests() {
+ return array(
+ 'Check good wpFileKey' =>
+ array( new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) ) ),
+ 'Check good wpSessionKey' =>
+ array( new FauxRequest( array( 'wpFileKey' => 'testkey-test.test' ) ) ),
+ 'Check key precedence' =>
+ array( new FauxRequest( array(
+ 'wpFileKey' => 'testkey-test.test',
+ 'wpSessionKey' => 'foo'
+ ) ) ),
+ );
}
+ /**
+ * @dataProvider provideValidRequests
+ */
+ public function testValidRequestWithValidRequests( $request ) {
+ $this->assertTrue( UploadFromStash::isValidRequest( $request ) );
+ }
+
}