-
Notifications
You must be signed in to change notification settings - Fork 6
/
Riak.php
74 lines (61 loc) · 2.03 KB
/
Riak.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace TestTools\Basho;
use Basho\Riak as BashoRiak;
use Basho\Riak\Command;
use Basho\Riak\Command\Object\Fetch;
use TestTools\Fixture\SelfInitializingFixtureTrait;
class Riak extends BashoRiak
{
use SelfInitializingFixtureTrait;
protected function getFixtureFingerprintArguments(array $arguments)
{
$fingerprintArguments = array();
foreach ($arguments as $arg) {
if (is_object($arg) && method_exists($arg, '__toString')) {
$fingerprintArg = (string)$arg;
} elseif ($arg instanceof Command) {
$fingerprintArg = $arg->getMethod();
if ($arg->getLocation()) {
$fingerprintArg .= $arg->getLocation()->__toString();
} else {
$fingerprintArg .= $arg->getBucket()->__toString();
}
if ($arg->getParameters()) {
$fingerprintArg .= print_r($arg->getParameters(), true);
}
if ($arg instanceof Fetch && is_object($arg->getObject())) {
$fingerprintArg .= print_r($arg->getEncodedData(), true);
}
} else {
$fingerprintArg = $arg;
}
$fingerprintArguments[] = $fingerprintArg;
}
return $fingerprintArguments;
}
/**
* Execute a Riak command
*
* @param Command $command
*
* @return Command\Response
*/
public function execute(Command $command)
{
return $this->callWithFixtures('execute', func_get_args());
}
/**
* Outputs the caller method name so that accidental connections can be noticed
*
* Using echo() is safe, since fixtures should be enabled on the command line while running PHPUnit only!
*
* @return BashoRiak\Node
*/
public function getActiveNode()
{
if ($this->usesFixtures()) {
echo ' [RIAK CONNECT BY "' . $this->getFixtureCaller(8) . '"] ';
}
return parent::getActiveNode();
}
}