-
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. (#4…
…7902) * [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]> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * formatting --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
8bfd22b
commit aeb8205
Showing
3 changed files
with
75 additions
and
1 deletion.
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
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,44 @@ | ||
<?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() | ||
{ | ||
if (! class_exists(SearchArguments::class)) { | ||
return $this->markTestSkipped('Skipped tests on predis/predis dependency without '.SearchArguments::class); | ||
} | ||
|
||
$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) { | ||
return $event->connection instanceof PredisConnection | ||
&& $event->command === $command | ||
&& $event->parameters === ['test', '*', ['DIALECT', '3', 'WITHSCORES']]; | ||
}); | ||
} | ||
} |