4 * Tests for the Sites class.
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.
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.
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
30 * @licence GNU GPL v2+
31 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
33 class SitesTest
extends MediaWikiTestCase
{
35 public function setUp() {
37 TestSites
::insertIntoDb();
40 public function testSingleton() {
41 $this->assertInstanceOf( 'Sites', Sites
::singleton() );
42 $this->assertTrue( Sites
::singleton() === Sites
::singleton() );
45 public function testGetSites() {
46 $this->assertInstanceOf( 'SiteList', Sites
::singleton()->getSites() );
50 public function testGetSite() {
52 $sites = Sites
::singleton()->getSites();
57 foreach ( $sites as $site ) {
58 $this->assertInstanceOf( 'Site', $site );
62 Sites
::singleton()->getSite( $site->getGlobalId() )
65 if ( ++
$count > 100 ) {
71 public function testNewSite() {
72 $this->assertInstanceOf( 'Site', Sites
::newSite() );
73 $this->assertInstanceOf( 'Site', Sites
::newSite( 'enwiki' ) );
76 public function testGetGroup() {
77 $wikipedias = Sites
::singleton()->getSiteGroup( "wikipedia" );
79 $this->assertFalse( $wikipedias->isEmpty() );
82 foreach ( $wikipedias as $site ) {
83 $this->assertEquals( 'wikipedia', $site->getGroup() );