Skip to content

Commit 13d3777

Browse files
committed
Improve coverage + add UT for SpellCheck result parsing
1 parent 4383b46 commit 13d3777

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Redis/Command/AggregateCommand/GroupByOption.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function isValid(): bool
5858
}
5959

6060
/**
61+
* @codeCoverageIgnore Simple getter
62+
*
6163
* @return array<string,mixed>
6264
*/
6365
public function getOptionData()

src/Redis/Command/AggregateCommand/SortByOption.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function isValid(): bool
5252
}
5353

5454
/**
55+
* @codeCoverageIgnore Simple getter
56+
*
5557
* @return array<string,null|array<string,null|string>|int>
5658
*/
5759
public function getOptionData()

tests/Redis/Command/SpellCheckTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
namespace MacFJA\RediSearch\tests\Redis\Command;
2323

24+
use Closure;
2425
use MacFJA\RediSearch\Redis\Command\SpellCheck;
26+
use MacFJA\RediSearch\Redis\Response\SpellCheckResponseItem;
2527
use PHPUnit\Framework\TestCase;
2628

2729
/**
@@ -64,4 +66,24 @@ public function testFullOption(): void
6466
'TERMS', 'INCLUDE', 'cities',
6567
], $command->getArguments());
6668
}
69+
70+
public function testResponseTransformation(): void
71+
{
72+
$command = new SpellCheck();
73+
$expected = [
74+
new SpellCheckResponseItem('hell', ['hello' => 0.7, 'hola' => 0.4]),
75+
new SpellCheckResponseItem('worl', ['world' => 0.9, 'work' => 0.56]),
76+
];
77+
$rawResponse = [
78+
['TERM', 'hell', [[0.7, 'hello'], [0.4, 'hola']]],
79+
['TERM', 'worl', [[0.9, 'world'], [0.56, 'work']]],
80+
];
81+
$transformer = function ($data) {
82+
// @phpstan-ignore-next-line
83+
return $this->transformParsedResponse($data);
84+
};
85+
$actual = Closure::fromCallable($transformer)->call($command, $rawResponse);
86+
87+
static::assertEquals($expected, $actual);
88+
}
6789
}

0 commit comments

Comments
 (0)