Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit fd1a459

Browse files
committed
Added integrations for Redis
1 parent 6c8c748 commit fd1a459

File tree

3 files changed

+165
-180
lines changed

3 files changed

+165
-180
lines changed

tests/Mocks/LazyClient.php

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public function __call($name, $args)
5757
$this->calls[] = [$name, $args];
5858

5959
if (! in_array($name, ['subscribe', 'psubscribe', 'unsubscribe', 'punsubscribe', 'onMessage'])) {
60-
$this->redis->__call($name, $args);
60+
if ($name === 'eval') {
61+
$this->redis->{$name}(...$args);
62+
} else {
63+
$this->redis->__call($name, $args);
64+
}
6165
}
6266

6367
return new PromiseResolver(
@@ -98,14 +102,34 @@ public function assertCalled($name)
98102
return $this;
99103
}
100104

105+
/**
106+
* Check if the method got called.
107+
*
108+
* @param int $times
109+
* @param string $name
110+
* @return $this
111+
*/
112+
public function assertCalledCount(int $times, string $name)
113+
{
114+
$total = collect($this->getCalledFunctions())->filter(function ($function) use ($name) {
115+
[$calledName, ] = $function;
116+
117+
return $calledName === $name;
118+
});
119+
120+
PHPUnit::assertCount($times, $total);
121+
122+
return $this;
123+
}
124+
101125
/**
102126
* Check if the method with args got called.
103127
*
104128
* @param string $name
105129
* @param array $args
106130
* @return $this
107131
*/
108-
public function assertCalledWithArgs($name, array $args)
132+
public function assertCalledWithArgs(string $name, array $args)
109133
{
110134
foreach ($this->getCalledFunctions() as $function) {
111135
[$calledName, $calledArgs] = $function;
@@ -125,11 +149,12 @@ public function assertCalledWithArgs($name, array $args)
125149
/**
126150
* Check if the method with args got called an amount of times.
127151
*
152+
* @param int $times
128153
* @param string $name
129154
* @param array $args
130155
* @return $this
131156
*/
132-
public function assertCalledWithArgsCount($times = 1, $name, array $args)
157+
public function assertCalledWithArgsCount(int $times, string $name, array $args)
133158
{
134159
$total = collect($this->getCalledFunctions())->filter(function ($function) use ($name, $args) {
135160
[$calledName, $calledArgs] = $function;
@@ -148,7 +173,7 @@ public function assertCalledWithArgsCount($times = 1, $name, array $args)
148173
* @param string $name
149174
* @return $this
150175
*/
151-
public function assertNotCalled($name)
176+
public function assertNotCalled(string $name)
152177
{
153178
foreach ($this->getCalledFunctions() as $function) {
154179
[$calledName, ] = $function;
@@ -172,7 +197,7 @@ public function assertNotCalled($name)
172197
* @param array $args
173198
* @return $this
174199
*/
175-
public function assertNotCalledWithArgs($name, array $args)
200+
public function assertNotCalledWithArgs(string $name, array $args)
176201
{
177202
foreach ($this->getCalledFunctions() as $function) {
178203
[$calledName, $calledArgs] = $function;
@@ -192,11 +217,12 @@ public function assertNotCalledWithArgs($name, array $args)
192217
/**
193218
* Check if the method with args got called an amount of times.
194219
*
220+
* @param int $times
195221
* @param string $name
196222
* @param array $args
197223
* @return $this
198224
*/
199-
public function assertNotCalledWithArgsCount($times = 1, $name, array $args)
225+
public function assertNotCalledWithArgsCount(int $times, string $name, array $args)
200226
{
201227
$total = collect($this->getCalledFunctions())->filter(function ($function) use ($name, $args) {
202228
[$calledName, $calledArgs] = $function;

0 commit comments

Comments
 (0)