}
public function dataGetDefaultModelFor() {
+ //NOTE: assume that the Help namespace default to wikitext content
return array(
- array( 'Foo', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo.js', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ),
#public static function makeContent( $text, Title $title, $modelId = null, $format = null )
public function dataMakeContent() {
+ //NOTE: assume the Help namespace defaults to wikitext content
return array(
- array( 'hallo', 'Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
+ array( 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ),
array( 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ),
array( serialize('hallo'), 'Dummy:Test', null, null, "testing", 'hallo', false ),
- array( 'hallo', 'Test', null, CONTENT_FORMAT_WIKITEXT, CONTENT_MODEL_WIKITEXT, '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', 'Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, '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', 'Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
+ array( 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ),
array( 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ),
array( 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, null, true ),
);
public function dataGetParserOutput() {
return array(
- array("MediaWiki:Test.css", "hello <world>\n", "<pre class=\"mw-code mw-css\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
+ array("MediaWiki:Test.css", null, "hello <world>\n",
+ "<pre class=\"mw-code mw-css\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
// @todo: more...?
);
}
public function dataGetParserOutput() {
return array(
- array("MediaWiki:Test.js", "hello <world>\n",
+ array("MediaWiki:Test.js", null, "hello <world>\n",
"<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello <world>\n\n</pre>\n"),
// @todo: more...?
);
$wgContLang->resetNamespaces(); # reset namespace cache
if ( !$this->the_page ) {
- $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page" );
+ $this->the_page = $this->createPage( 'RevisionStorageTest_the_page', "just a dummy page", CONTENT_MODEL_WIKITEXT );
}
}
*/
public function testNewFromArchiveRow()
{
- $page = $this->createPage( 'RevisionStorageTest_testNewFromArchiveRow', 'Lorem Ipsum' );
+ $page = $this->createPage( 'RevisionStorageTest_testNewFromArchiveRow', 'Lorem Ipsum', CONTENT_MODEL_WIKITEXT );
$orig = $page->getRevision();
$page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
*/
public function testFetchRevision()
{
- $page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one' );
+ $page = $this->createPage( 'RevisionStorageTest_testFetchRevision', 'one', CONTENT_MODEL_WIKITEXT );
$id1 = $page->getRevision()->getId();
$page->doEditContent( new WikitextContent( 'two' ), 'second rev' );
*/
public function testIsCurrent()
{
- $page = $this->createPage( 'RevisionStorageTest_testIsCurrent', 'Lorem Ipsum' );
+ $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() ), '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
*/
public function testGetPrevious()
{
- $page = $this->createPage( 'RevisionStorageTest_testGetPrevious', 'Lorem Ipsum testGetPrevious' );
+ $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() ),
+ $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
'second rev testGetPrevious' );
$rev2 = $page->getRevision();
*/
public function testGetNext()
{
- $page = $this->createPage( 'RevisionStorageTest_testGetNext', 'Lorem Ipsum testGetNext' );
+ $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() ),
+ $page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
'second rev testGetNext' );
$rev2 = $page->getRevision();
*/
public function testNewNullRevision()
{
- $page = $this->createPage( 'RevisionStorageTest_testNewNullRevision', 'some testing text' );
+ $page = $this->createPage( 'RevisionStorageTest_testNewNullRevision', 'some testing text', CONTENT_MODEL_WIKITEXT );
$orig = $page->getRevision();
$dbw = wfGetDB( DB_MASTER );
'timestamp' => '20120101000000',
'user' => $userA->getId(),
'text' => 'zero',
+ 'content_model' => CONTENT_MODEL_WIKITEXT,
'summary' => 'edit zero'
) );
$revisions[0]->insertOn( $dbw );
'timestamp' => '20120101000100',
'user' => $userA->getId(),
'text' => 'one',
+ 'content_model' => CONTENT_MODEL_WIKITEXT,
'summary' => 'edit one'
) );
$revisions[1]->insertOn( $dbw );
'timestamp' => '20120101000200',
'user' => $userB->getId(),
'text' => 'two',
+ 'content_model' => CONTENT_MODEL_WIKITEXT,
'summary' => 'edit two'
) );
$revisions[2]->insertOn( $dbw );
'timestamp' => '20120101000300',
'user' => $userA->getId(),
'text' => 'three',
+ 'content_model' => CONTENT_MODEL_WIKITEXT,
'summary' => 'edit three'
) );
$revisions[3]->insertOn( $dbw );
'timestamp' => '20120101000200',
'user' => $userA->getId(),
'text' => 'zero',
+ 'content_model' => CONTENT_MODEL_WIKITEXT,
'summary' => 'edit four'
) );
$revisions[4]->insertOn( $dbw );
}
function dataGetContentModel() {
+ //NOTE: we expect the help namespace to always contain wikitext
return array(
- array( 'hello world', 'Hello', null, null, CONTENT_MODEL_WIKITEXT ),
+ array( 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ),
array( 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ),
array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
);
}
function dataGetContentFormat() {
+ //NOTE: we expect the help namespace to always contain wikitext
return array(
- array( 'hello world', 'Hello', null, null, CONTENT_FORMAT_WIKITEXT ),
- array( 'hello world', 'Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ),
+ array( 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ),
+ array( 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ),
array( 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ),
array( serialize('hello world'), 'Dummy:Hello', null, null, "testing" ),
);
}
function dataGetContentHandler() {
+ //NOTE: we expect the help namespace to always contain wikitext
return array(
- array( 'hello world', 'Hello', null, null, 'WikitextContentHandler' ),
+ array( 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ),
array( 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ),
array( serialize('hello world'), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
);
}
function dataGetContent() {
+ //NOTE: we expect the help namespace to always contain wikitext
return array(
- array( 'hello world', 'Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
+ 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') ),
);
}
function dataGetText() {
+ //NOTE: we expect the help namespace to always contain wikitext
return array(
- array( 'hello world', 'Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
+ array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
array( serialize('hello world'), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
array( serialize('hello world'), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
);
public function dataGetSize( ) {
return array(
- array( "hello world.", null, 12 ),
+ array( "hello world.", CONTENT_MODEL_WIKITEXT, 12 ),
array( serialize( "hello world." ), "testing", 12 ),
);
}
public function dataGetSha1( ) {
return array(
- array( "hello world.", null, Revision::base36Sha1( "hello world." ) ),
+ array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
);
}
/**
* @group ContentHandler
+ *
+ * @note: We don't make assumptions about the main namespace.
+ * But we do expect the Help namespace to contain Wikitext.
+ *
*/
class TitleMethodsTest extends MediaWikiTestCase {
public function dataGetContentModel() {
return array(
- array( 'Foo', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo.js', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ),
public function dataIsCssOrJsPage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.js', false ),
- array( 'Foo/bar.js', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.js', false ),
+ array( 'Help:Foo/bar.js', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo/bar.js', false ),
public function dataIsCssJsSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.js', false ),
- array( 'Foo/bar.js', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.js', false ),
+ array( 'Help:Foo/bar.js', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo/bar.js', true ),
public function dataIsCssSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.css', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.css', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo.css', false ),
public function dataIsJsSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.css', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.css', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo.css', false ),
public function dataIsWikitextPage() {
return array(
- array( 'Foo', true ),
- array( 'Foo.js', true ),
- array( 'Foo/bar.js', true ),
+ array( 'Help:Foo', true ),
+ array( 'Help:Foo.js', true ),
+ array( 'Help:Foo/bar.js', true ),
array( 'User:Foo', true ),
array( 'User:Foo.js', true ),
array( 'User:Foo/bar.js', false ),
parent::__construct( $name, $data, $dataName );
$this->tablesUsed = array_merge ( $this->tablesUsed,
- array( 'page',
- 'revision',
- 'text',
-
- 'recentchanges',
- 'logging',
-
- 'page_props',
- 'pagelinks',
- 'categorylinks',
- 'langlinks',
- 'externallinks',
- 'imagelinks',
- 'templatelinks',
- 'iwlinks' ) );
- }
-
+ array( 'page',
+ 'revision',
+ 'text',
+
+ 'recentchanges',
+ 'logging',
+
+ 'page_props',
+ 'pagelinks',
+ 'categorylinks',
+ 'langlinks',
+ 'externallinks',
+ 'imagelinks',
+ 'templatelinks',
+ 'iwlinks' ) );
+ }
+
public function setUp() {
parent::setUp();
$this->pages_to_delete = array();
/**
* @param Title $title
+ * @param String $model
* @return WikiPage
*/
- protected function newPage( $title ) {
- if ( is_string( $title ) ) $title = Title::newFromText( $title );
+ protected function newPage( $title, $model = null ) {
+ if ( is_string( $title ) ) {
+ $title = Title::newFromText( $title );
+ }
$p = new WikiPage( $title );
* @return WikiPage
*/
protected function createPage( $page, $text, $model = null ) {
- if ( is_string( $page ) ) $page = Title::newFromText( $page );
+ if ( is_string( $page ) ) {
+ $page = Title::newFromText( $page );
+ }
if ( $page instanceof Title ) {
- $title = $page;
- $page = $this->newPage( $page );
- } else {
- $title = null;
+ $page = $this->newPage( $page, $model );
}
$content = ContentHandler::makeContent( $text, $page->getTitle(), $model );
$page = $this->newPage( $title );
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
- $title );
+ . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+ $title, CONTENT_MODEL_WIKITEXT );
$page->doEditContent( $content, "[[testing]] 1" );
# ------------------------
$content = ContentHandler::makeContent( "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
- . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.",
- $title );
+ . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.",
+ $title, CONTENT_MODEL_WIKITEXT );
$page->doEditContent( $content, "testing 2" );
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
-
+
public function testDoEdit() {
$this->hideDeprecated( "WikiPage::doEdit" );
$this->hideDeprecated( "WikiPage::getText" );
$this->hideDeprecated( "Revision::getText" );
- $title = Title::newFromText( "WikiPageTest_testDoEdit" );
+ //NOTE: assume help namespace will default to wikitext
+ $title = Title::newFromText( "Help:WikiPageTest_testDoEdit" );
$page = $this->newPage( $title );
$text = "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
+ . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
$page->doEdit( $text, "[[testing]] 1" );
# ------------------------
$text = "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
- . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.";
+ . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.";
$page->doEdit( $text, "testing 2" );
$this->hideDeprecated( "WikiPage::doQuickEdit" );
- $page = $this->createPage( "WikiPageTest_testDoQuickEdit", "original text" );
+ //NOTE: assume help namespace will default to wikitext
+ $page = $this->createPage( "Help:WikiPageTest_testDoQuickEdit", "original text" );
$text = "quick text";
$page->doQuickEdit( $text, $wgUser, "testing q" );
public function testDoQuickEditContent() {
global $wgUser;
- $page = $this->createPage( "WikiPageTest_testDoQuickEditContent", "original text" );
+ $page = $this->createPage( "WikiPageTest_testDoQuickEditContent", "original text", CONTENT_MODEL_WIKITEXT );
- $content = ContentHandler::makeContent( "quick text", $page->getTitle() );
+ $content = ContentHandler::makeContent( "quick text", $page->getTitle(), CONTENT_MODEL_WIKITEXT );
$page->doQuickEditContent( $content, $wgUser, "testing q" );
# ---------------------
$page = new WikiPage( $page->getTitle() );
$this->assertTrue( $content->equals( $page->getContent() ) );
}
-
+
public function testDoDeleteArticle() {
- $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo" );
+ $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$page->doDeleteArticle( "testing deletion" );
}
public function testDoDeleteUpdates() {
- $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo" );
+ $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$page->doDeleteUpdates( $id );
$this->assertNull( $rev );
# -----------------
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$rev = $page->getRevision();
$this->assertNull( $content );
# -----------------
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$content = $page->getContent();
$this->assertEquals( "some text", $content->getNativeData() );
$this->assertFalse( $text );
# -----------------
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$text = $page->getText();
$this->assertEquals( "some text", $text );
$this->assertFalse( $text );
# -----------------
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$text = $page->getRawText();
$this->assertEquals( "some text", $text );
$this->assertFalse( $page->exists() );
# -----------------
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$this->assertTrue( $page->exists() );
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( $viewable, $page->hasViewableContent() );
if ( $create ) {
- $this->createPage( $page, "some text" );
+ $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
$this->assertTrue( $page->hasViewableContent() );
$page = new WikiPage( $page->getTitle() );
public function dataGetRedirectTarget() {
return array(
- array( 'WikiPageTest_testGetRedirectTarget_1', "hello world", null ),
- array( 'WikiPageTest_testGetRedirectTarget_2', "#REDIRECT [[hello world]]", "Hello world" ),
+ array( 'WikiPageTest_testGetRedirectTarget_1', CONTENT_MODEL_WIKITEXT, "hello world", null ),
+ array( 'WikiPageTest_testGetRedirectTarget_2', CONTENT_MODEL_WIKITEXT, "#REDIRECT [[hello world]]", "Hello world" ),
);
}
/**
* @dataProvider dataGetRedirectTarget
*/
- public function testGetRedirectTarget( $title, $text, $target ) {
- $page = $this->createPage( $title, $text );
+ public function testGetRedirectTarget( $title, $model, $text, $target ) {
+ $page = $this->createPage( $title, $text, $model );
# sanity check, because this test seems to fail for no reason for some people.
$c = $page->getContent();
$this->assertEquals( 'WikitextContent', get_class( $c ) );
-
+
# now, test the actual redirect
$t = $page->getRedirectTarget();
$this->assertEquals( $target, is_null( $t ) ? null : $t->getPrefixedText() );
/**
* @dataProvider dataGetRedirectTarget
*/
- public function testIsRedirect( $title, $text, $target ) {
- $page = $this->createPage( $title, $text );
+ public function testIsRedirect( $title, $model, $text, $target ) {
+ $page = $this->createPage( $title, $text, $model );
$this->assertEquals( !is_null( $target ), $page->isRedirect() );
}
// any
array( 'WikiPageTest_testIsCountable',
- '',
- 'any',
- true
+ CONTENT_MODEL_WIKITEXT,
+ '',
+ 'any',
+ true
),
array( 'WikiPageTest_testIsCountable',
- 'Foo',
- 'any',
- true
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo',
+ 'any',
+ true
),
// comma
array( 'WikiPageTest_testIsCountable',
- 'Foo',
- 'comma',
- false
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo',
+ 'comma',
+ false
),
array( 'WikiPageTest_testIsCountable',
- 'Foo, bar',
- 'comma',
- true
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo, bar',
+ 'comma',
+ true
),
// link
array( 'WikiPageTest_testIsCountable',
- 'Foo',
- 'link',
- false
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo',
+ 'link',
+ false
),
array( 'WikiPageTest_testIsCountable',
- 'Foo [[bar]]',
- 'link',
- true
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo [[bar]]',
+ 'link',
+ true
),
// redirects
array( 'WikiPageTest_testIsCountable',
- '#REDIRECT [[bar]]',
- 'any',
- false
+ CONTENT_MODEL_WIKITEXT,
+ '#REDIRECT [[bar]]',
+ 'any',
+ false
),
array( 'WikiPageTest_testIsCountable',
- '#REDIRECT [[bar]]',
- 'comma',
- false
+ CONTENT_MODEL_WIKITEXT,
+ '#REDIRECT [[bar]]',
+ 'comma',
+ false
),
array( 'WikiPageTest_testIsCountable',
- '#REDIRECT [[bar]]',
- 'link',
- false
+ CONTENT_MODEL_WIKITEXT,
+ '#REDIRECT [[bar]]',
+ 'link',
+ false
),
// not a content namespace
array( 'Talk:WikiPageTest_testIsCountable',
- 'Foo',
- 'any',
- false
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo',
+ 'any',
+ false
),
array( 'Talk:WikiPageTest_testIsCountable',
- 'Foo, bar',
- 'comma',
- false
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo, bar',
+ 'comma',
+ false
),
array( 'Talk:WikiPageTest_testIsCountable',
- 'Foo [[bar]]',
- 'link',
- false
+ CONTENT_MODEL_WIKITEXT,
+ 'Foo [[bar]]',
+ 'link',
+ false
),
// not a content namespace, different model
array( 'MediaWiki:WikiPageTest_testIsCountable.js',
- 'Foo',
- 'any',
- false
+ null,
+ 'Foo',
+ 'any',
+ false
),
array( 'MediaWiki:WikiPageTest_testIsCountable.js',
- 'Foo, bar',
- 'comma',
- false
+ null,
+ 'Foo, bar',
+ 'comma',
+ false
),
array( 'MediaWiki:WikiPageTest_testIsCountable.js',
- 'Foo [[bar]]',
- 'link',
- false
+ null,
+ 'Foo [[bar]]',
+ 'link',
+ false
),
);
}
/**
* @dataProvider dataIsCountable
*/
- public function testIsCountable( $title, $text, $mode, $expected ) {
+ public function testIsCountable( $title, $model, $text, $mode, $expected ) {
global $wgArticleCountMethod;
$oldArticleCountMethod = $wgArticleCountMethod;
$wgArticleCountMethod = $mode;
- $page = $this->createPage( $title, $text );
+ $page = $this->createPage( $title, $text, $model );
$hasLinks = wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
array( 'pl_from' => $page->getId() ), __METHOD__ );
$wgArticleCountMethod = $oldArticleCountMethod;
$this->assertEquals( $expected, $v, "isCountable( null ) returned unexpected value " . var_export( $v, true )
- . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
$this->assertEquals( $expected, $w, "isCountable( \$editInfo ) returned unexpected value " . var_export( $v, true )
- . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
+ . " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
}
public function dataGetParserOutput() {
return array(
- array("hello ''world''\n", "<p>hello <i>world</i></p>"),
+ array( CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>"),
// @todo: more...?
);
}
/**
* @dataProvider dataGetParserOutput
*/
- public function testGetParserOutput( $text, $expectedHtml ) {
- $page = $this->createPage( 'WikiPageTest_testGetParserOutput', $text );
+ public function testGetParserOutput( $model, $text, $expectedHtml ) {
+ $page = $this->createPage( 'WikiPageTest_testGetParserOutput', $text, $model );
$opt = new ParserOptions();
$po = $page->getParserOutput( $opt );
public function dataReplaceSection() {
+ //NOTE: assume the Help namespace to contain wikitext
return array(
- array( 'WikiPageTest_testReplaceSection',
- WikiPageTest::$sections,
- "0",
- "No more",
- null,
- trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
- ),
- array( 'WikiPageTest_testReplaceSection',
- WikiPageTest::$sections,
- "",
- "No more",
- null,
- "No more"
- ),
- array( 'WikiPageTest_testReplaceSection',
- WikiPageTest::$sections,
- "2",
- "== TEST ==\nmore fun",
- null,
- trim( preg_replace( '/^== test ==.*== foo ==/sm',
- "== TEST ==\nmore fun\n\n== foo ==",
- WikiPageTest::$sections ) )
- ),
- array( 'WikiPageTest_testReplaceSection',
- WikiPageTest::$sections,
- "8",
- "No more",
- null,
- trim( WikiPageTest::$sections )
- ),
- array( 'WikiPageTest_testReplaceSection',
- WikiPageTest::$sections,
- "new",
- "No more",
- "New",
- trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
+ array( 'Help:WikiPageTest_testReplaceSection',
+ CONTENT_MODEL_WIKITEXT,
+ WikiPageTest::$sections,
+ "0",
+ "No more",
+ null,
+ trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
+ ),
+ array( 'Help:WikiPageTest_testReplaceSection',
+ CONTENT_MODEL_WIKITEXT,
+ WikiPageTest::$sections,
+ "",
+ "No more",
+ null,
+ "No more"
+ ),
+ array( 'Help:WikiPageTest_testReplaceSection',
+ CONTENT_MODEL_WIKITEXT,
+ WikiPageTest::$sections,
+ "2",
+ "== TEST ==\nmore fun",
+ null,
+ trim( preg_replace( '/^== test ==.*== foo ==/sm',
+ "== TEST ==\nmore fun\n\n== foo ==",
+ WikiPageTest::$sections ) )
+ ),
+ array( 'Help:WikiPageTest_testReplaceSection',
+ CONTENT_MODEL_WIKITEXT,
+ WikiPageTest::$sections,
+ "8",
+ "No more",
+ null,
+ trim( WikiPageTest::$sections )
+ ),
+ array( 'Help:WikiPageTest_testReplaceSection',
+ CONTENT_MODEL_WIKITEXT,
+ WikiPageTest::$sections,
+ "new",
+ "No more",
+ "New",
+ trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
),
);
}
/**
* @dataProvider dataReplaceSection
*/
- public function testReplaceSection( $title, $text, $section, $with, $sectionTitle, $expected ) {
+ public function testReplaceSection( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
$this->hideDeprecated( "WikiPage::replaceSection" );
- $page = $this->createPage( $title, $text );
+ $page = $this->createPage( $title, $text, $model );
$text = $page->replaceSection( $section, $with, $sectionTitle );
$text = trim( $text );
/**
* @dataProvider dataReplaceSection
*/
- public function testReplaceSectionContent( $title, $text, $section, $with, $sectionTitle, $expected ) {
- $page = $this->createPage( $title, $text );
+ public function testReplaceSectionContent( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
+ $page = $this->createPage( $title, $text, $model );
$content = ContentHandler::makeContent( $with, $page->getTitle(), $page->getContentModel() );
$c = $page->replaceSectionContent( $section, $content, $sectionTitle );
$this->assertEquals( $expected, is_null( $c ) ? null : trim( $c->getNativeData() ) );
}
-
+
/* @todo FIXME: fix this!
public function testGetUndoText() {
global $wgDiff3;
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
"section one", EDIT_NEW, false, $admin );
$rev1 = $page->getRevision();
$user1->setName( "127.0.1.11" );
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
- $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
+ $page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ),
"adding section two", 0, false, $user1 );
# now, try the rollback
array(
array(
array( "first edit: "
- . "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.'", null ),
+ . "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.'", null ),
),
'/first edit:.*\.\.\."/',
false
public function testGetAutoDeleteReason( $edits, $expectedResult, $expectedHistory ) {
global $wgUser;
- $page = $this->newPage( "WikiPageTest_testGetAutoDeleteReason" );
+ //NOTE: assume Help namespace to contain wikitext
+ $page = $this->newPage( "Help:WikiPageTest_testGetAutoDeleteReason" );
$c = 1;
public function dataPreSaveTransform() {
return array(
array( 'hello this is ~~~',
- "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
+ "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
),
array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
- 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+ 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
),
);
}
$user = new User();
$user->setName("127.0.0.1");
- $page = $this->newPage( "WikiPageTest_testPreloadTransform" );
+ //NOTE: assume Help namespace to contain wikitext
+ $page = $this->newPage( "Help:WikiPageTest_testPreloadTransform" );
$text = $page->preSaveTransform( $text, $user );
$this->assertEquals( $expected, $text );
public function dataGetParserOutput() {
return array(
- array("WikitextContentTest_testGetParserOutput", "hello ''world''\n", "<p>hello <i>world</i>\n</p>"),
+ array("WikitextContentTest_testGetParserOutput", CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i>\n</p>"),
// @todo: more...?
);
}
/**
* @dataProvider dataGetParserOutput
*/
- public function testGetParserOutput( $title, $text, $expectedHtml ) {
+ public function testGetParserOutput( $title, $model, $text, $expectedHtml ) {
$title = Title::newFromText( $title );
- $content = ContentHandler::makeContent( $text, $title );
+ $content = ContentHandler::makeContent( $text, $title, $model );
$po = $content->getParserOutput( $title );
public function dataGetSecondaryDataUpdates() {
return array(
- array("WikitextContentTest_testGetSecondaryDataUpdates_1", "hello ''world''\n",
+ array("WikitextContentTest_testGetSecondaryDataUpdates_1",
+ CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
array( 'LinksUpdate' => array( 'mRecursive' => true,
'mLinks' => array() ) )
),
- array("WikitextContentTest_testGetSecondaryDataUpdates_2", "hello [[world test 21344]]\n",
+ array("WikitextContentTest_testGetSecondaryDataUpdates_2",
+ CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
array( 'LinksUpdate' => array( 'mRecursive' => true,
'mLinks' => array( array( 'World_test_21344' => 0 ) ) ) )
),
* @dataProvider dataGetSecondaryDataUpdates
* @group Database
*/
- public function testGetSecondaryDataUpdates( $title, $text, $expectedStuff ) {
+ public function testGetSecondaryDataUpdates( $title, $model, $text, $expectedStuff ) {
$title = Title::newFromText( $title );
$title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
- $handler = ContentHandler::getForModelID( $title->getContentModel() );
- $content = ContentHandler::makeContent( $text, $title );
+ $content = ContentHandler::makeContent( $text, $title, $model );
$updates = $content->getSecondaryDataUpdates( $title );
public function dataGetDeletionUpdates() {
return array(
- array("WikitextContentTest_testGetSecondaryDataUpdates_1", "hello ''world''\n",
+ array("WikitextContentTest_testGetSecondaryDataUpdates_1",
+ CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
array( 'LinksDeletionUpdate' => array( ) )
),
- array("WikitextContentTest_testGetSecondaryDataUpdates_2", "hello [[world test 21344]]\n",
+ array("WikitextContentTest_testGetSecondaryDataUpdates_2",
+ CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
array( 'LinksDeletionUpdate' => array( ) )
),
// @todo: more...?
/**
* @dataProvider dataGetDeletionUpdates
*/
- public function testDeletionUpdates( $title, $text, $expectedStuff ) {
+ public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) {
$title = Title::newFromText( $title );
$title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates!
- $handler = ContentHandler::getForModelID( $title->getContentModel() );
- $content = ContentHandler::makeContent( $text, $title );
+ $content = ContentHandler::makeContent( $text, $title, $model );
$updates = $content->getDeletionUpdates( WikiPage::factory( $title ) );
}
function testEdit( ) {
- $name = 'ApiEditPageTest_testEdit';
+ $name = 'Help:ApiEditPageTest_testEdit'; // assume Help namespace to default to wikitext
// -- test new page --------------------------------------------
$apiResult = $this->doApiRequestWithToken( array(
$data = $this->doApiRequest( array(
'action' => 'edit',
- 'title' => 'UTPage',
+ 'title' => 'Help:UTPage', // Help namespace is hopefully wikitext
'text' => 'new text',
'token' => $pageinfo['edittoken'],
'watchlist' => 'watch' ) );
$data = $this->doApiRequest( array(
'action' => 'protect',
'token' => $pageinfo['protecttoken'],
- 'title' => 'UTPage',
+ 'title' => 'Help:UTPage',
'protections' => 'edit=sysop',
'watchlist' => 'unwatch' ) );
$pageinfo = $this->getTokens();
- if ( !Title::newFromText( 'UTPage' )->exists() ) {
- $this->markTestSkipped( "The article [[UTPage]] does not exist" ); //TODO: just create it?
+ if ( !Title::newFromText( 'Help:UTPage' )->exists() ) {
+ $this->markTestSkipped( "The article [[Help:UTPage]] does not exist" ); //TODO: just create it?
}
$data = $this->doApiRequest( array(
'action' => 'query',
'prop' => 'revisions',
- 'titles' => 'UTPage',
+ 'titles' => 'Help:UTPage',
'rvtoken' => 'rollback' ) );
$this->assertArrayHasKey( 'query', $data[0] );
$key = array_pop( $keys );
if ( isset( $data[0]['query']['pages'][$key]['missing'] ) ) {
- $this->markTestSkipped( "Target page (UTPage) doesn't exist" );
+ $this->markTestSkipped( "Target page (Help:UTPage) doesn't exist" );
}
$this->assertArrayHasKey( 'pageid', $data[0]['query']['pages'][$key] );
try {
$data = $this->doApiRequest( array(
'action' => 'rollback',
- 'title' => 'UTPage',
+ 'title' => 'Help:UTPage',
'user' => $revinfo['user'],
'token' => $pageinfo['rollbacktoken'],
'watchlist' => 'watch' ) );
$this->assertArrayHasKey( 'title', $data[0]['rollback'] );
} catch( UsageException $ue ) {
if( $ue->getCodeString() == 'onlyauthor' ) {
- $this->markTestIncomplete( "Only one author to 'UTPage', cannot test rollback" );
+ $this->markTestIncomplete( "Only one author to 'Help:UTPage', cannot test rollback" );
} else {
$this->fail( "Received error '" . $ue->getCodeString() . "'" );
}
$data = $this->doApiRequest( array(
'action' => 'delete',
'token' => $pageinfo['deletetoken'],
- 'title' => 'UTPage' ) );
+ 'title' => 'Help:UTPage' ) );
$this->assertArrayHasKey( 'delete', $data[0] );
$this->assertArrayHasKey( 'title', $data[0]['delete'] );