File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,19 @@ public function resolve($name)
90
90
91
91
$ config = Arr::add ($ config , 'store ' , $ name );
92
92
93
+ return $ this ->build ($ config );
94
+ }
95
+
96
+ /**
97
+ * Build a cache repository with the given configuration.
98
+ *
99
+ * @param array $config
100
+ * @return \Illuminate\Cache\Repository
101
+ */
102
+ public function build (array $ config )
103
+ {
104
+ $ config = Arr::add ($ config , 'store ' , $ config ['name ' ] ?? 'ondemand ' );
105
+
93
106
if (isset ($ this ->customCreators [$ config ['driver ' ]])) {
94
107
return $ this ->callCustomCreator ($ config );
95
108
}
Original file line number Diff line number Diff line change 6
6
* @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
7
7
* @method static \Illuminate\Contracts\Cache\Repository driver(string|null $driver = null)
8
8
* @method static \Illuminate\Contracts\Cache\Repository resolve(string $name)
9
+ * @method static \Illuminate\Contracts\Cache\Repository build(array $config)
9
10
* @method static \Illuminate\Cache\Repository repository(\Illuminate\Contracts\Cache\Store $store, array $config = [])
10
11
* @method static void refreshEventDispatcher()
11
12
* @method static string getDefaultDriver()
Original file line number Diff line number Diff line change @@ -59,6 +59,18 @@ public function testCustomDriverOverridesInternalDrivers()
59
59
$ this ->assertSame ('mm(u_u)mm ' , $ driver ->flag );
60
60
}
61
61
62
+ public function testItCanBuildRepositories ()
63
+ {
64
+ $ app = $ this ->getApp ([]);
65
+ $ cacheManager = new CacheManager ($ app );
66
+
67
+ $ arrayCache = $ cacheManager ->build (['driver ' => 'array ' ]);
68
+ $ nullCache = $ cacheManager ->build (['driver ' => 'null ' ]);
69
+
70
+ $ this ->assertInstanceOf (ArrayStore::class, $ arrayCache ->getStore ());
71
+ $ this ->assertInstanceOf (NullStore::class, $ nullCache ->getStore ());
72
+ }
73
+
62
74
public function testItMakesRepositoryWhenContainerHasNoDispatcher ()
63
75
{
64
76
$ userConfig = [
You can’t perform that action at this time.
0 commit comments