Debian Codegraph @

tests/phpunit/includes/title/NamespaceImportTitleFactoryTest.php

raw symbols SCIP
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.
7 *
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.
12 *
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
17 *
18 * @file
19 * @author This, that and the other
20 */
21
22 use MediaWiki\Title\ForeignTitle;
23 use MediaWiki\Title\NamespaceImportTitleFactory;
24 use MediaWiki\Title\Title;
25
26 /**
27 * @covers \MediaWiki\Title\NamespaceImportTitleFactory
28 *
29 * @group Title
30 *
31 * TODO convert to unit tests
32 */
33 class NamespaceImportTitleFactoryTest extends MediaWikiIntegrationTestCase {
34
35 protected function setUp(): void {
36 parent::setUp();
37
38 $this->setContentLang( 'en' );
39 }
40
41 public static function basicProvider() {
42 return [
43 [
44 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
45 0,
46 'MainNamespaceArticle'
47 ],
48 [
49 new ForeignTitle( 0, '', 'MainNamespaceArticle' ),
50 2,
51 'User:MainNamespaceArticle'
52 ],
53 [
54 new ForeignTitle( 1, 'Discussion', 'Nice_talk' ),
55 0,
56 'Nice_talk'
57 ],
58 [
59 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
60 0,
61 'Bogus:Nice_talk'
62 ],
63 [
64 new ForeignTitle( 0, '', 'Bogus:Nice_talk' ),
65 2,
66 'User:Bogus:Nice_talk'
67 ],
68 ];
69 }
70
71 /**
72 * @dataProvider basicProvider
73 */
74 public function testBasic( ForeignTitle $foreignTitle, $ns, $titleText ) {
75 $factory = new NamespaceImportTitleFactory(
76 $this->getServiceContainer()->getNamespaceInfo(),
77 $this->getServiceContainer()->getTitleFactory(),
78 $ns
79 );
80 $testTitle = $factory->createTitleFromForeignTitle( $foreignTitle );
81 $title = Title::newFromText( $titleText );
82
83 $this->assertTrue( $title->equals( $testTitle ) );
84 }
85 }