1
|
<?php
|
2
|
|
3
|
/*
|
4
|
* This file is part of the Predis package.
|
5
|
*
|
6
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
7
|
*
|
8
|
* For the full copyright and license information, please view the LICENSE
|
9
|
* file that was distributed with this source code.
|
10
|
*/
|
11
|
|
12
|
namespace Predis\Profile;
|
13
|
|
14
|
use PredisTestCase;
|
15
|
|
16
|
/**
|
17
|
*
|
18
|
*/
|
19
|
abstract class PredisProfileTestCase extends PredisTestCase
|
20
|
{
|
21
|
/**
|
22
|
* Returns a new instance of the tested profile.
|
23
|
*
|
24
|
* @param string $version Version of Redis.
|
25
|
* @return ServerProfileInterface
|
26
|
*/
|
27
|
protected function getProfile($version = null)
|
28
|
{
|
29
|
$this->markTestIncomplete("Server profile must be defined in ".get_class($this));
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Returns the expected version string for the tested profile.
|
34
|
*
|
35
|
* @return string Version string.
|
36
|
*/
|
37
|
abstract protected function getExpectedVersion();
|
38
|
|
39
|
/**
|
40
|
* Returns the expected list of commands supported by the tested profile.
|
41
|
*
|
42
|
* @return array List of supported commands.
|
43
|
*/
|
44
|
abstract protected function getExpectedCommands();
|
45
|
|
46
|
/**
|
47
|
* Returns the list of commands supported by the current
|
48
|
* server profile.
|
49
|
*
|
50
|
* @param ServerProfileInterface $profile Server profile instance.
|
51
|
* @return array
|
52
|
*/
|
53
|
protected function getCommands(ServerProfileInterface $profile)
|
54
|
{
|
55
|
$commands = $profile->getSupportedCommands();
|
56
|
|
57
|
return array_keys($commands);
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* @group disconnected
|
62
|
*/
|
63
|
public function testGetVersion()
|
64
|
{
|
65
|
$profile = $this->getProfile();
|
66
|
|
67
|
$this->assertEquals($this->getExpectedVersion(), $profile->getVersion());
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
* @group disconnected
|
72
|
*/
|
73
|
public function testSupportedCommands()
|
74
|
{
|
75
|
$profile = $this->getProfile();
|
76
|
$expected = $this->getExpectedCommands();
|
77
|
$commands = $this->getCommands($profile);
|
78
|
|
79
|
$this->assertSame($expected, $commands);
|
80
|
}
|
81
|
}
|