Merge "Removed READ_LATEST default from Revision::newFromTitle()."
[lhc/web/wiklou.git] / tests / phpunit / includes / site / SitesTest.php
1 <?php
2
3 /**
4 * Tests for the Sites class.
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 * @group Database
29 *
30 * @licence GNU GPL v2+
31 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
32 */
33 class SitesTest extends MediaWikiTestCase {
34
35 public function setUp() {
36 parent::setUp();
37 TestSites::insertIntoDb();
38 }
39
40 public function testSingleton() {
41 $this->assertInstanceOf( 'Sites', Sites::singleton() );
42 $this->assertTrue( Sites::singleton() === Sites::singleton() );
43 }
44
45 public function testGetSites() {
46 $this->assertInstanceOf( 'SiteList', Sites::singleton()->getSites() );
47 }
48
49
50 public function testGetSite() {
51 $count = 0;
52 $sites = Sites::singleton()->getSites();
53
54 /**
55 * @var Site $site
56 */
57 foreach ( $sites as $site ) {
58 $this->assertInstanceOf( 'Site', $site );
59
60 $this->assertEquals(
61 $site,
62 Sites::singleton()->getSite( $site->getGlobalId() )
63 );
64
65 if ( ++$count > 100 ) {
66 break;
67 }
68 }
69 }
70
71 public function testNewSite() {
72 $this->assertInstanceOf( 'Site', Sites::newSite() );
73 $this->assertInstanceOf( 'Site', Sites::newSite( 'enwiki' ) );
74 }
75
76 public function testGetGroup() {
77 $wikipedias = Sites::singleton()->getSiteGroup( "wikipedia" );
78
79 $this->assertFalse( $wikipedias->isEmpty() );
80
81 /* @var Site $site */
82 foreach ( $wikipedias as $site ) {
83 $this->assertEquals( 'wikipedia', $site->getGroup() );
84 }
85 }
86
87 }