You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
<?php |
|
|
|
namespace yiiunit\extensions\redis; |
|
|
|
/** |
|
* @group redis |
|
*/ |
|
class RedisConnectionTest extends RedisTestCase |
|
{ |
|
/** |
|
* test connection to redis and selection of db |
|
*/ |
|
public function testConnect() |
|
{ |
|
$db = $this->getConnection(false); |
|
$db->open(); |
|
$this->assertTrue($db->ping()); |
|
$db->set('YIITESTKEY', 'YIITESTVALUE'); |
|
$db->close(); |
|
|
|
$db = $this->getConnection(false); |
|
$db->database = 0; |
|
$db->open(); |
|
$this->assertEquals('YIITESTVALUE', $db->get('YIITESTKEY')); |
|
$db->close(); |
|
|
|
$db = $this->getConnection(false); |
|
$db->database = 1; |
|
$db->open(); |
|
$this->assertNull($db->get('YIITESTKEY')); |
|
$db->close(); |
|
} |
|
|
|
public function keyValueData() |
|
{ |
|
return [ |
|
[123], |
|
[-123], |
|
[0], |
|
['test'], |
|
["test\r\ntest"], |
|
[''], |
|
]; |
|
} |
|
|
|
/** |
|
* @dataProvider keyValueData |
|
*/ |
|
public function testStoreGet($data) |
|
{ |
|
$db = $this->getConnection(true); |
|
|
|
$db->set('hi', $data); |
|
$this->assertEquals($data, $db->get('hi')); |
|
} |
|
}
|
|
|