Beispiel #1
0
    public function testRefreshRoute()
    {
        $httpCache = \Mockery::mock('\FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface')
            ->shouldReceive('refresh')->once()->with('/my/route', null)
            ->shouldReceive('refresh')->once()->with('/route/with/params/id/123', null)
            ->shouldReceive('refresh')->once()->with('/route/with/params/id/123', array('X-Foo' => 'bar'))
            ->shouldReceive('flush')->never()
            ->getMock();

        $router = \Mockery::mock('\Symfony\Component\Routing\Generator\UrlGeneratorInterface')
            ->shouldReceive('generate')
            ->with('my_route', array())
            ->andReturn('/my/route')

            ->shouldReceive('generate')
            ->with('route_with_params', array('id' => 123))
            ->andReturn('/route/with/params/id/123')
            ->getMock();

        $cacheManager = new CacheManager($httpCache, $router);

        $cacheManager
            ->refreshRoute('my_route')
            ->refreshRoute('route_with_params', array('id' => 123))
            ->refreshRoute('route_with_params', array('id' => 123), array('X-Foo' => 'bar'))
        ;
    }