/**
* @dataProvider complexVersionProvider
*/
- public function testGivenComplexVersionWithoutDash_normalizeSuffixAddsDash( $withoutDash, $withDash ) {
+ public function testGivenComplexVersionWithoutDash_normalizeSuffixAddsDash(
+ $withoutDash, $withDash
+ ) {
$normalizer = new ComposerVersionNormalizer();
$this->assertEquals(
/**
* @dataProvider complexVersionProvider
*/
- public function testGivenComplexVersionWithDash_normalizeSuffixReturnsAsIs( $withoutDash, $withDash ) {
+ public function testGivenComplexVersionWithDash_normalizeSuffixReturnsAsIs(
+ $withoutDash, $withDash
+ ) {
$this->assertRemainsUnchanged( $withDash );
}
/**
* @dataProvider levelNormalizationProvider
*/
- public function testGivenFewerLevels_levelCountNormalizationEnsuresFourLevels( $expected, $version ) {
+ public function testGivenFewerLevels_levelCountNormalizationEnsuresFourLevels(
+ $expected, $version
+ ) {
$normalizer = new ComposerVersionNormalizer();
$this->assertEquals(
* @group ContentHandler
* @group Database
*
- * @note Declare that we are using the database, because otherwise we'll fail in the "databaseless" test run.
- * This is because the LinkHolderArray used by the parser needs database access.
- *
+ * @note Declare that we are using the database, because otherwise we'll fail in
+ * the "databaseless" test run. This is because the LinkHolderArray used by the
+ * parser needs database access.
*/
class ContentHandlerTest extends MediaWikiTestCase {
array( 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
array( serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ),
- array( 'hallo', 'Help:Test', null, CONTENT_FORMAT_WIKITEXT, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
- array( 'hallo', 'MediaWiki:Test.js', null, CONTENT_FORMAT_JAVASCRIPT, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
+ array(
+ 'hallo',
+ 'Help:Test',
+ null,
+ CONTENT_FORMAT_WIKITEXT,
+ CONTENT_MODEL_WIKITEXT,
+ 'hallo',
+ false
+ ),
+ array(
+ 'hallo',
+ 'MediaWiki:Test.js',
+ null,
+ CONTENT_FORMAT_JAVASCRIPT,
+ CONTENT_MODEL_JAVASCRIPT,
+ 'hallo',
+ false
+ ),
array( serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ),
array( 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
- array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ),
- array( serialize( 'hallo' ), 'Dummy:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, serialize( 'hallo' ), false ),
+ array(
+ 'hallo',
+ 'MediaWiki:Test.js',
+ CONTENT_MODEL_CSS,
+ null,
+ CONTENT_MODEL_CSS,
+ 'hallo',
+ false
+ ),
+ array(
+ serialize( 'hallo' ),
+ 'Dummy:Test',
+ CONTENT_MODEL_CSS,
+ null,
+ CONTENT_MODEL_CSS,
+ serialize( 'hallo' ),
+ false
+ ),
array( 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ),
* @dataProvider dataMakeContent
* @covers ContentHandler::makeContent
*/
- public function testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail ) {
+ public function testMakeContent( $data, $title, $modelId, $format,
+ $expectedModelId, $expectedNativeData, $shouldFail
+ ) {
$title = Title::newFromText( $title );
try {
Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' );
$content = new WikitextContent( 'test text' );
- $ok = ContentHandler::runLegacyHooks( 'testRunLegacyHooks', array( 'foo', &$content, 'bar' ), false );
+ $ok = ContentHandler::runLegacyHooks(
+ 'testRunLegacyHooks',
+ array( 'foo', &$content, 'bar' ),
+ false
+ );
$this->assertTrue( $ok, "runLegacyHooks should have returned true" );
$this->assertEquals( "TEST TEXT", $content->getNativeData() );
}
/**
- * @return string A string representing the content in a way useful for building a full text search index.
- * If no useful representation exists, this method returns an empty string.
+ * @return string A string representing the content in a way useful for
+ * building a full text search index. If no useful representation exists,
+ * this method returns an empty string.
*/
public function getTextForSearchIndex() {
return '';
}
/**
- * Returns a textual representation of the content suitable for use in edit summaries and log messages.
+ * Returns a textual representation of the content suitable for use in edit
+ * summaries and log messages.
*
* @param int $maxlength Maximum length of the summary text.
* @return string The summary text.
* Returns true if this content is countable as a "real" wiki page, provided
* that it's also in a countable location (e.g. a current revision in the main namespace).
*
- * @param bool $hasLinks if it is known whether this content contains links, provide this information here,
- * to avoid redundant parsing to find out.
+ * @param bool $hasLinks if it is known whether this content contains links,
+ * provide this information here, to avoid redundant parsing to find out.
* @return bool
*/
public function isCountable( $hasLinks = null ) {
*
* @return ParserOutput
*/
- public function getParserOutput( Title $title, $revId = null, ParserOptions $options = null, $generateHtml = true ) {
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true
+ ) {
return new ParserOutput( $this->getNativeData() );
}
}
$mw = MagicWord::get( "staticredirect" );
$content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" );
- $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" );
+ $this->assertFalse(
+ $content->matchMagicWord( $mw ),
+ "should not have matched magic word, since it's not wikitext"
+ );
}
/**
$content = $this->newContent( "#REDIRECT [[Someplace]]" );
$newContent = $content->updateRedirect( $target );
- $this->assertTrue( $content->equals( $newContent ), "content should be unchanged since it's not wikitext" );
+ $this->assertTrue(
+ $content->equals( $newContent ),
+ "content should be unchanged since it's not wikitext"
+ );
}
/**
* @dataProvider dataGetParserOutput
* @covers TextContent::getParserOutput
*/
- public function testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields = null ) {
+ public function testGetParserOutput( $title, $model, $text, $expectedHtml,
+ $expectedFields = null
+ ) {
$title = Title::newFromText( $title );
$content = ContentHandler::makeContent( $text, $title, $model );
$options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang );
$content = $this->newContent( $text );
- $content = $content->preSaveTransform( $this->context->getTitle(), $this->context->getUser(), $options );
+ $content = $content->preSaveTransform(
+ $this->context->getTitle(),
+ $this->context->getUser(),
+ $options
+ );
$this->assertEquals( $expected, $content->getNativeData() );
}
$v = $content->isCountable( $hasLinks, $this->context->getTitle() );
- $this->assertEquals( $expected, $v, 'isCountable() returned unexpected value ' . var_export( $v, true )
- . ' instead of ' . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ $this->assertEquals(
+ $expected,
+ $v,
+ 'isCountable() returned unexpected value ' . var_export( $v, true )
+ . ' instead of ' . var_export( $expected, true )
+ . " in mode `$mode` for text \"$text\""
+ );
}
public static function dataGetTextForSummary() {
* @group ContentHandler
*/
class WikitextContentHandlerTest extends MediaWikiLangTestCase {
-
/**
* @var ContentHandler
*/
- var $handler;
+ private $handler;
protected function setUp() {
parent::setUp();
$content = new WikitextContent( 'hello world' );
$this->assertEquals( 'hello world', $this->handler->serializeContent( $content ) );
- $this->assertEquals( 'hello world', $this->handler->serializeContent( $content, CONTENT_FORMAT_WIKITEXT ) );
+ $this->assertEquals(
+ 'hello world',
+ $this->handler->serializeContent( $content, CONTENT_FORMAT_WIKITEXT )
+ );
try {
$this->handler->serializeContent( $content, 'dummy/foo' );
array( 'Category:Foo', '#REDIRECT [[:Category:Foo]]' ),
array( Title::makeTitle( NS_MAIN, 'en:Foo' ), '#REDIRECT [[en:Foo]]' ),
array( Title::makeTitle( NS_MAIN, 'Foo', '', 'en' ), '#REDIRECT [[:en:Foo]]' ),
- array( Title::makeTitle( NS_MAIN, 'Bar', 'fragment', 'google' ), '#REDIRECT [[google:Bar#fragment]]' ),
+ array(
+ Title::makeTitle( NS_MAIN, 'Bar', 'fragment', 'google' ),
+ '#REDIRECT [[google:Bar#fragment]]'
+ ),
);
}
),
array(
- 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
- labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et
- ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
+ 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
+ eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+ voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
+ clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
'Hello world!',
0,
'/^Replaced .*Hello/'
$summary = $this->handler->getAutosummary( $oldContent, $newContent, $flags );
- $this->assertTrue( (bool)preg_match( $expected, $summary ), "Autosummary didn't match expected pattern $expected: $summary" );
+ $this->assertTrue(
+ (bool)preg_match( $expected, $summary ),
+ "Autosummary didn't match expected pattern $expected: $summary"
+ );
}
/**
* @todo Text case requires database, should be done by a test class in the Database group
*/
/*
- public function testGetUndoContent( Revision $current, Revision $undo, Revision $undoafter = null ) {}
+ public function testGetUndoContent( Revision $current, Revision $undo,
+ Revision $undoafter = null
+ ) {
+ }
*/
}
* ^--- needed, because we do need the database to test link updates
*/
class WikitextContentTest extends TextContentTest {
- static $sections = "Intro
+ public static $sections = "Intro
== stuff ==
hello world
"2",
"== TEST ==\nmore fun",
null,
- trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikitextContentTest::$sections ) )
+ trim( preg_replace(
+ '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==",
+ WikitextContentTest::$sections
+ ) )
),
array( WikitextContentTest::$sections,
"8",
*/
class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
// From DatabaseBase
- function __construct() {}
- protected function closeConnection() {}
- protected function doQuery( $sql ) {}
+ function __construct() {
+ }
+
+ protected function closeConnection() {
+ }
+
+ protected function doQuery( $sql ) {
+ }
// From DatabaseMysql
- protected function mysqlConnect( $realServer ) {}
- protected function mysqlSetCharset( $charset ) {}
- protected function mysqlFreeResult( $res ) {}
- protected function mysqlFetchObject( $res ) {}
- protected function mysqlFetchArray( $res ) {}
- protected function mysqlNumRows( $res ) {}
- protected function mysqlNumFields( $res ) {}
- protected function mysqlFieldName( $res, $n ) {}
- protected function mysqlFieldType( $res, $n ) {}
- protected function mysqlDataSeek( $res, $row ) {}
- protected function mysqlError( $conn = null ) {}
- protected function mysqlFetchField( $res, $n ) {}
- protected function mysqlPing() {}
+ protected function mysqlConnect( $realServer ) {
+ }
+
+ protected function mysqlSetCharset( $charset ) {
+ }
+
+ protected function mysqlFreeResult( $res ) {
+ }
+
+ protected function mysqlFetchObject( $res ) {
+ }
+
+ protected function mysqlFetchArray( $res ) {
+ }
+
+ protected function mysqlNumRows( $res ) {
+ }
+
+ protected function mysqlNumFields( $res ) {
+ }
+
+ protected function mysqlFieldName( $res, $n ) {
+ }
+
+ protected function mysqlFieldType( $res, $n ) {
+ }
+
+ protected function mysqlDataSeek( $res, $row ) {
+ }
+
+ protected function mysqlError( $conn = null ) {
+ }
+
+ protected function mysqlFetchField( $res, $n ) {
+ }
+
+ protected function mysqlPing() {
+ }
// From interface DatabaseType
- function insertId() {}
- function lastErrno() {}
- function affectedRows() {}
- function getServerVersion() {}
+ function insertId() {
+ }
+
+ function lastErrno() {
+ }
+
+ function affectedRows() {
+ }
+
+ function getServerVersion() {
+ }
}
class DatabaseMysqlBaseTest extends MediaWikiTestCase {
-
/**
* @dataProvider provideDiapers
* @covers DatabaseMysqlBase::addIdentifierQuotes
'tables' => array( 'table', 't2' => 'table2' ),
'fields' => array( 'tid', 'field', 'alias' => 'field2', 't2.id' ),
'conds' => array( 'alias' => 'text' ),
- 'options' => array( 'LIMIT' => 1, 'GROUP BY' => array( 'field', 'field2' ), 'HAVING' => array( 'COUNT(*) > 1', 'field' => 1 ) ),
+ 'options' => array(
+ 'LIMIT' => 1,
+ 'GROUP BY' => array( 'field', 'field2' ),
+ 'HAVING' => array( 'COUNT(*) > 1', 'field' => 1 )
+ ),
'join_conds' => array( 't2' => array(
'LEFT JOIN', 'tid = t2.id'
) ),
<?php
class MockDatabaseSqlite extends DatabaseSqliteStandalone {
- var $lastQuery;
+ private $lastQuery;
function __construct() {
parent::__construct( ':memory:' );
* @group medium
*/
class DatabaseSqliteTest extends MediaWikiTestCase {
-
- /**
- * @var MockDatabaseSqlite
- */
- var $db;
+ /** @var MockDatabaseSqlite */
+ protected $db;
protected function setUp() {
parent::setUp();
array( // #2: including quote
'foo\'bar', "'foo''bar'"
),
- array( // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
+ // #3: including \0 (must be represented as hex, per https://bugs.php.net/bug.php?id=63419)
+ array(
"x\0y",
"x'780079'",
),
public function testReplaceVars() {
$this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
- $this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
+ $this->assertEquals(
+ "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
. "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
- $this->replaceVars( "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
- foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;" )
+ $this->replaceVars(
+ "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, "
+ . "foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', "
+ . "foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;"
+ )
);
- $this->assertEquals( "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
- $this->replaceVars( "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );" )
+ $this->assertEquals(
+ "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
+ $this->replaceVars(
+ "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );"
+ )
);
$this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
/**
* @var DatabaseBase
*/
- var $db;
- var $functionTest = false;
+ protected $db;
+
+ private $functionTest = false;
protected function setUp() {
parent::setUp();
global $IP;
$this->dropFunctions();
$this->functionTest = true;
- $this->assertTrue( $this->db->sourceFile( "$IP/tests/phpunit/data/db/{$this->db->getType()}/functions.sql" ) );
+ $this->assertTrue(
+ $this->db->sourceFile( "$IP/tests/phpunit/data/db/{$this->db->getType()}/functions.sql" )
+ );
$res = $this->db->query( 'SELECT mw_test_function() AS test', __METHOD__ );
$this->assertEquals( 42, $res->fetchObject()->test );
}