Example #1
0
 public function testGetPrependAppendCacheRule()
 {
     $this->assertInstanceOf('Webiny\\Hrc\\CacheRules\\CacheRule', $this->instance->getCacheRule('FooBar'));
     $this->assertFalse($this->instance->getCacheRule('AppendedRule'));
     $appendedRule = new CacheRule('AppendedRule', 100, ['t1'], ['Url' => 'appended-rule/*']);
     $this->instance->appendRule($appendedRule);
     $this->assertSame($appendedRule, $this->instance->getCacheRule('AppendedRule'));
     $this->assertFalse($this->instance->getCacheRule('PrependedRule'));
     $prependedRule = new CacheRule('PrependedRule', 100, ['t1'], ['Url' => 'prepended-rule/*']);
     $this->instance->prependRule($prependedRule);
     $this->assertSame($prependedRule, $this->instance->getCacheRule('PrependedRule'));
     $rules = $this->instance->getCacheRule();
     $this->assertSame(3, count($rules));
     $this->assertSame('PrependedRule', $rules[0]->getName());
     $this->assertSame('FooBar', $rules[1]->getName());
     $this->assertSame('AppendedRule', $rules[2]->getName());
 }