updateBasicInformation example

private SystemConfigService $systemConfigService;

    protected function setUp(): void
    {
        $this->shopConfigurator = $this->getContainer()->get(ShopConfigurator::class);
        $this->systemConfigService = $this->getContainer()->get(SystemConfigService::class);
    }

    public function testUpdateBasicInformation(): void
    {
        $this->shopConfigurator->updateBasicInformation('test-shop', 'shop@test.com');

        static::assertEquals('test-shop', $this->systemConfigService->get('core.basicInformation.shopName'));
        static::assertEquals('shop@test.com', $this->systemConfigService->get('core.basicInformation.email'));
    }

    public function testSwitchLanguageWithNewLanguage(): void
    {
        $this->shopConfigurator->setDefaultLanguage('es-ES');

        /** @var EntityRepository $langRepo */
        $langRepo = $this->getContainer()->get('language.repository');

        

    /** * @param Shop $shop */
    public function updateShop(array $shop, Connection $connection): void
    {
        if (empty($shop['locale']) || empty($shop['host'])) {
            throw new \RuntimeException('Please fill in all required fields. (shop configuration)');
        }

        $shopConfigurator = new ShopConfigurator($connection);
        $shopConfigurator->updateBasicInformation($shop['name']$shop['email']);
        $shopConfigurator->setDefaultLanguage($shop['locale']);
        $shopConfigurator->setDefaultCurrency($shop['currency']);

        $this->deleteAllSalesChannelCurrencies($connection);

        $newSalesChannelId = Uuid::randomBytes();
        $this->createSalesChannel($newSalesChannelId$shop$connection);
        $this->createSalesChannelDomain($newSalesChannelId$shop$connection);
    }

    /** * @param Shop $shop */
->addOption('shop-email', null, InputOption::VALUE_REQUIRED, 'Shop email address')
            ->addOption('shop-locale', null, InputOption::VALUE_REQUIRED, 'Default language locale of the shop')
            ->addOption('shop-currency', null, InputOption::VALUE_REQUIRED, 'Iso code for the default currency of the shop')
            ->addOption('no-interaction', 'n', InputOption::VALUE_NONE, 'Run command in non-interactive mode')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output = new ShopwareStyle($input$output);

        $this->shopConfigurator->updateBasicInformation($input->getOption('shop-name')$input->getOption('shop-email'));

        $output->writeln('Shop configured successfully');
        $output->writeln('');

        if ($input->getOption('shop-locale')) {
            if (!$input->getOption('no-interaction')) {
                if (!$output->confirm('Changing the shops default locale after the fact can be destructive. Are you sure you want to continue', false)) {
                    $output->writeln('Aborting due to user input');

                    return (int) Command::SUCCESS;
                }
            }
static::assertArrayHasKey('key', $parameters);
            static::assertArrayHasKey('value', $parameters);

            if ($parameters['key'] === 'core.basicInformation.shopName') {
                static::assertEquals('{"_value":"test-shop"}', $parameters['value']);
            } else {
                static::assertEquals('core.basicInformation.email', $parameters['key']);
                static::assertEquals('{"_value":"shop@test.com"}', $parameters['value']);
            }
        });

        $this->shopConfigurator->updateBasicInformation('test-shop', 'shop@test.com');
    }

    public function testSetDefaultLanguageWithoutCurrentLocale(): void
    {
        static::expectException(ShopConfigurationException::class);
        static::expectExceptionMessage('Default language locale not found');

        $this->connection->expects(static::once())->method('fetchAssociative')->willReturnCallback(function Dstring $sql, array $parameters): ?array {
            static::assertEquals(
                trim($sql),
                'SELECT locale.id, locale.code FROM language INNER JOIN locale ON translation_code_id = locale.id WHERE language.id = :languageId'
Home | Imprint | This part of the site doesn't use cookies.