Merge "(bug 41295) Galician date and time localization"
[lhc/web/wiklou.git] / tests / phpunit / includes / WikiPageTest.php
index 02c0677..fb20ce6 100644 (file)
@@ -3,6 +3,7 @@
 * @group ContentHandler
 * @group Database
 * ^--- important, causes temporary tables to be used instead of the real database
+* @group medium
 **/
 
 class WikiPageTest extends MediaWikiLangTestCase {
@@ -12,32 +13,33 @@ class WikiPageTest extends MediaWikiLangTestCase {
        function  __construct( $name = null, array $data = array(), $dataName = '' ) {
                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' ) );
-       }
-       
-       public function setUp() {
+               $this->tablesUsed = array_merge (
+                       $this->tablesUsed,
+                       array( 'page',
+                                       'revision',
+                                       'text',
+
+                                       'recentchanges',
+                                       'logging',
+
+                                       'page_props',
+                                       'pagelinks',
+                                       'categorylinks',
+                                       'langlinks',
+                                       'externallinks',
+                                       'imagelinks',
+                                       'templatelinks',
+                                       'iwlinks' ) );
+       }
+
+       protected function setUp() {
                parent::setUp();
                $this->pages_to_delete = array();
 
                LinkCache::singleton()->clear(); # avoid cached redirect status, etc
        }
 
-       public function tearDown() {
+       protected function tearDown() {
                foreach ( $this->pages_to_delete as $p ) {
                        /* @var $p WikiPage */
 
@@ -54,10 +56,14 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
        /**
         * @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 ) ) {
+                       $ns = $this->getDefaultWikitextNS();
+                       $title = Title::newFromText( $title, $ns );
+               }
 
                $p = new WikiPage( $title );
 
@@ -75,13 +81,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
         * @return WikiPage
         */
        protected function createPage( $page, $text, $model = null ) {
-               if ( is_string( $page ) ) $page = Title::newFromText( $page );
-
-               if ( $page instanceof Title ) {
-                       $title = $page;
-                       $page = $this->newPage( $page );
-               } else {
-                       $title = null;
+               if ( is_string( $page ) || $page instanceof Title ) {
+                       $page = $this->newPage( $page, $model );
                }
 
                $content = ContentHandler::makeContent( $text, $page->getTitle(), $model );
@@ -91,13 +92,12 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        public function testDoEditContent() {
-               $title = Title::newFromText( "WikiPageTest_testDoEditContent" );
-
-               $page = $this->newPage( $title );
+               $page = $this->newPage( "WikiPageTest_testDoEditContent" );
+               $title = $page->getTitle();
 
                $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" );
 
@@ -124,8 +124,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                # ------------------------
                $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" );
 
@@ -143,14 +143,19 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                $this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
        }
-       
+
        public function testDoEdit() {
-               $title = Title::newFromText( "WikiPageTest_testDoEdit" );
+               $this->hideDeprecated( "WikiPage::doEdit" );
+               $this->hideDeprecated( "WikiPage::getText" );
+               $this->hideDeprecated( "Revision::getText" );
+
+               //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" );
 
@@ -177,7 +182,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
 
                # ------------------------
                $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" );
 
@@ -199,7 +204,10 @@ class WikiPageTest extends MediaWikiLangTestCase {
        public function testDoQuickEdit() {
                global $wgUser;
 
-               $page = $this->createPage( "WikiPageTest_testDoQuickEdit", "original text" );
+               $this->hideDeprecated( "WikiPage::doQuickEdit" );
+
+               //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" );
@@ -212,18 +220,18 @@ class WikiPageTest extends MediaWikiLangTestCase {
        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" );
@@ -247,7 +255,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        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 );
@@ -268,7 +276,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $this->assertNull( $rev );
 
                # -----------------
-               $this->createPage( $page, "some text" );
+               $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
 
                $rev = $page->getRevision();
 
@@ -283,33 +291,37 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $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() );
        }
 
        public function testGetText() {
+               $this->hideDeprecated( "WikiPage::getText" );
+
                $page = $this->newPage( "WikiPageTest_testGetText" );
 
                $text = $page->getText();
                $this->assertFalse( $text );
 
                # -----------------
-               $this->createPage( $page, "some text" );
+               $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
 
                $text = $page->getText();
                $this->assertEquals( "some text", $text );
        }
 
        public function testGetRawText() {
+               $this->hideDeprecated( "WikiPage::getRawText" );
+
                $page = $this->newPage( "WikiPageTest_testGetRawText" );
 
                $text = $page->getRawText();
                $this->assertFalse( $text );
 
                # -----------------
-               $this->createPage( $page, "some text" );
+               $this->createPage( $page, "some text", CONTENT_MODEL_WIKITEXT );
 
                $text = $page->getRawText();
                $this->assertEquals( "some text", $text );
@@ -346,7 +358,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $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() );
@@ -360,7 +372,7 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $this->assertFalse( $page->exists() );
        }
 
-       public function dataHasViewableContent() {
+       public static function provideHasViewableContent() {
                return array(
                        array( 'WikiPageTest_testHasViewableContent', false, true ),
                        array( 'Special:WikiPageTest_testHasViewableContent', false ),
@@ -371,14 +383,14 @@ class WikiPageTest extends MediaWikiLangTestCase {
        }
 
        /**
-        * @dataProvider dataHasViewableContent
+        * @dataProvider provideHasViewableContent
         */
        public function testHasViewableContent( $title, $viewable, $create = false ) {
                $page = $this->newPage( $title );
                $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() );
@@ -386,139 +398,160 @@ class WikiPageTest extends MediaWikiLangTestCase {
                }
        }
 
-       public function dataGetRedirectTarget() {
+       public static function provideGetRedirectTarget() {
                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
+        * @dataProvider provideGetRedirectTarget
         */
-       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
+        * @dataProvider provideGetRedirectTarget
         */
-       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() );
        }
 
-       public function dataIsCountable() {
+       public static function provideIsCountable() {
                return array(
 
                        // 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
+        * @dataProvider provideIsCountable
         */
-       public function testIsCountable( $title, $text, $mode, $expected ) {
-               global $wgArticleCountMethod;
+       public function testIsCountable( $title, $model, $text, $mode, $expected ) {
+               global $wgContentHandlerUseDB;
+
+               $this->setMwGlobals( 'wgArticleCountMethod', $mode );
 
-               $oldArticleCountMethod = $wgArticleCountMethod;
-               $wgArticleCountMethod = $mode;
+               $title = Title::newFromText( $title );
 
-               $page = $this->createPage( $title, $text );
+               if ( !$wgContentHandlerUseDB && ContentHandler::getDefaultModelFor( $title ) != $model ) {
+                       $this->markTestSkipped( "Can not use non-default content model $model for "
+                               . $title->getPrefixedDBkey() . " with \wgArticleCountMethod disabled." );
+               }
+
+               $page = $this->createPage( $title, $text, $model );
                $hasLinks = wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
                                        array( 'pl_from' => $page->getId() ), __METHOD__ );
 
@@ -527,29 +560,27 @@ class WikiPageTest extends MediaWikiLangTestCase {
                $v = $page->isCountable();
                $w = $page->isCountable( $editInfo );
 
-               $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() {
+       public static function provideGetParserOutput() {
                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
+        * @dataProvider provideGetParserOutput
         */
-       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();
+               $opt = $page->makeParserOptions( 'canonical' );
                $po = $page->getParserOutput( $opt );
                $text = $po->getText();
 
@@ -560,6 +591,29 @@ class WikiPageTest extends MediaWikiLangTestCase {
                return $po;
        }
 
+       public function testGetParserOutput_nonexisting( ) {
+               static $count = 0;
+               $count ++;
+
+               $page = new WikiPage( new Title( "WikiPageTest_testGetParserOutput_nonexisting_$count" ) );
+
+               $opt = new ParserOptions();
+               $po = $page->getParserOutput( $opt );
+
+               $this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." );
+       }
+
+       public function testGetParserOutput_badrev( ) {
+               $page = $this->createPage( 'WikiPageTest_testGetParserOutput', "dummy", CONTENT_MODEL_WIKITEXT );
+
+               $opt = new ParserOptions();
+               $po = $page->getParserOutput( $opt, $page->getLatest() + 1234 );
+
+               //@todo: would be neat to also test deleted revision
+
+               $this->assertFalse( $po, "getParserOutput() shall return false for non-existing revisions." );
+       }
+
        static $sections =
 
                "Intro
@@ -576,43 +630,49 @@ more stuff
 
 
        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"
                        ),
                );
        }
@@ -620,8 +680,10 @@ more stuff
        /**
         * @dataProvider dataReplaceSection
         */
-       public function testReplaceSection( $title, $text, $section, $with, $sectionTitle, $expected ) {
-               $page = $this->createPage( $title, $text );
+       public function testReplaceSection( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
+               $this->hideDeprecated( "WikiPage::replaceSection" );
+
+               $page = $this->createPage( $title, $text, $model );
                $text = $page->replaceSection( $section, $with, $sectionTitle );
                $text = trim( $text );
 
@@ -631,15 +693,15 @@ more stuff
        /**
         * @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;
@@ -756,7 +818,7 @@ more stuff
 
                $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();
 
@@ -764,7 +826,7 @@ more stuff
                $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
@@ -782,7 +844,7 @@ more stuff
                $this->assertEquals( "one", $page->getContent()->getNativeData() );
        }
 
-       public function dataGetAutosummary( ) {
+       public static function provideGetAutosummary( ) {
                return array(
                        array(
                                'Hello there, world!',
@@ -824,9 +886,11 @@ more stuff
        }
 
        /**
-        * @dataProvider dataGetAutoSummary
+        * @dataProvider provideGetAutoSummary
         */
        public function testGetAutosummary( $old, $new, $flags, $expected ) {
+               $this->hideDeprecated( "WikiPage::getAutosummary" );
+
                $page = $this->newPage( "WikiPageTest_testGetAutosummary" );
 
                $summary = $page->getAutosummary( $old, $new, $flags );
@@ -835,7 +899,7 @@ more stuff
                                                        "Autosummary didn't match expected pattern $expected: $summary" );
        }
 
-       public function dataGetAutoDeleteReason( ) {
+       public static function provideGetAutoDeleteReason( ) {
                return array(
                        array(
                                array(),
@@ -872,10 +936,10 @@ more stuff
                        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
@@ -894,12 +958,13 @@ more stuff
        }
 
        /**
-        * @dataProvider dataGetAutoDeleteReason
+        * @dataProvider provideGetAutoDeleteReason
         */
        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;
 
@@ -928,26 +993,27 @@ more stuff
                $page->doDeleteArticle( "done" );
        }
 
-       public function dataPreSaveTransform() {
+       public static function providePreSaveTransform() {
                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>',
                        ),
                );
        }
 
        /**
-        * @dataProvider dataPreSaveTransform
+        * @dataProvider providePreSaveTransform
         */
        public function testPreSaveTransform( $text, $expected ) {
                $this->hideDeprecated( 'WikiPage::preSaveTransform' );
                $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 );