setDefaultLanguage example

$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;
                }
            }

            $this->shopConfigurator->setDefaultLanguage($input->getOption('shop-locale'));
            $output->writeln('Successfully changed shop default language');
            $output->writeln('');
        }

        if ($input->getOption('shop-currency')) {
            if (!$input->getOption('no-interaction')) {
                if (!$output->confirm('Changing the shops default currency 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;
                }
            }
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');

        $lang = $langRepo->search(new Criteria([Defaults::LANGUAGE_SYSTEM]), Context::createDefaultContext())
            ->first();

        static::assertEquals('Spanish', $lang->getName());
    }

    public function testSwitchLanguageWithDefaultLocale(): void
    {
class MigrateDefaultLanguageTest extends MigrateDrupal7TestBase {

  /** * {@inheritdoc} */
  protected static $modules = ['language'];

  /** * Tests language_default migration with a non-existing language. */
  public function testMigrationWithExistingLanguage() {
    $this->setDefaultLanguage('is');
    $this->startCollectingMessages();
    $this->executeMigrations(['language', 'default_language']);

    // Tests the language is loaded and is the default language.     $default_language = ConfigurableLanguage::load('is');
    $this->assertNotNull($default_language);
    $this->assertSame('is', $this->config('system.site')->get('default_langcode'));
  }

  /** * Tests language_default migration with a non-existing language. */
/** * @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 */

            );

            static::assertArrayHasKey('languageId', $parameters);
            static::assertEquals(Defaults::LANGUAGE_SYSTEM, Uuid::fromBytesToHex($parameters['languageId']));

            return null;
        });

        $this->shopConfigurator->setDefaultLanguage('vi-VN');
    }

    public function testSetDefaultLanguageMatchCurrentLocale(): void
    {
        $currentLocaleId = Uuid::randomHex();

        $this->connection->expects(static::once())->method('fetchAssociative')->willReturnCallback(function Dstring $sql, array $parameters) use ($currentLocaleId) {
            static::assertEquals(
                trim($sql),
                'SELECT locale.id, locale.code FROM language INNER JOIN locale ON translation_code_id = locale.id WHERE language.id = :languageId'
class MigrateDefaultLanguageTest extends MigrateDrupal6TestBase {

  /** * {@inheritdoc} */
  protected static $modules = ['language'];

  /** * Tests language_default migration with an existing language. */
  public function testMigrationWithExistingLanguage() {
    $this->setDefaultLanguage('fr');
    $this->startCollectingMessages();
    $this->executeMigrations(['language', 'default_language']);

    // Tests the language is loaded and is the default language.     $default_language = ConfigurableLanguage::load('fr');
    $this->assertNotNull($default_language);
    $this->assertSame('fr', $this->config('system.site')->get('default_langcode'));
  }

  /** * Tests language_default migration with a non-existing language. */
Home | Imprint | This part of the site doesn't use cookies.