Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / title / SubpageImportTitleFactoryTest.php
blob6514d0e49a21b29f497ce7a09d31d5a473fab4a6
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 use MediaWiki\MainConfigNames;
23 use MediaWiki\Title\ForeignTitle;
24 use MediaWiki\Title\SubpageImportTitleFactory;
25 use MediaWiki\Title\Title;
27 /**
28 * @covers \MediaWiki\Title\SubpageImportTitleFactory
30 * @group Title
32 * TODO convert to Unit tests
34 class SubpageImportTitleFactoryTest extends MediaWikiIntegrationTestCase {
36 protected function setUp(): void {
37 parent::setUp();
39 $this->overrideConfigValues( [
40 MainConfigNames::LanguageCode => 'en',
41 MainConfigNames::NamespacesWithSubpages => [ 0 => false, 2 => true ],
42 ] );
45 private function newSubpageImportTitleFactory( Title $rootPage ) {
46 return new SubpageImportTitleFactory(
47 $this->getServiceContainer()->getNamespaceInfo(),
48 $this->getServiceContainer()->getTitleFactory(),
49 $rootPage
53 public static function basicProvider() {
54 return [
56 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
57 Title::makeTitle( NS_USER, 'Graham' ),
58 Title::makeTitle( NS_USER, 'Graham/MainNamespaceArticle' )
61 new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
62 Title::makeTitle( NS_USER, 'Graham' ),
63 Title::makeTitle( NS_USER, 'Graham/Discussion:Nice_talk' )
66 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
67 Title::makeTitle( NS_USER, 'Graham' ),
68 Title::makeTitle( NS_USER, 'Graham/Bogus:Nice_talk' )
73 /**
74 * @dataProvider basicProvider
76 public function testBasic( ForeignTitle $foreignTitle, Title $rootPage,
77 Title $title
78 ) {
79 $factory = $this->newSubpageImportTitleFactory( $rootPage );
80 $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
82 $this->assertTrue( $testTitle->equals( $title ) );
85 public function testInvalidNamespace() {
86 $this->expectException( InvalidArgumentException::class );
87 $this->newSubpageImportTitleFactory( Title::makeTitle( NS_MAIN, 'Graham' ) );