Merge "(bug 44338) set the site internal id when loading sites from the db"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 25 Jan 2013 13:18:13 +0000 (13:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 25 Jan 2013 13:18:13 +0000 (13:18 +0000)
1  2 
includes/site/SiteSQLStore.php
tests/phpunit/includes/site/SiteSQLStoreTest.php

Simple merge
@@@ -71,49 -71,19 +71,53 @@@ class SiteSQLStoreTest extends MediaWik
                $site->setLanguageCode( 'nl' );
                $sites[] = $site;
  
 -              $this->assertTrue( $sitesTable->saveSites( $sites ) );
 +              $this->assertTrue( $store->saveSites( $sites ) );
  
 -              $site = $sitesTable->getSite( 'ertrywuutr', 'nocache' );
 +              $site = $store->getSite( 'ertrywuutr' );
                $this->assertInstanceOf( 'Site', $site );
                $this->assertEquals( 'en', $site->getLanguageCode() );
+               $this->assertTrue( is_integer( $site->getInternalId() ) );
+               $this->assertTrue( $site->getInternalId() >= 0 );
  
 -              $site = $sitesTable->getSite( 'sdfhxujgkfpth', 'nocache' );
 +              $site = $store->getSite( 'sdfhxujgkfpth' );
                $this->assertInstanceOf( 'Site', $site );
                $this->assertEquals( 'nl', $site->getLanguageCode() );
+               $this->assertTrue( is_integer( $site->getInternalId() ) );
+               $this->assertTrue( $site->getInternalId() >= 0 );
        }
  
 +      public function testReset() {
 +              $store1 = SiteSQLStore::newInstance();
 +              $store2 = SiteSQLStore::newInstance();
 +
 +              // initialize internal cache
 +              $this->assertGreaterThan( 0, $store1->getSites()->count() );
 +              $this->assertGreaterThan( 0, $store2->getSites()->count() );
 +
 +              // Clear actual data. Will purge the external cache and reset the internal
 +              // cache in $store1, but not the internal cache in store2.
 +              $this->assertTrue( $store1->clear() );
 +
 +              // sanity check: $store2 should have a stale cache now
 +              $this->assertNotNull( $store2->getSite( 'enwiki' ) );
 +
 +              // purge cache
 +              $store2->reset();
 +
 +              // ...now the internal cache of $store2 should be updated and thus empty.
 +              $site = $store2->getSite( 'enwiki' );
 +              $this->assertNull( $site );
 +      }
 +
 +      public function testClear() {
 +              $store = SiteSQLStore::newInstance();
 +              $this->assertTrue( $store->clear() );
 +
 +              $site = $store->getSite( 'enwiki' );
 +              $this->assertNull( $site );
 +
 +              $sites = $store->getSites();
 +              $this->assertEquals( 0, $sites->count() );
 +      }
 +
  }