Skip to content

Commit cbea3b6

Browse files
committed
ICM: Laravel 5.2 support.
1 parent 9f819a2 commit cbea3b6

File tree

2 files changed

+3
-53
lines changed

2 files changed

+3
-53
lines changed

src/Mutex.php

+3-19
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
use NinjaMutex\Lock\FlockLock;
99
use NinjaMutex\Lock\MemcachedLock;
1010
use NinjaMutex\Lock\MySqlLock;
11-
use NinjaMutex\Lock\PhpRedisLock;
1211
use NinjaMutex\Lock\PredisRedisLock;
1312
use NinjaMutex\Mutex as Ninja;
14-
use Predis\Client as PredisClient;
1513

1614
class Mutex
1715
{
@@ -42,7 +40,7 @@ public function getStrategy()
4240
);
4341

4442
case 'redis':
45-
return $this->getRedisLock(config('database.redis.client', 'predis'));
43+
return $this->getRedisLock();
4644

4745
case 'memcached':
4846
return new MemcachedLock(Cache::getStore()->getMemcached());
@@ -53,28 +51,14 @@ public function getStrategy()
5351
}
5452
}
5553

56-
private function getRedisLock($client)
54+
private function getRedisLock()
5755
{
58-
if ($client === 'phpredis') {
59-
return new PhpRedisLock($this->getPhpRedisClient());
60-
}
61-
6256
return new PredisRedisLock($this->getPredisClient());
6357
}
6458

65-
public function getPhpRedisClient()
66-
{
67-
return RedisFacade::connection()->client();
68-
}
69-
7059
public function getPredisClient()
7160
{
72-
$connection = RedisFacade::connection();
73-
74-
/* @laravel-versions */
75-
$predisClient = ($connection instanceof PredisClient) ? $connection : $connection->client();
76-
77-
return $predisClient;
61+
return RedisFacade::connection();
7862
}
7963

8064
public function __call($method, $parameters)

tests/ConsoleMutex/MutexTest.php

-34
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
namespace Illuminated\Console\ConsoleMutex\Tests;
44

55
use GenericCommand;
6-
use Illuminate\Redis\Connectors\PhpRedisConnector;
76
use Illuminate\Support\Facades\Cache;
87
use Illuminated\Console\Mutex;
98
use Mockery;
109
use NinjaMutex\Lock\FlockLock;
1110
use NinjaMutex\Lock\MemcachedLock;
1211
use NinjaMutex\Lock\MySqlLock;
13-
use NinjaMutex\Lock\PhpRedisLock;
1412
use NinjaMutex\Lock\PredisRedisLock;
1513
use Predis\Client as PredisClient;
16-
use Redis;
1714

1815
class MutexTest extends TestCase
1916
{
@@ -76,44 +73,13 @@ public function it_supports_redis_strategy_with_predis_client_which_is_default()
7673
$this->assertEquals($expectedStrategy, $mutex->getStrategy());
7774
}
7875

79-
/** @test */
80-
public function it_supports_redis_strategy_with_phpredis_client()
81-
{
82-
/* @laravel-versions */
83-
if (!class_exists(PhpRedisConnector::class)) {
84-
return;
85-
}
86-
87-
config(['database.redis.client' => 'phpredis']);
88-
89-
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('redis');
90-
91-
$mutex = new Mutex($this->command);
92-
$expectedStrategy = new PhpRedisLock($mutex->getPhpRedisClient());
93-
$this->assertEquals($expectedStrategy, $mutex->getStrategy());
94-
}
95-
9676
/** @test */
9777
public function it_has_get_predis_client_method_which_always_returns_an_instance_of_predis_client_class()
9878
{
9979
$mutex = new Mutex($this->command);
10080
$this->assertInstanceOf(PredisClient::class, $mutex->getPredisClient());
10181
}
10282

103-
/** @test */
104-
public function it_has_get_phpredis_client_method_which_always_returns_an_instance_of_redis_class()
105-
{
106-
/* @laravel-versions */
107-
if (!class_exists(PhpRedisConnector::class)) {
108-
return;
109-
}
110-
111-
config(['database.redis.client' => 'phpredis']);
112-
113-
$mutex = new Mutex($this->command);
114-
$this->assertInstanceOf(Redis::class, $mutex->getPhpRedisClient());
115-
}
116-
11783
/** @test */
11884
public function it_supports_memcached_strategy()
11985
{

0 commit comments

Comments
 (0)