File tree Expand file tree Collapse file tree 3 files changed +12
-26
lines changed
Expand file tree Collapse file tree 3 files changed +12
-26
lines changed Original file line number Diff line number Diff line change 33namespace malkusch \lock \mutex ;
44
55use Redis ;
6+ use RedisException ;
67
78/**
89 * Tests for PHPRedisMutex.
1617 * @license WTFPL
1718 * @see PHPRedisMutex
1819 * @requires redis
20+ * @group redis
1921 */
2022class PHPRedisMutexTest extends \PHPUnit_Framework_TestCase
2123{
22-
2324 /**
2425 * @var Redis The Redis API.
2526 */
@@ -34,28 +35,19 @@ protected function setUp()
3435 {
3536 parent ::setUp ();
3637
37- if (!getenv ("REDIS_URIS " )) {
38- $ this ->markTestSkipped ();
39- return ;
40- }
4138 $ this ->redis = new Redis ();
4239
43- $ uris = explode (", " , getenv ("REDIS_URIS " ));
40+ $ uris = explode (", " , getenv ("REDIS_URIS " ) ?: " redis://localhost " );
4441 $ uri = parse_url ($ uris [0 ]);
4542 if (!empty ($ uri ["port " ])) {
4643 $ this ->redis ->connect ($ uri ["host " ], $ uri ["port " ]);
4744 } else {
4845 $ this ->redis ->connect ($ uri ["host " ]);
4946 }
5047
51- $ this ->mutex = new PHPRedisMutex ([$ this ->redis ], "test " );
52- }
48+ $ this ->redis ->flushAll (); // Clear any existing locks.
5349
54- protected function tearDown ()
55- {
56- $ this ->redis ->flushAll ();
57-
58- parent ::tearDown ();
50+ $ this ->mutex = new PHPRedisMutex ([$ this ->redis ], "test " );
5951 }
6052
6153 /**
Original file line number Diff line number Diff line change 1616 * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations
1717 * @license WTFPL
1818 * @see PredisMutex
19+ * @group redis
1920 */
2021class PredisMutexTest extends \PHPUnit_Framework_TestCase
2122{
@@ -28,18 +29,8 @@ protected function setUp()
2829 {
2930 parent ::setUp ();
3031
31- if (!getenv ("REDIS_URIS " )) {
32- $ this ->markTestSkipped ();
33- }
34-
35- $ this ->client = new Client ("redis://example.net " );
36- }
37-
38- protected function tearDown ()
39- {
40- $ this ->client ->flushall ();
41-
42- parent ::tearDown ();
32+ $ this ->client = new Client (getenv ("REDIS_URIS " ) ?: "redis://localhost " );
33+ $ this ->client ->flushall (); // Clear any existing locks
4334 }
4435
4536 /**
@@ -51,7 +42,9 @@ protected function tearDown()
5142 */
5243 public function testAddFails ()
5344 {
54- $ mutex = new PredisMutex ([$ this ->client ], "test " );
45+ $ client = new Client ("redis://127.0.0.1:12345 " );
46+
47+ $ mutex = new PredisMutex ([$ client ], "test " );
5548
5649 $ mutex ->synchronized (function () {
5750 $ this ->fail ("Code execution is not expected " );
Original file line number Diff line number Diff line change 1717 * @license WTFPL
1818 *
1919 * @see RedisMutex
20+ * @group redis
2021 */
2122class RedisMutexTest extends \PHPUnit_Framework_TestCase
2223{
You can’t perform that action at this time.
0 commit comments