/**
  * Create a new cache repository with the given implementation.
  *
  * @param  \Illuminate\Contracts\Cache\Store $store
  * @return \Propaganistas\LaravelCacheKeywords\KeywordsRepository
  */
 public function repository(Store $store)
 {
     $repository = new KeywordsRepository($store);
     if ($this->app->bound('Illuminate\\Contracts\\Events\\Dispatcher')) {
         $repository->setEventDispatcher($this->app['Illuminate\\Contracts\\Events\\Dispatcher']);
     }
     return $repository;
 }
 public function testMergeKeywords()
 {
     // Add a keyword.
     $this->cache->mergeKeywords('test')->put('key1', 'newValue', 60);
     $this->assertEquals(['key1'], $this->cache->get('keyword[test]'));
     $this->assertEquals(['key1'], $this->cache->get('keyword[keyword1]'));
     $this->assertEquals(['key1', 'key2'], $this->cache->get('keyword[keyword2]'));
     $this->assertEquals(['keyword1', 'keyword2', 'test'], $this->cache->get('keyword_index[key1]'));
     // Try existing keywords; should do nothing.
     $this->cache->mergeKeywords('keyword3')->forever('key3', 'value3');
     $this->assertEquals(['key2', 'key3'], $this->cache->get('keyword[keyword3]'));
     $this->assertEquals(['key3', 'key4'], $this->cache->get('keyword[keyword4]'));
     $this->assertEquals(['keyword3', 'keyword4'], $this->cache->get('keyword_index[key3]'));
     // Try empty; should do nothing.
     $this->cache->mergeKeywords([])->forever('key3', 'value3');
     $this->assertEquals(['key2', 'key3'], $this->cache->get('keyword[keyword3]'));
     $this->assertEquals(['key3', 'key4'], $this->cache->get('keyword[keyword4]'));
     $this->assertEquals(['keyword3', 'keyword4'], $this->cache->get('keyword_index[key3]'));
 }