Merge "Added release notes for 'ContentHandler::runLegacyHooks' removal"
[mediawiki.git] / tests / phpunit / includes / title / SubpageImportTitleFactoryTest.php
blobbaeb95cfad25e5757f7b52e8f1eacd83fe24c75b
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @author This, that and the other
22 /**
23 * @covers SubpageImportTitleFactory
25 * @group Title
27 class SubpageImportTitleFactoryTest extends MediaWikiTestCase {
29 protected function setUp() {
30 parent::setUp();
32 $this->setMwGlobals( [
33 'wgLanguageCode' => 'en',
34 'wgContLang' => Language::factory( 'en' ),
35 'wgNamespacesWithSubpages' => [ 0 => false, 2 => true ],
36 ] );
39 public function basicProvider() {
40 return [
42 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
43 Title::newFromText( 'User:Graham' ),
44 Title::newFromText( 'User:Graham/MainNamespaceArticle' )
47 new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
48 Title::newFromText( 'User:Graham' ),
49 Title::newFromText( 'User:Graham/Discussion:Nice_talk' )
52 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
53 Title::newFromText( 'User:Graham' ),
54 Title::newFromText( 'User:Graham/Bogus:Nice_talk' )
59 /**
60 * @dataProvider basicProvider
62 public function testBasic( ForeignTitle $foreignTitle, Title $rootPage,
63 Title $title ) {
65 $factory = new SubpageImportTitleFactory( $rootPage );
66 $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
68 $this->assertTrue( $testTitle->equals( $title ) );
71 public function failureProvider() {
72 return [
74 Title::newFromText( 'Graham' ),
79 /**
80 * @dataProvider failureProvider
82 public function testFailures( Title $rootPage ) {
83 $this->setExpectedException( 'MWException' );
84 new SubpageImportTitleFactory( $rootPage );