Editing unit tests: set title in context
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 17 Jul 2014 22:28:46 +0000 (15:28 -0700)
committerOri.livneh <ori@wikimedia.org>
Thu, 17 Jul 2014 23:59:00 +0000 (23:59 +0000)
It is assumed that users of EditFilterMergedContent hook need to get
the page being edited from context as it happens during normal functioning,
tests shouldn't violate this convention.

Bug: 66930
Change-Id: I8d453d819aad8630d4934a15e7bf512fa828fe24

tests/phpunit/includes/EditPageTest.php

index 3c653b4..6b8bf27 100644 (file)
@@ -96,6 +96,7 @@ class EditPageTest extends MediaWikiLangTestCase {
                        $ns = $this->getDefaultWikitextNS();
                        $title = Title::newFromText( $title, $ns );
                }
+               $this->assertNotNull( $title );
 
                if ( is_string( $user ) ) {
                        $user = User::newFromName( $user );
@@ -141,7 +142,9 @@ class EditPageTest extends MediaWikiLangTestCase {
 
                $req = new FauxRequest( $edit, true ); // session ??
 
-               $ep = new EditPage( new Article( $title ) );
+               $article = new Article( $title );
+               $article->getContext()->setTitle( $title );
+               $ep = new EditPage( $article );
                $ep->setContextTitle( $title );
                $ep->importFormData( $req );