CredisStandaloneClusterTest.php 1 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<?php

require_once dirname(__FILE__).'/CredisClusterTest.php';

class CredisStandaloneClusterTest extends CredisClusterTest
{
  protected $useStandalone = TRUE;
  protected function tearDown()
  {
    if($this->cluster) {
        foreach($this->cluster->clients() as $client){
            if($client->isConnected()) {
                $client->close();
            }
        }
        $this->cluster = NULL;
    }
  }
  public function testMasterSlave()
  {
    $this->tearDown();
    $this->cluster = new Credis_Cluster(array($this->redisConfig[0],$this->redisConfig[6]), 2, $this->useStandalone);
    $this->assertTrue($this->cluster->client('master')->set('key','value'));
    $this->waitForSlaveReplication();
    $this->assertEquals('value',$this->cluster->client('slave')->get('key'));
    $this->assertEquals('value',$this->cluster->get('key'));
    $this->setExpectedExceptionShim('CredisException','READONLY You can\'t write against a read only slave.');
    $this->cluster->client('slave')->set('key2','value');
  }
}