* @covers File::getArchivePath
*/
public function testGetArchivePath() {
- $this->assertEquals( 'mwstore://local-backend/test-public/archive', $this->file_hl0->getArchivePath() );
- $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2', $this->file_hl2->getArchivePath() );
- $this->assertEquals( 'mwstore://local-backend/test-public/archive/!', $this->file_hl0->getArchivePath( '!' ) );
- $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-public/archive',
+ $this->file_hl0->getArchivePath()
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-public/archive/a/a2',
+ $this->file_hl2->getArchivePath()
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-public/archive/!',
+ $this->file_hl0->getArchivePath( '!' )
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-public/archive/a/a2/!',
+ $this->file_hl2->getArchivePath( '!' )
+ );
}
/**
* @covers File::getThumbPath
*/
public function testGetThumbPath() {
- $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!', $this->file_hl0->getThumbPath() );
- $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!', $this->file_hl2->getThumbPath() );
- $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!/x', $this->file_hl0->getThumbPath( 'x' ) );
- $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-thumb/Test!',
+ $this->file_hl0->getThumbPath()
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-thumb/a/a2/Test!',
+ $this->file_hl2->getThumbPath()
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-thumb/Test!/x',
+ $this->file_hl0->getThumbPath( 'x' )
+ );
+ $this->assertEquals(
+ 'mwstore://local-backend/test-thumb/a/a2/Test!/x',
+ $this->file_hl2->getThumbPath( 'x' )
+ );
}
/**
*/
public function testGetArchiveVirtualUrl() {
$this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() );
- $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() );
- $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0->getArchiveVirtualUrl( '!' ) );
- $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) );
+ $this->assertEquals(
+ 'mwrepo://test/public/archive/a/a2',
+ $this->file_hl2->getArchiveVirtualUrl()
+ );
+ $this->assertEquals(
+ 'mwrepo://test/public/archive/%21',
+ $this->file_hl0->getArchiveVirtualUrl( '!' )
+ );
+ $this->assertEquals(
+ 'mwrepo://test/public/archive/a/a2/%21',
+ $this->file_hl2->getArchiveVirtualUrl( '!' )
+ );
}
/**
public function testGetThumbVirtualUrl() {
$this->assertEquals( 'mwrepo://test/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() );
$this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() );
- $this->assertEquals( 'mwrepo://test/thumb/Test%21/%21', $this->file_hl0->getThumbVirtualUrl( '!' ) );
- $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) );
+ $this->assertEquals(
+ 'mwrepo://test/thumb/Test%21/%21',
+ $this->file_hl0->getThumbVirtualUrl( '!' )
+ );
+ $this->assertEquals(
+ 'mwrepo://test/thumb/a/a2/Test%21/%21',
+ $this->file_hl2->getThumbVirtualUrl( '!' )
+ );
}
/**
*/
public function testWfLocalFile() {
$file = wfLocalFile( "File:Some_file_that_probably_doesn't exist.png" );
- $this->assertThat( $file, $this->isInstanceOf( 'LocalFile' ), 'wfLocalFile() returns LocalFile for valid Titles' );
+ $this->assertThat(
+ $file,
+ $this->isInstanceOf( 'LocalFile' ),
+ 'wfLocalFile() returns LocalFile for valid Titles'
+ );
}
}
// NOTE: make sure internal caching of the message text is reset appropriately
$msg = wfMessage( 'mainpage' );
$this->assertEquals( 'Main Page', $msg->inLanguage( Language::factory( 'en' ) )->text() );
- $this->assertEquals( 'Заглавная страница', $msg->inLanguage( Language::factory( 'ru' ) )->text() );
+ $this->assertEquals(
+ 'Заглавная страница',
+ $msg->inLanguage( Language::factory( 'ru' ) )->text()
+ );
}
/**
public function testMessageParams() {
$this->assertEquals( 'Return to $1.', wfMessage( 'returnto' )->text() );
$this->assertEquals( 'Return to $1.', wfMessage( 'returnto', array() )->text() );
- $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', 'foo', 'bar' )->text() );
- $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text() );
+ $this->assertEquals(
+ 'You have foo (bar).',
+ wfMessage( 'youhavenewmessages', 'foo', 'bar' )->text()
+ );
+ $this->assertEquals(
+ 'You have foo (bar).',
+ wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text()
+ );
}
/**
* @covers Message::rawParams
*/
public function testMessageParamSubstitution() {
- $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses', 'Заглавная страница' )->plain() );
- $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses', 'Заглавная страница $1' )->plain() );
- $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain() );
- $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain() );
+ $this->assertEquals(
+ '(Заглавная страница)',
+ wfMessage( 'parentheses', 'Заглавная страница' )->plain()
+ );
+ $this->assertEquals(
+ '(Заглавная страница $1)',
+ wfMessage( 'parentheses', 'Заглавная страница $1' )->plain()
+ );
+ $this->assertEquals(
+ '(Заглавная страница)',
+ wfMessage( 'parentheses' )->rawParams( 'Заглавная страница' )->plain()
+ );
+ $this->assertEquals(
+ '(Заглавная страница $1)',
+ wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain()
+ );
}
/**
$msg = new RawMessage( '$1$2$3$4$5$6$7$8$9$10$11$12' );
// One less than above has placeholders
$params = array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k' );
- $this->assertEquals( 'abcdefghijka2', $msg->params( $params )->plain(), 'Params > 9 are replaced correctly' );
+ $this->assertEquals(
+ 'abcdefghijka2',
+ $msg->params( $params )->plain(),
+ 'Params > 9 are replaced correctly'
+ );
}
/**
// NOTE: make sure internal caching of the message text is reset appropriately.
// NOTE: wgForceUIMsgAsContentMsg forces the messages *current* language to be used.
$msg = wfMessage( 'mainpage' );
- $this->assertEquals( 'Accueil', $msg->inContentLanguage()->plain(), 'inContentLanguage() with ForceUIMsg override enabled' );
+ $this->assertEquals(
+ 'Accueil',
+ $msg->inContentLanguage()->plain(),
+ 'inContentLanguage() with ForceUIMsg override enabled'
+ );
$this->assertEquals( 'Main Page', $msg->inLanguage( 'en' )->plain(), "inLanguage( 'en' )" );
- $this->assertEquals( 'Main Page', $msg->inContentLanguage()->plain(), 'inContentLanguage() with ForceUIMsg override enabled' );
+ $this->assertEquals(
+ 'Main Page',
+ $msg->inContentLanguage()->plain(),
+ 'inContentLanguage() with ForceUIMsg override enabled'
+ );
$this->assertEquals( 'Hauptseite', $msg->inLanguage( 'de' )->plain(), "inLanguage( 'de' )" );
}
* Ensure the router doesn't choke on long paths.
*/
public function testLength() {
+ // @codingStandardsIgnoreStart Ignore long line warnings
$matches = $this->basicRouter->parse( "/wiki/Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." );
$this->assertEquals( $matches, array( 'title' => "Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." ) );
+ // @codingStandardsIgnoreEnd
}
/**
$curTitle = Title::newFromText( "C" );
$context->setTitle( $curTitle );
- $this->assertTrue( $curTitle->equals( $context->getWikiPage()->getTitle() ),
- "When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
+ $this->assertTrue(
+ $curTitle->equals( $context->getWikiPage()->getTitle() ),
+ "When a title is updated the WikiPage should be purged "
+ . "and recreated on-demand with the new title."
+ );
}
/**
'sessionId' => 'd612ee607c87e749ef14da4983a702cd',
'userId' => $user->getId(),
'ip' => '192.0.2.0',
- 'headers' => array( 'USER-AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0' )
+ 'headers' => array(
+ 'USER-AGENT' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0'
+ )
);
$sc = RequestContext::importScopedSession( $sinfo ); // load new context
$this->assertEquals( $sinfo['headers'], $info['headers'], "Correct headers." );
$this->assertEquals( $sinfo['sessionId'], $info['sessionId'], "Correct session ID." );
$this->assertEquals( $sinfo['userId'], $info['userId'], "Correct user ID." );
- $this->assertEquals( $sinfo['ip'], $context->getRequest()->getIP(), "Correct context IP address." );
- $this->assertEquals( $sinfo['headers'], $context->getRequest()->getAllHeaders(), "Correct context headers." );
+ $this->assertEquals(
+ $sinfo['ip'],
+ $context->getRequest()->getIP(),
+ "Correct context IP address."
+ );
+ $this->assertEquals(
+ $sinfo['headers'],
+ $context->getRequest()->getAllHeaders(),
+ "Correct context headers."
+ );
$this->assertEquals( $sinfo['sessionId'], session_id(), "Correct context session ID." );
$this->assertEquals( true, $context->getUser()->isLoggedIn(), "Correct context user." );
$this->assertEquals( $sinfo['userId'], $context->getUser()->getId(), "Correct context user ID." );
- $this->assertEquals( 'UnitTestContextUser', $context->getUser()->getName(), "Correct context user name." );
+ $this->assertEquals(
+ 'UnitTestContextUser',
+ $context->getUser()->getName(),
+ "Correct context user name."
+ );
unset( $sc ); // restore previous context
* ^--- important, causes tests not to fail with timeout
*/
class RevisionStorageTest extends MediaWikiTestCase {
-
/**
* @var WikiPage $the_page
*/
- var $the_page;
+ private $the_page;
function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
if ( !$this->the_page ) {
- $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page", CONTENT_MODEL_WIKITEXT );
+ $this->the_page = $this->createPage(
+ 'RevisionStorageTest_the_page',
+ "just a dummy page",
+ CONTENT_MODEL_WIKITEXT
+ );
}
}
* @covers Revision::newFromArchiveRow
*/
public function testNewFromArchiveRow() {
- $page = $this->createPage( 'RevisionStorageTest_testNewFromArchiveRow', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testNewFromArchiveRow',
+ 'Lorem Ipsum',
+ CONTENT_MODEL_WIKITEXT
+ );
$orig = $page->getRevision();
$page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
* @covers Revision::fetchRevision
*/
public function testFetchRevision() {
- $page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testFetchRevision',
+ 'one',
+ CONTENT_MODEL_WIKITEXT
+ );
// Hidden process cache assertion below
$page->getRevision()->getId();
$this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
$this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
- $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
+ $this->assertTrue(
+ in_array( 'rev_timestamp', $fields ),
+ 'missing rev_timestamp in list of fields'
+ );
$this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
if ( $wgContentHandlerUseDB ) {
* @covers Revision::isCurrent
*/
public function testIsCurrent() {
- $page = $this->createPage( 'RevisionStorageTest_testIsCurrent', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testIsCurrent',
+ 'Lorem Ipsum',
+ CONTENT_MODEL_WIKITEXT
+ );
$rev1 = $page->getRevision();
# @todo find out if this should be true
$rev1x = Revision::newFromId( $rev1->getId() );
$this->assertTrue( $rev1x->isCurrent() );
- $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ), 'second rev' );
+ $page->doEditContent(
+ ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+ 'second rev'
+ );
$rev2 = $page->getRevision();
# @todo find out if this should be true
* @covers Revision::getPrevious
*/
public function testGetPrevious() {
- $page = $this->createPage( 'RevisionStorageTest_testGetPrevious', 'Lorem Ipsum testGetPrevious', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testGetPrevious',
+ 'Lorem Ipsum testGetPrevious',
+ CONTENT_MODEL_WIKITEXT
+ );
$rev1 = $page->getRevision();
$this->assertNull( $rev1->getPrevious() );
- $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+ $page->doEditContent(
+ ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
'second rev testGetPrevious' );
$rev2 = $page->getRevision();
* @covers Revision::getNext
*/
public function testGetNext() {
- $page = $this->createPage( 'RevisionStorageTest_testGetNext', 'Lorem Ipsum testGetNext', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testGetNext',
+ 'Lorem Ipsum testGetNext',
+ CONTENT_MODEL_WIKITEXT
+ );
$rev1 = $page->getRevision();
$this->assertNull( $rev1->getNext() );
- $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
- 'second rev testGetNext' );
+ $page->doEditContent(
+ ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
+ 'second rev testGetNext'
+ );
$rev2 = $page->getRevision();
$this->assertNotNull( $rev1->getNext() );
* @covers Revision::newNullRevision
*/
public function testNewNullRevision() {
- $page = $this->createPage( 'RevisionStorageTest_testNewNullRevision', 'some testing text', CONTENT_MODEL_WIKITEXT );
+ $page = $this->createPage(
+ 'RevisionStorageTest_testNewNullRevision',
+ 'some testing text',
+ CONTENT_MODEL_WIKITEXT
+ );
$orig = $page->getRevision();
$dbw = wfGetDB( DB_MASTER );
# zero
$revisions[0] = new Revision( array(
'page' => $page->getId(),
- 'title' => $page->getTitle(), // we need the title to determine the page's default content model
+ // we need the title to determine the page's default content model
+ 'title' => $page->getTitle(),
'timestamp' => '20120101000000',
'user' => $userA->getId(),
'text' => 'zero',
# one
$revisions[1] = new Revision( array(
'page' => $page->getId(),
- 'title' => $page->getTitle(), // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+ // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+ 'title' => $page->getTitle(),
'timestamp' => '20120101000100',
'user' => $userA->getId(),
'text' => 'one',
--- /dev/null
+<?php
+
+/**
+ * @group ContentHandler
+ * @group Database
+ * ^--- important, causes temporary tables to be used instead of the real database
+ */
+class RevisionTestContentHandlerUseDB extends RevisionStorageTest {
+
+ protected function setUp() {
+ $this->setMwGlobals( 'wgContentHandlerUseDB', false );
+
+ $dbw = wfGetDB( DB_MASTER );
+
+ $page_table = $dbw->tableName( 'page' );
+ $revision_table = $dbw->tableName( 'revision' );
+ $archive_table = $dbw->tableName( 'archive' );
+
+ if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
+ $dbw->query( "alter table $page_table drop column page_content_model" );
+ $dbw->query( "alter table $revision_table drop column rev_content_model" );
+ $dbw->query( "alter table $revision_table drop column rev_content_format" );
+ $dbw->query( "alter table $archive_table drop column ar_content_model" );
+ $dbw->query( "alter table $archive_table drop column ar_content_format" );
+ }
+
+ parent::setUp();
+ }
+
+ /**
+ * @covers Revision::selectFields
+ */
+ public function testSelectFields() {
+ $fields = Revision::selectFields();
+
+ $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
+ $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
+ $this->assertTrue(
+ in_array( 'rev_timestamp', $fields ),
+ 'missing rev_timestamp in list of fields'
+ );
+ $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
+
+ $this->assertFalse(
+ in_array( 'rev_content_model', $fields ),
+ 'missing rev_content_model in list of fields'
+ );
+ $this->assertFalse(
+ in_array( 'rev_content_format', $fields ),
+ 'missing rev_content_format in list of fields'
+ );
+ }
+
+ /**
+ * @covers Revision::getContentModel
+ */
+ public function testGetContentModel() {
+ try {
+ $this->makeRevision( array( 'text' => 'hello hello.',
+ 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
+
+ $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+ . "\$wgContentHandlerUseDB disabled" );
+ } catch ( MWException $ex ) {
+ $this->assertTrue( true ); // ok
+ }
+ }
+
+ /**
+ * @covers Revision::getContentFormat
+ */
+ public function testGetContentFormat() {
+ try {
+ // @todo change this to test failure on using a non-standard (but supported) format
+ // for a content model supported in the given location. As of 1.21, there are
+ // no alternative formats for any of the standard content models that could be
+ // used for this though.
+
+ $this->makeRevision( array( 'text' => 'hello hello.',
+ 'content_model' => CONTENT_MODEL_JAVASCRIPT,
+ 'content_format' => 'text/javascript' ) );
+
+ $this->fail( "Creating JavaScript content on a wikitext page should fail with "
+ . "\$wgContentHandlerUseDB disabled" );
+ } catch ( MWException $ex ) {
+ $this->assertTrue( true ); // ok
+ }
+ }
+}
+++ /dev/null
-<?php
-
-/**
- * @group ContentHandler
- * @group Database
- * ^--- important, causes temporary tables to be used instead of the real database
- */
-class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
-
- protected function setUp() {
- $this->setMwGlobals( 'wgContentHandlerUseDB', false );
-
- $dbw = wfGetDB( DB_MASTER );
-
- $page_table = $dbw->tableName( 'page' );
- $revision_table = $dbw->tableName( 'revision' );
- $archive_table = $dbw->tableName( 'archive' );
-
- if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
- $dbw->query( "alter table $page_table drop column page_content_model" );
- $dbw->query( "alter table $revision_table drop column rev_content_model" );
- $dbw->query( "alter table $revision_table drop column rev_content_format" );
- $dbw->query( "alter table $archive_table drop column ar_content_model" );
- $dbw->query( "alter table $archive_table drop column ar_content_format" );
- }
-
- parent::setUp();
- }
-
- /**
- * @covers Revision::selectFields
- */
- public function testSelectFields() {
- $fields = Revision::selectFields();
-
- $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
- $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
- $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
- $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
-
- $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields' );
- $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields' );
- }
-
- /**
- * @covers Revision::getContentModel
- */
- public function testGetContentModel() {
- try {
- $this->makeRevision( array( 'text' => 'hello hello.',
- 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
-
- $this->fail( "Creating JavaScript content on a wikitext page should fail with "
- . "\$wgContentHandlerUseDB disabled" );
- } catch ( MWException $ex ) {
- $this->assertTrue( true ); // ok
- }
- }
-
- /**
- * @covers Revision::getContentFormat
- */
- public function testGetContentFormat() {
- try {
- // @todo change this to test failure on using a non-standard (but supported) format
- // for a content model supported in the given location. As of 1.21, there are
- // no alternative formats for any of the standard content models that could be
- // used for this though.
-
- $this->makeRevision( array( 'text' => 'hello hello.',
- 'content_model' => CONTENT_MODEL_JAVASCRIPT,
- 'content_format' => 'text/javascript' ) );
-
- $this->fail( "Creating JavaScript content on a wikitext page should fail with "
- . "\$wgContentHandlerUseDB disabled" );
- } catch ( MWException $ex ) {
- $this->assertTrue( true ); // ok
- }
- }
-}
Revision::getRevisionText( $row ), "getRevisionText" );
}
- # =================================================================================================================
+ # =========================================================================
/**
* @param string $text
*
* @return Revision
*/
- function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
+ function newTestRevision( $text, $title = "Test",
+ $model = CONTENT_MODEL_WIKITEXT, $format = null
+ ) {
if ( is_string( $title ) ) {
$title = Title::newFromText( $title );
}
//NOTE: we expect the help namespace to always contain wikitext
return array(
array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
- array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
- array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
+ array(
+ serialize( 'hello world' ),
+ 'Hello',
+ "testing",
+ null,
+ Revision::FOR_PUBLIC,
+ serialize( 'hello world' )
+ ),
+ array(
+ serialize( 'hello world' ),
+ 'Dummy:Hello',
+ null,
+ null,
+ Revision::FOR_PUBLIC,
+ serialize( 'hello world' )
+ ),
);
}
* @dataProvider dataGetContent
* @covers Revision::getContent
*/
- public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+ public function testGetContent( $text, $title, $model, $format,
+ $audience, $expectedSerialization
+ ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$content = $rev->getContent( $audience );
- $this->assertEquals( $expectedSerialization, is_null( $content ) ? null : $content->serialize( $format ) );
+ $this->assertEquals(
+ $expectedSerialization,
+ is_null( $content ) ? null : $content->serialize( $format )
+ );
}
function dataGetText() {
public function dataGetSha1() {
return array(
array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
- array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
+ array(
+ serialize( "hello world." ),
+ "testing",
+ Revision::base36Sha1( serialize( "hello world." ) )
+ ),
);
}
$content->setText( "bar" );
$content2 = $rev->getContent( Revision::RAW );
- $this->assertNotSame( $content, $content2, "expected a clone" ); // content is mutable, expect clone
- $this->assertEquals( "foo", $content2->getText() ); // clone should contain the original text
+ // content is mutable, expect clone
+ $this->assertNotSame( $content, $content2, "expected a clone" );
+ // clone should contain the original text
+ $this->assertEquals( "foo", $content2->getText() );
$content2->setText( "bla bla" );
$this->assertEquals( "bar", $content->getText() ); // clones should be independent
);
}
+ // @codingStandardsIgnoreStart Ignore long line warning
/**
* @dataProvider provideTitles
- * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.dataProvider
+ * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.dataProvider
*/
+ // @codingStandardsIgnoreEnd
public function testCreateBasicListOfTitles( $titleName, $ns, $text ) {
$title = Title::newFromText( $titleName, $ns );
$this->assertEquals( $text, "$title", "see if '$titleName' matches '$text'" );
/**
* @depends testSetUpMainPageTitleForNextTest
- * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.depends
+ * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.depends
*/
public function testCheckMainPageTitleIsConsideredLocal( $title ) {
$this->assertTrue( $title->isLocal() );
}
+ // @codingStandardsIgnoreStart Ignore long line warning
/**
* @expectedException MWException object
- * See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.expectedException
+ * See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.expectedException
*/
+ // @codingStandardsIgnoreEnd
public function testTitleObjectFromObject() {
$title = Title::newFromText( Title::newFromText( "test" ) );
$this->assertEquals( "Test", $title->isLocal() );
* @covers Sanitizer::decodeCharReferences
*/
public function testInvalidNumberedEntities() {
- $this->assertEquals( UTF8_REPLACEMENT, Sanitizer::decodeCharReferences( "�" ), 'Invalid numbered entity' );
+ $this->assertEquals(
+ UTF8_REPLACEMENT,
+ Sanitizer::decodeCharReferences( "�" ),
+ 'Invalid numbered entity'
+ );
}
/**
array( array( 'foo' => 'bar' ), ' foo = bar ', 'Spaced attribute' ),
array( array( 'foo' => 'bar' ), 'foo="bar"', 'Double-quoted attribute' ),
array( array( 'foo' => 'bar' ), 'foo=\'bar\'', 'Single-quoted attribute' ),
- array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\' baz="foo"', 'Several attributes' ),
- array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\' baz="foo"', 'Several attributes' ),
- array( array( 'foo' => 'bar', 'baz' => 'foo' ), 'foo=\'bar\' baz="foo"', 'Several attributes' ),
+ array(
+ array( 'foo' => 'bar', 'baz' => 'foo' ),
+ 'foo=\'bar\' baz="foo"',
+ 'Several attributes'
+ ),
+ array(
+ array( 'foo' => 'bar', 'baz' => 'foo' ),
+ 'foo=\'bar\' baz="foo"',
+ 'Several attributes'
+ ),
+ array(
+ array( 'foo' => 'bar', 'baz' => 'foo' ),
+ 'foo=\'bar\' baz="foo"',
+ 'Several attributes'
+ ),
array( array( ':foo' => 'bar' ), ':foo=\'bar\'', 'Leading :' ),
array( array( '_foo' => 'bar' ), '_foo=\'bar\'', 'Leading _' ),
array( array( 'foo' => 'bar' ), 'Foo=\'bar\'', 'Leading capital' ),
array( array(), 'foo$=baz', 'Symbols are not allowed' ),
array( array(), 'foo@=baz', 'Symbols are not allowed' ),
array( array(), 'foo~=baz', 'Symbols are not allowed' ),
- array( array( 'foo' => '1[#^`*%w/(' ), 'foo=1[#^`*%w/(', 'All kind of characters are allowed as values' ),
- array( array( 'foo' => '1[#^`*%\'w/(' ), 'foo="1[#^`*%\'w/("', 'Double quotes are allowed if quoted by single quotes' ),
- array( array( 'foo' => '1[#^`*%"w/(' ), 'foo=\'1[#^`*%"w/(\'', 'Single quotes are allowed if quoted by double quotes' ),
+ array(
+ array( 'foo' => '1[#^`*%w/(' ),
+ 'foo=1[#^`*%w/(',
+ 'All kind of characters are allowed as values'
+ ),
+ array(
+ array( 'foo' => '1[#^`*%\'w/(' ),
+ 'foo="1[#^`*%\'w/("',
+ 'Double quotes are allowed if quoted by single quotes'
+ ),
+ array(
+ array( 'foo' => '1[#^`*%"w/(' ),
+ 'foo=\'1[#^`*%"w/(\'',
+ 'Single quotes are allowed if quoted by double quotes'
+ ),
array( array( 'foo' => '&"' ), 'foo=&"', 'Special chars can be provided as entities' ),
array( array( 'foo' => '&foobar;' ), 'foo=&foobar;', 'Entity-like items are accepted' ),
);
'Remove anything after a comment-start token' ),
array( '', "\\2f\\2a unifinished comment'",
'Remove anything after a backslash-escaped comment-start token' ),
- array( '/* insecure input */', 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'asdf.png\',sizingMethod=\'scale\');' ),
- array( '/* insecure input */', '-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'asdf.png\',sizingMethod=\'scale\')";' ),
+ array(
+ '/* insecure input */',
+ 'filter: progid:DXImageTransform.Microsoft.AlphaImageLoader'
+ . '(src=\'asdf.png\',sizingMethod=\'scale\');'
+ ),
+ array(
+ '/* insecure input */',
+ '-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader'
+ . '(src=\'asdf.png\',sizingMethod=\'scale\')";'
+ ),
array( '/* insecure input */', 'width: expression(1+1);' ),
array( '/* insecure input */', 'background-image: image(asdf.png);' ),
array( '/* insecure input */', 'background-image: -webkit-image(asdf.png);' ),
array( '/* insecure input */', 'background-image: -moz-image(asdf.png);' ),
array( '/* insecure input */', 'background-image: image-set("asdf.png" 1x, "asdf.png" 2x);' ),
- array( '/* insecure input */', 'background-image: -webkit-image-set("asdf.png" 1x, "asdf.png" 2x);' ),
- array( '/* insecure input */', 'background-image: -moz-image-set("asdf.png" 1x, "asdf.png" 2x);' ),
+ array(
+ '/* insecure input */',
+ 'background-image: -webkit-image-set("asdf.png" 1x, "asdf.png" 2x);'
+ ),
+ array(
+ '/* insecure input */',
+ 'background-image: -moz-image-set("asdf.png" 1x, "asdf.png" 2x);'
+ ),
);
}
public static function provideAttributeSupport() {
/** array( <attributes>, <expected>, <message> ) */
return array(
- array( 'div', ' role="presentation"', ' role="presentation"', 'Support for WAI-ARIA\'s role="presentation".' ),
+ array(
+ 'div',
+ ' role="presentation"',
+ ' role="presentation"',
+ 'Support for WAI-ARIA\'s role="presentation".'
+ ),
array( 'div', ' role="main"', '', "Other WAI-ARIA roles are currently not supported." ),
);
}
'fallback' => 'tag',
'params' => 'en wiki enwiki',
'global' => array( 'enwiki' => 'enwiki' ) + $GLOBALS['global'],
- 'merge' => array( 'enwiki' => 'enwiki', 'tag' => 'tag', 'wiki' => 'wiki', 'default' => 'default' ),
+ 'merge' => array(
+ 'enwiki' => 'enwiki',
+ 'tag' => 'tag',
+ 'wiki' => 'wiki',
+ 'default' => 'default'
+ ),
);
$this->assertEquals( $getall, $this->mConf->getAll( 'enwiki' ), 'getAll()' );
$this->mConf->extractAllGlobals( 'enwiki', 'wiki' );
- $this->assertEquals( $getall['simple'], $GLOBALS['simple'], 'extractAllGlobals(): simple setting' );
- $this->assertEquals( $getall['fallback'], $GLOBALS['fallback'], 'extractAllGlobals(): fallback setting' );
- $this->assertEquals( $getall['params'], $GLOBALS['params'], 'extractAllGlobals(): parameter replacement' );
- $this->assertEquals( $getall['global'], $GLOBALS['global'], 'extractAllGlobals(): merging with global' );
- $this->assertEquals( $getall['merge'], $GLOBALS['merge'], 'extractAllGlobals(): merging setting' );
+ $this->assertEquals(
+ $getall['simple'],
+ $GLOBALS['simple'],
+ 'extractAllGlobals(): simple setting'
+ );
+ $this->assertEquals(
+ $getall['fallback'],
+ $GLOBALS['fallback'],
+ 'extractAllGlobals(): fallback setting'
+ );
+ $this->assertEquals(
+ $getall['params'],
+ $GLOBALS['params'],
+ 'extractAllGlobals(): parameter replacement'
+ );
+ $this->assertEquals(
+ $getall['global'],
+ $GLOBALS['global'],
+ 'extractAllGlobals(): merging with global'
+ );
+ $this->assertEquals(
+ $getall['merge'],
+ $GLOBALS['merge'],
+ 'extractAllGlobals(): merging setting'
+ );
}
}
*/
class SkinTemplateTest extends MediaWikiTestCase {
-
/**
* @dataProvider makeListItemProvider
*/
array(
'<li class="class" title="itemtitle"><a href="url" title="title">text</a></li>',
'',
- array( 'class' => 'class', 'itemtitle' => 'itemtitle', 'href' => 'url', 'title' => 'title', 'text' => 'text' ),
+ array(
+ 'class' => 'class',
+ 'itemtitle' => 'itemtitle',
+ 'href' => 'url',
+ 'title' => 'title',
+ 'text' => 'text'
+ ),
array(),
'Test makteListItem with normal values'
)