/**
  * @depends testResolveIsSavedToCache
  */
 public function testRemoveUsesIndex()
 {
     $request = new Request();
     $resolver = $this->getMockResolver();
     $resolver->expects($this->once())->method('resolve')->with($request, $this->path, $this->filter)->will($this->returnValue($this->targetPath));
     $resolver->expects($this->once())->method('remove')->will($this->returnValue(true));
     $cache = new MemoryCache();
     $cacheResolver = new CacheResolver($cache, $resolver);
     $cacheResolver->resolve($request, $this->path, $this->filter);
     /*
      * Three items:
      * * The result of resolve.
      * * The result of reverse for the targetPath.
      * * The index of both entries.
      */
     $this->assertCount(3, $cache->data);
     $this->assertTrue($cacheResolver->remove($this->targetPath, $this->filter));
     // Cache including index has been removed.
     $this->assertCount(0, $cache->data);
 }
    public function testRemoveAllFilterCacheOnRemove()
    {
        $resolver = $this->createResolverMock();
        $resolver
            ->expects($this->exactly(4))
            ->method('resolve')
            ->will($this->returnValue('aCachePath'))
        ;
        $resolver
            ->expects($this->once())
            ->method('remove')
        ;

        $cache = new ArrayCache();

        $cacheResolver = new CacheResolver($cache, $resolver);
        $cacheResolver->resolve('aPathFoo', 'thumbnail_233x233');
        $cacheResolver->resolve('aPathBar', 'thumbnail_233x233');
        $cacheResolver->resolve('aPathFoo', 'thumbnail_100x100');
        $cacheResolver->resolve('aPathBar', 'thumbnail_100x100');

        /*
         * Seven items:
         * * The result of four resolve execution.
         * * The index of two entities.
         * * The array cache meta info
         */
        $this->assertCount(7, $this->readAttribute($cache, 'data'));

        $cacheResolver->remove(array(), array('thumbnail_233x233'));

        // Cache including index has been removed.
        $this->assertCount(4, $this->readAttribute($cache, 'data'));
    }