getSystemConfigService example

private const STORE_URI_CONFIG_KEY = 'core.store.apiUri';

    private ?string $originalStoreUri = null;

    /** * @before */
    public function updateStoreUri(): void
    {
        $this->originalStoreUri = $this->getApiUrlFromSystemConfig();
        $this->getSystemConfigService()->set(self::STORE_URI_CONFIG_KEY, self::TEST_STORE_URI);
    }

    /** * @after */
    public function restoreStoreUri(): void
    {
        $this->getSystemConfigService()->set(self::STORE_URI_CONFIG_KEY, $this->originalStoreUri);
    }

    public function testItCreatesAnClientWithBaseConfig(): void
    {
if ($request === null) {
            $request = new Request();
        }

        $salesChannelContext = $request->attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT);

        $event = new StorefrontRenderEvent($view$parameters$request$salesChannelContext);

        $this->container->get('event_dispatcher')->dispatch($event);

        $iconCacheEnabled = $this->getSystemConfigService()->get('core.storefrontSettings.iconCache') ?? true;

        if ($iconCacheEnabled) {
            IconCacheTwigFilter::enable();
        }

        $response = Profiler::trace('twig-rendering', fn () => $this->render($view$event->getParameters()new StorefrontResponse()));

        if ($iconCacheEnabled) {
            IconCacheTwigFilter::disable();
        }

        

class CanonicalRedirectServiceTest extends TestCase
{
    final public const CONFIG_KEY = 'core.seo.redirectToCanonicalUrl';

    /** * @dataProvider requestDataProvider */
    public function testGetRedirect(Request $request, ?Response $response): void
    {
        $shouldRedirect = $response->getStatusCode() === Response::HTTP_MOVED_PERMANENTLY;
        $canonicalRedirectService = new CanonicalRedirectService($this->getSystemConfigService($shouldRedirect));

        /** @var RedirectResponse|null $actual */
        $actual = $canonicalRedirectService->getRedirect($request);

        if ($shouldRedirect) {
            static::assertNotNull($actual);
            static::assertInstanceOf(
                RedirectResponse::class,
                $actual
            );
            static::assertEquals(
                
Home | Imprint | This part of the site doesn't use cookies.