Skip to content

Commit

Permalink
Merge 510f732 into 767c429
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuakiM committed Sep 24, 2017
2 parents 767c429 + 510f732 commit b8567c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -13,7 +13,8 @@ services:

before_script:
- echo 'extension=redis.so' >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- composer install --no-progress --no-ansi --no-interaction --profile
- composer global require hirak/prestissimo --no-interaction --quiet
- composer install --no-interaction --quiet

script:
- composer test
Expand Down
6 changes: 3 additions & 3 deletions src/Clients.php
Expand Up @@ -18,12 +18,12 @@ class Clients extends \Redis //{{{
{
protected $config;
private $_defaultConfig = [
'host' => null, //can be a host, or the path to a unix domain socket
'host' => null,
'port' => 6379,
'timeout' => 0.0, //value in seconds (optional, default is 0 meaning unlimited)
'timeout' => 0.0,
'password' => null,
'serializer' => \Redis::SERIALIZER_NONE,
'persistent' => false, //default is connect
'persistent' => false,
];

/**
Expand Down
37 changes: 8 additions & 29 deletions tests/ClientsTest.php
Expand Up @@ -18,20 +18,12 @@ class ClientsTest extends \PHPUnit\Framework\TestCase //{{{
{
// Class variable {{{
private $_defaultConfig = [
// 'connect' paramater
'host' => '127.0.0.1', //can be a host, or the path to a unix domain socket
'host' => '127.0.0.1',
'port' => 6379,
'timeout' => 1.0, //value in seconds (optional, default is 0 meaning unlimited)
'read_timeout' => 1.0, //value in seconds (optional, default is 0 meaning unlimited)

// 'auth' paramater
'timeout' => 1.0,
'password' => null,

// serializer
'serializer' => \Redis::SERIALIZER_NONE,

// 'connect' or 'pconnect'
'persistent' => false, //default is connect
'persistent' => false,
];

private $_clients;
Expand Down Expand Up @@ -65,6 +57,7 @@ public function testConnectionPersistentError() //{{{
$config = $this->_defaultConfig;
$config['host'] = '127.0.0.2';
$clients = new Clients($config);
unset($clients);
} //}}}

/**
Expand All @@ -80,6 +73,7 @@ public function testConnectionError() //{{{
$config['host'] = '127.0.0.2';
$config['persistent'] = true;
$clients = new Clients($config);
unset($clients);
} //}}}

/**
Expand All @@ -94,6 +88,7 @@ public function testAuthError() //{{{
$config = $this->_defaultConfig;
$config['password'] = 'dummy';
$clients = new Clients($config);
unset($clients);
} //}}}

/**
Expand All @@ -117,30 +112,14 @@ public function testPingError() //{{{
*/
public function testConnection() //{{{
{
$this->assertTrue($this->_clients->isConnected());

$config = $this->_defaultConfig;
$config['persistent'] = true;
$clients = new Clients($config);
$this->assertTrue($clients->isConnected());
$this->assertTrue($clients-> /* @scrutinizer ignore-call */ isConnected());
$clients->ping();
$clients->close();

unset($clients);
} //}}}

/**
* testIsConnected.
*/
public function testIsConnected() //{{{
{
$config = $this->_defaultConfig;
$config['persistent'] = true;
$clients = new Clients($config);
$this->assertTrue($clients->isConnected());
$clients->close();

$this->assertFalse($clients->isConnected());
$this->assertFalse($clients-> /* @scrutinizer ignore-call */ isConnected());
$clients->close();
} //}}}

Expand Down

0 comments on commit b8567c8

Please sign in to comment.