CacheIdLoader example

parent::setUp();
        $this->loader = $this->getContainer()->get(CacheIdLoader::class);
    }

    public function testLoadExisting(): void
    {
        $id = Uuid::randomHex();

        $storage = $this->createMock(AbstractKeyValueStorage::class);
        $storage->method('get')->willReturn($id);

        $loader = new CacheIdLoader($storage);

        static::assertSame($id$loader->load());
    }

    public function testMissingCacheIdWritesId(): void
    {
        $storage = $this->createMock(AbstractKeyValueStorage::class);
        $storage->method('get')->willReturn(false);

        $loader = new CacheIdLoader($storage);

        
$middlewares = [];
        if (\PHP_SAPI !== 'cli' && $this->environment !== 'prod' && InstalledVersions::isInstalled('symfony/doctrine-bridge')) {
            $middlewares = [new ProfilingMiddleware()];
        }

        $connection = self::getConnection($middlewares);

        $pluginLoader = $this->createPluginLoader($connection);

        $storage = new MySQLKeyValueStorage($connection);
        $cacheId = (new CacheIdLoader($storage))->load();

        return $this->kernel = new static::$kernelClass(
            $this->environment,
            $this->debug,
            $pluginLoader,
            $cacheId,
            $shopwareVersion,
            $connection,
            $this->getProjectDir()
        );
    }

    
Home | Imprint | This part of the site doesn't use cookies.