ContainerParametersResourceChecker example

class ContainerParametersResourceCheckerTest extends TestCase
{
    private ContainerParametersResource $resource;
    private ContainerParametersResourceChecker $resourceChecker;
    private MockObject&ContainerInterface $container;

    protected function setUp(): void
    {
        $this->resource = new ContainerParametersResource(['locales' => ['fr', 'en'], 'default_locale' => 'fr']);
        $this->container = $this->createMock(ContainerInterface::class);
        $this->resourceChecker = new ContainerParametersResourceChecker($this->container);
    }

    public function testSupports()
    {
        $this->assertTrue($this->resourceChecker->supports($this->resource));
    }

    /** * @dataProvider isFreshProvider */
    public function testIsFresh(callable $mockContainer$expected)
    {
$container = new Container();
            $container->set('routing.loader', new YamlFileLoader(new FileLocator(__DIR__.'/Fixtures')));

            $container->setParameter('parameter.condition', $parameter);

            $router = new Router($container, 'with_condition.yaml', [
                'debug' => true,
                'cache_dir' => $cacheDir,
            ]);

            $resourceCheckers = [
                new ContainerParametersResourceChecker($container),
            ];

            $router->setConfigCacheFactory(new ResourceCheckerConfigCacheFactory($resourceCheckers));

            $router->getMatcher(); // trigger cache build
            $cache = new ResourceCheckerConfigCache($cacheDir.\DIRECTORY_SEPARATOR.'url_matching_routes.php', $resourceCheckers);

            $this->assertTrue($cache->isFresh());
        } finally {
            if (is_dir($cacheDir)) {
                
Home | Imprint | This part of the site doesn't use cookies.