6 * @covers \SqlBagOStuff
8 class SqlBagOStuffIntegrationTest
extends BagOStuffTestBase
{
9 protected function newCacheInstance() {
10 return $this->getServiceContainer()->getObjectCacheFactory()->getInstance( CACHE_DB
);
13 public function testFallback() {
14 if ( $this->getDb()->getType() !== 'mysql' ) {
15 $this->markTestSkipped( "Does not work with sqlite and postgres" );
17 global $wgDBserver, $wgDBport, $wgDBname, $wgDBuser, $wgDBpassword, $wgDBtype;
18 $cache = new SqlBagOStuff( [
20 'servers' => [ 'pc1' => [
21 'serverName' => 'db0',
22 'host' => $wgDBserver,
24 'dbname' => $wgDBname,
26 'password' => $wgDBpassword,
29 'serverName' => 'db1',
30 'host' => $wgDBserver . 'nocoonection',
32 'dbname' => $wgDBname . 'nocoonection',
33 'user' => $wgDBuser . 'nocoonection',
34 'password' => $wgDBpassword . 'nocoonection',
40 // around half of these must fallback. Test shows keyname3 does.
41 for ( $i = 0; $i < 10; $i++
) {
42 $cache->set( 'keyname' . (string)$i, 'value' . (string)$i );
43 $res = $cache->get( 'keyname' . (string)$i );
45 $this->assertSame( 'value' . (string)$i, $res );
50 for ( $i = 0; $i < 10; $i++
) {
51 $cache->set( 'keyname' . (string)$i, 'value' . (string)$i );
52 $keys[] = 'keyname' . (string)$i;
54 $res = $cache->getMulti( $keys );
55 for ( $i = 0; $i < 10; $i++
) {
56 $this->assertSame( 'value' . (string)$i, $res['keyname' . (string)$i] );