Skip to content

Commit 8ebffb4

Browse files
committed
Improve client error message + add missing factory in facade + more tests
1 parent 71a8bdc commit 8ebffb4

15 files changed

+308
-41
lines changed

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: analyze fix-code test coverage validation integration-test
1+
.PHONY: analyze fix-code test test-with-integration coverage coverage-with-integration validation integration-test integration-coverage
22

33
analyze: | vendor
44
$(COMPOSER) exec -v parallel-lint -- src
@@ -18,14 +18,25 @@ fix-code: | vendor
1818
test: | vendor
1919
$(COMPOSER) exec -v phpunit
2020

21+
test-with-integration: | vendor
22+
$(COMPOSER) exec -v phpunit -- --group default,integration
23+
2124
coverage: | vendor
2225
@if [ -z "`php -v | grep -i 'xdebug'`" ]; then echo "You need to install Xdebug in order to do this action"; exit 1; fi
2326
$(COMPOSER) exec -v phpunit -- --coverage-text --color
2427

28+
coverage-with-integration: | vendor
29+
@if [ -z "`php -v | grep -i 'xdebug'`" ]; then echo "You need to install Xdebug in order to do this action"; exit 1; fi
30+
$(COMPOSER) exec -v phpunit -- --group default,integration --coverage-text --color
31+
2532
integration-test: | vendor
2633
$(COMPOSER) exec -v phpunit -- --group integration
2734

28-
validation: fix-code analyze test coverage integration-test
35+
integration-coverage: | vendor
36+
@if [ -z "`php -v | grep -i 'xdebug'`" ]; then echo "You need to install Xdebug in order to do this action"; exit 1; fi
37+
$(COMPOSER) exec -v phpunit -- --group integration --coverage-text --color
38+
39+
validation: fix-code analyze test-with-integration coverage-with-integration
2940

3041
vendor: composer.json
3142
$(COMPOSER) install --optimize-autoloader --no-suggest --prefer-dist

src/Redis/Client/AbstractClient.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use function count;
2525
use MacFJA\RediSearch\Redis\Client;
2626
use MacFJA\RediSearch\Redis\Command;
27+
use function strlen;
2728

2829
abstract class AbstractClient implements Client
2930
{
@@ -71,7 +72,7 @@ protected function getMissingMessage(string $name, bool $isExtension, array $cla
7172
if (true === $isExtension) {
7273
$message = 'The extension '.$name.' is missing.'.PHP_EOL.'Install the extension';
7374
}
74-
$message .= ' or use a polyfill that provide ';
75+
$message .= ' or use a polyfill';
7576

7677
$classesMessage = null;
7778
if (1 === count($classes)) {
@@ -92,8 +93,11 @@ protected function getMissingMessage(string $name, bool $isExtension, array $cla
9293
$functionsMessage = 'the functions "'.implode('", "', $functions).'"';
9394
}
9495

95-
$message .= implode(' and ', array_filter([$classesMessage, $methodsMessage, $functionsMessage]));
96-
$message .= '.';
96+
$additional = implode(' and ', array_filter([$classesMessage, $methodsMessage, $functionsMessage]));
97+
if (strlen($additional) > 0) {
98+
$additional = ' that provide '.$additional;
99+
}
100+
$message .= $additional.'.';
97101

98102
return $message;
99103
}

src/Redis/Client/AmpRedisClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
use MacFJA\RediSearch\Redis\Command;
3030
use RuntimeException;
3131

32-
/**
33-
* @codeCoverageIgnore
34-
*/
3532
class AmpRedisClient extends AbstractClient
3633
{
3734
/** @var Redis */

src/Redis/Client/CheprasovRedisClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
use RedisClient\Pipeline\PipelineInterface;
2929
use RuntimeException;
3030

31-
/**
32-
* @codeCoverageIgnore
33-
*/
3431
class CheprasovRedisClient extends AbstractClient
3532
{
3633
/** @var AbstractRedisClient */

src/Redis/Client/ClientFacade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
use Rediska as RediskaRedis;
3232
use RuntimeException;
3333

34-
/**
35-
* @codeCoverageIgnore
36-
*/
3734
class ClientFacade
3835
{
3936
/** @var array<string> */
@@ -46,6 +43,7 @@ class ClientFacade
4643
RedisentClient::class,
4744
RediskaClient::class,
4845
AmpRedisClient::class,
46+
TinyRedisClient::class,
4947
];
5048

5149
/**

src/Redis/Client/CredisClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
use MacFJA\RediSearch\Redis\Command;
2828
use RuntimeException;
2929

30-
/**
31-
* @codeCoverageIgnore
32-
*/
3330
class CredisClient extends AbstractClient
3431
{
3532
/** @var Credis_Client */

src/Redis/Client/PredisClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
use Predis\Command\RawCommand;
3030
use RuntimeException;
3131

32-
/**
33-
* @codeCoverageIgnore
34-
*/
3532
class PredisClient extends AbstractClient
3633
{
3734
/** @var ClientInterface */

src/Redis/Client/RedisentClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
use redisent\Redis;
2727
use RuntimeException;
2828

29-
/**
30-
* @codeCoverageIgnore
31-
*/
3229
class RedisentClient extends AbstractClient
3330
{
3431
/** @var Redis */

src/Redis/Client/RediskaClient.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
use Rediska_Connection_Exec;
3232
use RuntimeException;
3333

34-
/**
35-
* @codeCoverageIgnore
36-
*/
3734
class RediskaClient extends AbstractClient
3835
{
3936
/** @var Rediska */

src/Redis/Client/TinyRedisClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
use MacFJA\RediSearch\Redis\Command;
2626
use RuntimeException;
2727

28-
/**
29-
* @codeCoverageIgnore
30-
*/
3128
class TinyRedisClient extends AbstractClient
3229
{
3330
/** @var \TinyRedisClient */
@@ -80,6 +77,9 @@ public static function make($redis): Client
8077
return new self($redis);
8178
}
8279

80+
/**
81+
* @codeCoverageIgnore
82+
*/
8383
protected function doPipeline(Command ...$commands): array
8484
{
8585
return [];

0 commit comments

Comments
 (0)