CredisStandaloneClusterTest.php 1.0 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once dirname(__FILE__).'/CredisClusterTest.php';
  3. class CredisStandaloneClusterTest extends CredisClusterTest
  4. {
  5. protected $useStandalone = TRUE;
  6. protected function tearDown()
  7. {
  8. if($this->cluster) {
  9. foreach($this->cluster->clients() as $client){
  10. if($client->isConnected()) {
  11. $client->close();
  12. }
  13. }
  14. $this->cluster = NULL;
  15. }
  16. }
  17. public function testMasterSlave()
  18. {
  19. $this->tearDown();
  20. $this->cluster = new Credis_Cluster(array($this->redisConfig[0],$this->redisConfig[6]), 2, $this->useStandalone);
  21. $this->assertTrue($this->cluster->client('master')->set('key','value'));
  22. $this->waitForSlaveReplication();
  23. $this->assertEquals('value',$this->cluster->client('slave')->get('key'));
  24. $this->assertEquals('value',$this->cluster->get('key'));
  25. $this->setExpectedExceptionShim('CredisException','READONLY You can\'t write against a read only slave.');
  26. $this->cluster->client('slave')->set('key2','value');
  27. }
  28. }