File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -47,10 +47,17 @@ protected function setUp()
4747 } else {
4848 $ this ->redis ->connect ($ uri ["host " ]);
4949 }
50-
50+
5151 $ this ->mutex = new PHPRedisMutex ([$ this ->redis ], "test " );
5252 }
5353
54+ protected function tearDown ()
55+ {
56+ $ this ->redis ->flushAll ();
57+
58+ parent ::tearDown ();
59+ }
60+
5461 /**
5562 * Tests add() fails.
5663 *
Original file line number Diff line number Diff line change 33namespace malkusch \lock \mutex ;
44
55use Predis \Client ;
6+ use Predis \ClientInterface ;
67
78/**
89 * Tests for PredisMutex.
1819 */
1920class PredisMutexTest extends \PHPUnit_Framework_TestCase
2021{
21-
22+ /**
23+ * @var ClientInterface
24+ */
25+ protected $ client ;
26+
2227 protected function setUp ()
2328 {
2429 parent ::setUp ();
2530
2631 if (!getenv ("REDIS_URIS " )) {
2732 $ this ->markTestSkipped ();
2833 }
34+
35+ $ this ->client = new Client ("redis://example.net " );
36+ }
37+
38+ protected function tearDown ()
39+ {
40+ $ this ->client ->flushall ();
41+
42+ parent ::tearDown ();
2943 }
3044
3145 /**
@@ -37,8 +51,7 @@ protected function setUp()
3751 */
3852 public function testAddFails ()
3953 {
40- $ client = new Client ("redis://example.net " );
41- $ mutex = new PredisMutex ([$ client ], "test " );
54+ $ mutex = new PredisMutex ([$ this ->client ], "test " );
4255
4356 $ mutex ->synchronized (function () {
4457 $ this ->fail ("Code execution is not expected " );
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ protected function setUp()
4242 * @param int $count The amount of redis apis.
4343 * @param int $timeout The timeout.
4444 *
45- * @return \PHPUnit_Framework_MockObject_MockObject The mock.
45+ * @return \PHPUnit_Framework_MockObject_MockObject|RedisMutex
4646 */
4747 private function buildRedisMutex ($ count , $ timeout = 1 )
4848 {
You can’t perform that action at this time.
0 commit comments