-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Normalise predis command argument where it maybe an object.
Starting from predis 2.1.1 it is possible to apply an implementation of `Predis\Command\Argument\ArrayableArgument` fixes laravel/telescope#1366 Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Redis; | ||
|
||
use Illuminate\Redis\Connections\PredisConnection; | ||
use Illuminate\Redis\Events\CommandExecuted; | ||
use Illuminate\Support\Facades\Event; | ||
use Mockery as m; | ||
use Orchestra\Testbench\TestCase; | ||
use Predis\Client; | ||
use Predis\Command\Argument\Search\SearchArguments; | ||
|
||
class PredisConnectionTest extends TestCase | ||
{ | ||
protected function defineEnvironment($app) | ||
{ | ||
$app->get('config')->set('database.redis.client', 'predis'); | ||
} | ||
|
||
public function testPredisCanEmitEventWithArrayableArgumentObject() | ||
{ | ||
$event = Event::fake(); | ||
|
||
$command = 'ftSearch'; | ||
$parameters = ['test', "*", (new SearchArguments())->dialect('3')->withScores()]; | ||
|
||
$predis = new PredisConnection($client = m::mock(Client::class)); | ||
$predis->setEventDispatcher($event); | ||
|
||
$client->shouldReceive($command)->with(...$parameters)->andReturnTrue(); | ||
|
||
$this->assertTrue($predis->command($command, $parameters)); | ||
|
||
$event->assertDispatched(function (CommandExecuted $event) use ($command, $parameters) { | ||
return $event->connection instanceof PredisConnection | ||
&& $event->command === $command | ||
&& $event->parameters === ['test', '*', ['DIALECT', '3', 'WITHSCORES']]; | ||
}); | ||
} | ||
} |