public function it_should_cache_a_new_value(Cache $cache, TextFilter $filter)
 {
     $text = 'foo';
     $cache->contains(Argument::type('string'))->willReturn(false);
     $cache->fetch(Argument::type('string'))->shouldNotBeCalled();
     $filter->filter($text)->willReturn('bar');
     $cache->save(Argument::type('string'), 'bar')->shouldBeCalled();
     $this->filter($text)->shouldReturn('bar');
 }
 protected function doFilter($text)
 {
     $key = md5($text);
     if (true === $this->cache->contains($key)) {
         $result = $this->cache->fetch($key);
         if (false !== $result) {
             return $result;
         }
     }
     $text = $this->filter->filter($text);
     $this->cache->save($key, $text);
     return $text;
 }
 public function it_should_throw_an_exception_on_an_exception(TextFilter $filter1, TextFilter $filter2, TextFilter $filter3)
 {
     $this->beConstructedWith(array($filter1, $filter2, $filter3));
     $filter1->filter('foo')->willReturn('bar');
     $filter2->filter('bar')->willThrow('Exception');
     $filter3->filter(Argument::type('string'))->shouldNotBeCalled();
     $this->shouldThrow('TheWilkyBarKid\\TextFilter\\Exception\\TextFilterFailedException')->during('filter', array('foo'));
 }