Merge "Fix and make some types in PHPDoc and JSDoc tags more specific"
[lhc/web/wiklou.git] / tests / phpunit / includes / site / TestSites.php
1 <?php
2
3 /**
4 * Holds sites for testing purposes.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 * @since 1.21
23 *
24 * @ingroup Site
25 * @ingroup Test
26 *
27 * @group Site
28 *
29 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
30 */
31 class TestSites {
32
33 /**
34 * @since 1.21
35 *
36 * @return array
37 */
38 public static function getSites() {
39 $sites = [];
40
41 $site = new Site();
42 $site->setGlobalId( 'foobar' );
43 $sites[] = $site;
44
45 $site = new MediaWikiSite();
46 $site->setGlobalId( 'enwiktionary' );
47 $site->setGroup( 'wiktionary' );
48 $site->setLanguageCode( 'en' );
49 $site->addNavigationId( 'enwiktionary' );
50 $site->setPath( MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/$1" );
51 $site->setPath( MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/$1" );
52 $sites[] = $site;
53
54 $site = new MediaWikiSite();
55 $site->setGlobalId( 'dewiktionary' );
56 $site->setGroup( 'wiktionary' );
57 $site->setLanguageCode( 'de' );
58 $site->addInterwikiId( 'dewiktionary' );
59 $site->addInterwikiId( 'wiktionaryde' );
60 $site->setPath( MediaWikiSite::PATH_PAGE, "https://de.wiktionary.org/wiki/$1" );
61 $site->setPath( MediaWikiSite::PATH_FILE, "https://de.wiktionary.org/w/$1" );
62 $sites[] = $site;
63
64 $site = new Site();
65 $site->setGlobalId( 'spam' );
66 $site->setGroup( 'spam' );
67 $site->setLanguageCode( 'en' );
68 $site->addNavigationId( 'spam' );
69 $site->addNavigationId( 'spamz' );
70 $site->addInterwikiId( 'spamzz' );
71 $site->setLinkPath( "http://spamzz.test/testing/" );
72 $sites[] = $site;
73
74 /**
75 * Add at least one right-to-left language (current RTL languages in MediaWiki core are:
76 * aeb, ar, arc, arz, azb, bcc, bqi, ckb, dv, en_rtl, fa, glk, he, khw, kk_arab, kk_cn,
77 * ks_arab, ku_arab, lrc, mzn, pnb, ps, sd, ug_arab, ur, yi).
78 */
79 $languageCodes = [
80 'de',
81 'en',
82 'fa', // right-to-left
83 'nl',
84 'nn',
85 'no',
86 'sr',
87 'sv',
88 ];
89 foreach ( $languageCodes as $langCode ) {
90 $site = new MediaWikiSite();
91 $site->setGlobalId( $langCode . 'wiki' );
92 $site->setGroup( 'wikipedia' );
93 $site->setLanguageCode( $langCode );
94 $site->addInterwikiId( $langCode );
95 $site->addNavigationId( $langCode );
96 $site->setPath( MediaWikiSite::PATH_PAGE, "https://$langCode.wikipedia.org/wiki/$1" );
97 $site->setPath( MediaWikiSite::PATH_FILE, "https://$langCode.wikipedia.org/w/$1" );
98 $sites[] = $site;
99 }
100
101 return $sites;
102 }
103
104 /**
105 * Inserts sites into the database for the unit tests that need them.
106 *
107 * @since 0.1
108 */
109 public static function insertIntoDb() {
110 $sitesTable = \MediaWiki\MediaWikiServices::getInstance()->getSiteStore();
111 $sitesTable->clear();
112 $sitesTable->saveSites( self::getSites() );
113 }
114 }