-
Notifications
You must be signed in to change notification settings - Fork 327
/
ClientTest.php
55 lines (42 loc) · 1.75 KB
/
ClientTest.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Snc\RedisBundle\Tests\Client\Phpredis;
use Snc\RedisBundle\Client\Phpredis\Client;
use PHPUnit\Framework\TestCase;
/**
* ClientTest
*/
class ClientTest extends TestCase
{
/**
* @covers \Snc\RedisBundle\Client\Phpredis\Client::getCommandString
*/
public function testGetCommandString()
{
if (!extension_loaded('redis')) {
$this->markTestSkipped('This test needs the PHP Redis extension to work');
} elseif (version_compare(phpversion('redis'), '4.0.0') >= 0) {
$this->markTestSkipped('This test cannot be executed on Redis extension version ' . phpversion('redis'));
}
$method = new \ReflectionMethod(
'\Snc\RedisBundle\Client\Phpredis\Client', 'getCommandString'
);
$method->setAccessible(true);
$name = 'foo';
$arguments = array(array('chuck', 'norris'));
$this->assertEquals(
'FOO chuck norris', $method->invoke(new \Snc\RedisBundle\Client\Phpredis\Client(array('alias' => 'bar')), $name, $arguments)
);
$arguments = array('chuck:norris');
$this->assertEquals(
'FOO chuck:norris', $method->invoke(new \Snc\RedisBundle\Client\Phpredis\Client(array('alias' => 'bar')), $name, $arguments)
);
$arguments = array('chuck:norris fab:pot');
$this->assertEquals(
'FOO chuck:norris fab:pot', $method->invoke(new \Snc\RedisBundle\Client\Phpredis\Client(array('alias' => 'bar')), $name, $arguments)
);
$arguments = array('foo' => 'bar', 'baz' => null);
$this->assertEquals(
'FOO foo bar baz <null>', $method->invoke(new \Snc\RedisBundle\Client\Phpredis\Client(array('alias' => 'bar')), $name, $arguments)
);
}
}