<?php
+
/**
* @group ContentHandler
* @group Database
* ^--- important, causes temporary tables to be used instead of the real database
* @group medium
**/
-
class WikiPageTest extends MediaWikiLangTestCase {
- var $pages_to_delete;
+ protected $pages_to_delete;
function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
return $page;
}
+ /**
+ * @covers WikiPage::doEditContent
+ */
public function testDoEditContent() {
$page = $this->newPage( "WikiPageTest_testDoEditContent" );
$title = $page->getTitle();
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
+ /**
+ * @covers WikiPage::doEdit
+ */
public function testDoEdit() {
$this->hideDeprecated( "WikiPage::doEdit" );
$this->hideDeprecated( "WikiPage::getText" );
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
+ /**
+ * @covers WikiPage::doQuickEdit
+ */
public function testDoQuickEdit() {
global $wgUser;
$this->assertEquals( $text, $page->getText() );
}
+ /**
+ * @covers WikiPage::doQuickEditContent
+ */
public function testDoQuickEditContent() {
global $wgUser;
$this->assertTrue( $content->equals( $page->getContent() ) );
}
+ /**
+ * @covers WikiPage::doDeleteArticle
+ */
public function testDoDeleteArticle() {
$page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
}
+ /**
+ * @covers WikiPage::doDeleteUpdates
+ */
public function testDoDeleteUpdates() {
$page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
}
+ /**
+ * @covers WikiPage::getRevision
+ */
public function testGetRevision() {
$page = $this->newPage( "WikiPageTest_testGetRevision" );
$this->assertEquals( "some text", $rev->getContent()->getNativeData() );
}
+ /**
+ * @covers WikiPage::getContent
+ */
public function testGetContent() {
$page = $this->newPage( "WikiPageTest_testGetContent" );
$this->assertEquals( "some text", $content->getNativeData() );
}
+ /**
+ * @covers WikiPage::getText
+ */
public function testGetText() {
$this->hideDeprecated( "WikiPage::getText" );
$this->assertEquals( "some text", $text );
}
+ /**
+ * @covers WikiPage::getRawText
+ */
public function testGetRawText() {
$this->hideDeprecated( "WikiPage::getRawText" );
$this->assertEquals( "some text", $text );
}
+ /**
+ * @covers WikiPage::getContentModel
+ */
public function testGetContentModel() {
global $wgContentHandlerUseDB;
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $page->getContentModel() );
}
+ /**
+ * @covers WikiPage::getContentHandler
+ */
public function testGetContentHandler() {
global $wgContentHandlerUseDB;
$this->assertEquals( 'JavaScriptContentHandler', get_class( $page->getContentHandler() ) );
}
+ /**
+ * @covers WikiPage::exists
+ */
public function testExists() {
$page = $this->newPage( "WikiPageTest_testExists" );
$this->assertFalse( $page->exists() );
/**
* @dataProvider provideHasViewableContent
+ * @covers WikiPage::hasViewableContent
*/
public function testHasViewableContent( $title, $viewable, $create = false ) {
$page = $this->newPage( $title );
/**
* @dataProvider provideGetRedirectTarget
+ * @covers WikiPage::getRedirectTarget
*/
public function testGetRedirectTarget( $title, $model, $text, $target ) {
$page = $this->createPage( $title, $text, $model );
/**
* @dataProvider provideGetRedirectTarget
+ * @covers WikiPage::isRedirect
*/
public function testIsRedirect( $title, $model, $text, $target ) {
$page = $this->createPage( $title, $text, $model );
);
}
-
/**
* @dataProvider provideIsCountable
+ * @covers WikiPage::isCountable
*/
public function testIsCountable( $title, $model, $text, $mode, $expected ) {
global $wgContentHandlerUseDB;
/**
* @dataProvider provideGetParserOutput
+ * @covers WikiPage::getParserOutput
*/
public function testGetParserOutput( $model, $text, $expectedHtml ) {
$page = $this->createPage( 'WikiPageTest_testGetParserOutput', $text, $model );
return $po;
}
+ /**
+ * @covers WikiPage::getParserOutput
+ */
public function testGetParserOutput_nonexisting() {
static $count = 0;
$count++;
$this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." );
}
+ /**
+ * @covers WikiPage::getParserOutput
+ */
public function testGetParserOutput_badrev() {
$page = $this->createPage( 'WikiPageTest_testGetParserOutput', "dummy", CONTENT_MODEL_WIKITEXT );
more stuff
";
-
public function dataReplaceSection() {
//NOTE: assume the Help namespace to contain wikitext
return array(
/**
* @dataProvider dataReplaceSection
+ * @covers WikiPage::replaceSection
*/
public function testReplaceSection( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
$this->hideDeprecated( "WikiPage::replaceSection" );
/**
* @dataProvider dataReplaceSection
+ * @covers WikiPage::replaceSectionContent
*/
public function testReplaceSectionContent( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
$page = $this->createPage( $title, $text, $model );
/**
* @todo FIXME: the above rollback test is better, but it keeps failing in jenkins for some reason.
+ * @covers WikiPage::doRollback
*/
public function testDoRollback() {
$admin = new User();
/**
* @dataProvider provideGetAutoSummary
+ * @covers WikiPage::getAutosummary
*/
public function testGetAutosummary( $old, $new, $flags, $expected ) {
$this->hideDeprecated( "WikiPage::getAutosummary" );
/**
* @dataProvider provideGetAutoDeleteReason
+ * @covers WikiPage::getAutoDeleteReason
*/
public function testGetAutoDeleteReason( $edits, $expectedResult, $expectedHistory ) {
global $wgUser;
/**
* @dataProvider providePreSaveTransform
+ * @covers WikiPage::preSaveTransform
*/
public function testPreSaveTransform( $text, $expected ) {
$this->hideDeprecated( 'WikiPage::preSaveTransform' );
$this->assertEquals( $expected, $text );
}
+
+ /**
+ * @covers WikiPage::factory
+ */
+ public function testWikiPageFactory() {
+ $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiFilePage', get_class( $page ) );
+
+ $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
+
+ $title = Title::makeTitle( NS_MAIN, 'SomePage' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiPage', get_class( $page ) );
+ }
}