MediaWiki  1.28.1
Go to the documentation of this file.
1 <?php
13  public function testIsValidMove( $old, $new, $error ) {
14  $this->setMwGlobals( 'wgContentHandlerUseDB', false );
15  $mp = new MovePage(
16  Title::newFromText( $old ),
17  Title::newFromText( $new )
18  );
19  $status = $mp->isValidMove();
20  if ( $error === true ) {
21  $this->assertTrue( $status->isGood() );
22  } else {
23  $this->assertTrue( $status->hasMessage( $error ) );
24  }
25  }
30  public static function provideIsValidMove() {
31  return [
32  // for MovePage::isValidMove
33  [ 'Test', 'Test', 'selfmove' ],
34  [ 'Special:FooBar', 'Test', 'immobile-source-namespace' ],
35  [ 'Test', 'Special:FooBar', 'immobile-target-namespace' ],
36  [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ],
37  [ 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ],
38  // for MovePage::isValidFileMove
39  [ 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ],
40  ];
41  }
48  $oldTitle = Title::newFromText( 'Help:Some title' );
49  WikiPage::factory( $oldTitle )->doEditContent( new WikitextContent( 'foo' ), 'bar' );
50  $newTitle = Title::newFromText( 'Help:Some other title' );
51  $this->assertNull(
52  WikiPage::factory( $newTitle )->getRevision()
53  );
55  $this->assertTrue( $oldTitle->moveTo( $newTitle, false, 'test1', true ) );
56  $this->assertNotNull(
57  WikiPage::factory( $oldTitle )->getRevision()
58  );
59  $this->assertNotNull(
60  WikiPage::factory( $newTitle )->getRevision()
61  );
62  }
63 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:115
Handles the backend logic of moving a page from one title to another.
Definition: MovePage.php:30
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:262
Integration test to catch regressions like T74870.
Definition: MovePageTest.php:6
Content object for wiki text pages.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
versus $oldTitle
Definition: globals.txt:16
testIsValidMove($old, $new, $error)
provideIsValidMove MovePage::isValidMove MovePage::isValidFileMove
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1046
setMwGlobals($pairs, $value=null)
static provideIsValidMove()
This should be kept in sync with TitleTest::provideTestIsValidMoveOperation.