4 * Tests for the SiteSQLStore 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 SiteSQLStoreTest
extends MediaWikiTestCase
{
35 public function testGetSites() {
36 $expectedSites = TestSites
::getSites();
37 TestSites
::insertIntoDb();
39 $sitesTable = SiteSQLStore
::newInstance();
41 $sites = $sitesTable->getSites();
43 $this->assertInstanceOf( 'SiteList', $sites );
48 foreach ( $sites as $site ) {
49 $this->assertInstanceOf( 'Site', $site );
52 foreach ( $expectedSites as $site ) {
53 if ( $site->getGlobalId() !== null ) {
54 $this->assertTrue( $sites->hasSite( $site->getGlobalId() ) );
59 public function testSaveSites() {
60 $sitesTable = SiteSQLStore
::newInstance();
65 $site->setGlobalId( 'ertrywuutr' );
66 $site->setLanguageCode( 'en' );
69 $site = new MediaWikiSite();
70 $site->setGlobalId( 'sdfhxujgkfpth' );
71 $site->setLanguageCode( 'nl' );
74 $this->assertTrue( $sitesTable->saveSites( $sites ) );
76 $site = $sitesTable->getSite( 'ertrywuutr', 'nocache' );
77 $this->assertInstanceOf( 'Site', $site );
78 $this->assertEquals( 'en', $site->getLanguageCode() );
80 $site = $sitesTable->getSite( 'sdfhxujgkfpth', 'nocache' );
81 $this->assertInstanceOf( 'Site', $site );
82 $this->assertEquals( 'nl', $site->getLanguageCode() );