getDefaultViewParams example

$this->connectionFactory,
            __DIR__
        );
        $this->controller->setContainer($this->getInstallerContainer($this->twig, ['router' => $this->router]));
    }

    public function testDatabaseGetConfigurationRoute(): void
    {
        $this->twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/database-configuration.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'connectionInfo' => new DatabaseConnectionInformation(),
                    'error' => null,
                ])
            )
            ->willReturn('config');

        $this->connectionFactory->expects(static::never())->method('getConnection');

        $request = Request::create('/installer/database-configuration');
        $session = new Session(new MockArraySessionStorage());
        $request->setSession($session);

        

class SelectLanguagesControllerTest extends TestCase
{
    use InstallerControllerTestTrait;

    public function testLanguageSelectionRoute(): void
    {
        $twig = $this->createMock(Environment::class);
        $twig->expects(static::once())->method('render')
            ->with('@Installer/installer/language-selection.html.twig', $this->getDefaultViewParams())
            ->willReturn('languages');

        $notifier = $this->createMock(Notifier::class);
        $notifier->expects(static::once())->method('doTrackEvent')
            ->with(Notifier::EVENT_INSTALL_STARTED);

        $controller = new SelectLanguagesController($notifier);
        $controller->setContainer($this->getInstallerContainer($twig));

        $response = $controller->languageSelection();
        static::assertSame('languages', $response->getContent());
    }
$response = $this->controller->databaseImport($request);
        static::assertInstanceOf(RedirectResponse::class$response);
        static::assertSame('/installer/database-configuration', $response->getTargetUrl());
    }

    public function testImportDatabaseRoute(): void
    {
        $this->twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/database-import.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'supportedLanguages' => [],
                    'error' => null,
                ])
            )
            ->willReturn('import');

        $session = new Session(new MockArraySessionStorage());
        $session->set(DatabaseConnectionInformation::classnew DatabaseConnectionInformation());
        $request = Request::create('/installer/database-import');
        $request->setSession($session);

        
->method('fetchAllAssociative')
            ->willReturn([
                ['iso3' => 'DEU', 'iso' => 'DE'],
                ['iso3' => 'GBR', 'iso' => 'GB'],
            ]);

        $this->translator->method('trans')->willReturnCallback(fn (string $key): string => $key);

        $this->twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/shop-configuration.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'error' => null,
                    'countryIsos' => [
                        ['iso3' => 'DEU', 'default' => true, 'translated' => 'shopware.installer.select_country_deu'],
                        ['iso3' => 'GBR', 'default' => false, 'translated' => 'shopware.installer.select_country_gbr'],
                    ],
                    'currencyIsos' => ['EUR', 'USD'],
                    'languageIsos' => ['de' => 'de-DE', 'en' => 'en-GB'],
                    'parameters' => ['config_shop_language' => 'de-DE'],
                ])
            )
            ->willReturn('config');

        
$validator = $this->createMock(RequirementsValidatorInterface::class);
        $validator->expects(static::once())
            ->method('validateRequirements')
            ->with(static::isInstanceOf(RequirementsCheckCollection::class))
            ->willReturn($checks);

        $twig = $this->createMock(Environment::class);
        $twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/requirements.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'requirementChecks' => $checks,
                ])
            )
            ->willReturn('checks');

        $jwtCertificateGenerator = $this->createMock(JwtCertificateGenerator::class);
        $jwtCertificateGenerator->expects(static::never())->method('generate');

        $controller = new RequirementsController([$validator]$jwtCertificateGenerator, __DIR__);
        $controller->setContainer($this->getInstallerContainer($twig));

        
$licenseFetcher = $this->createMock(LicenseFetcher::class);
        $licenseFetcher->expects(static::once())
            ->method('fetch')
            ->with($request)
            ->willReturn('licenseText');

        $twig = $this->createMock(Environment::class);
        $twig->expects(static::once())->method('render')
            ->with(
                '@Installer/installer/license.html.twig',
                array_merge($this->getDefaultViewParams()[
                    'licenseAgreement' => 'licenseText',
                    'error' => null,
                ]),
            )
            ->willReturn('license');

        $controller = new LicenseController($licenseFetcher);
        $controller->setContainer($this->getInstallerContainer($twig));

        $response = $controller->license($request);
        static::assertSame('license', $response->getContent());
    }
Home | Imprint | This part of the site doesn't use cookies.