@@ -11,60 +11,66 @@ class RedisCacheIntegrationTest extends TestCase
1111{
1212 use InteractsWithRedis;
1313
14- protected function setUp (): void
15- {
16- parent ::setUp ();
17- $ this ->setUpRedis ();
18- }
19-
2014 protected function tearDown (): void
2115 {
22- parent ::tearDown ();
2316 $ this ->tearDownRedis ();
17+
18+ parent ::tearDown ();
2419 }
2520
2621 /**
27- * @dataProvider redisDriverProvider
22+ * @dataProvider extendedRedisConnectionDataProvider
2823 *
29- * @param string $driver
24+ * @param string $connection
3025 */
31- public function testRedisCacheAddTwice ($ driver )
26+ public function testRedisCacheAddTwice ($ connection )
3227 {
33- $ store = new RedisStore ( $ this ->redis [ $ driver ] );
34- $ repository = new Repository ( $ store );
28+ $ repository = $ this ->getRepository ( $ connection );
29+
3530 $ this ->assertTrue ($ repository ->add ('k ' , 'v ' , 3600 ));
3631 $ this ->assertFalse ($ repository ->add ('k ' , 'v ' , 3600 ));
37- $ this ->assertGreaterThan (3500 , $ this -> redis [ $ driver ] ->connection ()->ttl ('k ' ));
32+ $ this ->assertGreaterThan (3500 , $ repository -> getStore () ->connection ()->ttl ('k ' ));
3833 }
3934
4035 /**
4136 * Breaking change.
4237 *
43- * @dataProvider redisDriverProvider
38+ * @dataProvider extendedRedisConnectionDataProvider
4439 *
45- * @param string $driver
40+ * @param string $connection
4641 */
47- public function testRedisCacheAddFalse ($ driver )
42+ public function testRedisCacheAddFalse ($ connection )
4843 {
49- $ store = new RedisStore ( $ this ->redis [ $ driver ] );
50- $ repository = new Repository ( $ store );
44+ $ repository = $ this ->getRepository ( $ connection );
45+
5146 $ repository ->forever ('k ' , false );
5247 $ this ->assertFalse ($ repository ->add ('k ' , 'v ' , 60 ));
53- $ this ->assertEquals (-1 , $ this -> redis [ $ driver ] ->connection ()->ttl ('k ' ));
48+ $ this ->assertEquals (-1 , $ repository -> getStore () ->connection ()->ttl ('k ' ));
5449 }
5550
5651 /**
5752 * Breaking change.
5853 *
59- * @dataProvider redisDriverProvider
54+ * @dataProvider extendedRedisConnectionDataProvider
6055 *
61- * @param string $driver
56+ * @param string $connection
6257 */
63- public function testRedisCacheAddNull ($ driver )
58+ public function testRedisCacheAddNull ($ connection )
6459 {
65- $ store = new RedisStore ( $ this ->redis [ $ driver ] );
66- $ repository = new Repository ( $ store );
60+ $ repository = $ this ->getRepository ( $ connection );
61+
6762 $ repository ->forever ('k ' , null );
6863 $ this ->assertFalse ($ repository ->add ('k ' , 'v ' , 60 ));
6964 }
65+
66+ /**
67+ * Builds a cache repository out of a predefined redis connection name.
68+ *
69+ * @param string $connection
70+ * @return \Illuminate\Cache\Repository
71+ */
72+ private function getRepository ($ connection )
73+ {
74+ return new Repository (new RedisStore ($ this ->getRedisManager ($ connection )));
75+ }
7076}
0 commit comments