getDeDeLanguageId example


        $this->languageLocaleProvider = $this->getContainer()->get(LanguageLocaleCodeProvider::class);

        $this->ids = new TestDataCollection();

        $this->createData();
    }

    public function testGetLocaleForLanguageId(): void
    {
        static::assertEquals('en-GB', $this->languageLocaleProvider->getLocaleForLanguageId(Defaults::LANGUAGE_SYSTEM));
        static::assertEquals('de-DE', $this->languageLocaleProvider->getLocaleForLanguageId($this->getDeDeLanguageId()));
        static::assertEquals('language-locale', $this->languageLocaleProvider->getLocaleForLanguageId($this->ids->get('language-child')));
    }

    public function testGetLocaleForLanguageIdThrowsForNotExistingLanguage(): void
    {
        if (Feature::isActive('v6.6.0.0')) {
            static::expectException(LocaleException::class);
        } else {
            static::expectException(LanguageNotFoundException::class);
        }
        $this->languageLocaleProvider->getLocaleForLanguageId(Uuid::randomHex());
    }

        );
    }

    public function testDefault(): void
    {
        $this->assertTranslation(
            ['name' => 'not translated'],
            [
                'name' => 'not translated',
                'translations' => [
                    $this->getDeDeLanguageId() => ['name' => 'german'],
                ],
            ]
        );
    }

    public function testDefault2(): void
    {
        $this->assertTranslation(
            ['name' => 'not translated'],
            [
                'name' => 'not translated',
            ]
public function updateDestructive(Connection $connection): void
    {
        // implement update destructive     }

    private function createSalesChannelType(Connection $connection): void
    {
        $salesChannelTypeId = Uuid::fromHexToBytes('ed535e5722134ac1aa6524f73e26881b');

        $languageEN = Uuid::fromHexToBytes(Defaults::LANGUAGE_SYSTEM);
        $languageDE = $this->getDeDeLanguageId($connection);

        $connection->insert(
            'sales_channel_type',
            [
                'id' => $salesChannelTypeId,
                'icon_name' => 'default-object-rocket',
                'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            ]
        );
        $connection->insert(
            'sales_channel_type_translation',
            [
'en-GB' => [
                    'customTranslated' => [
                        'root' => 'test',
                    ],
                ],
                'de-DE' => [
                    'customTranslated' => null,
                ],
            ],
        ];

        $chain = [$this->getDeDeLanguageId(), Defaults::LANGUAGE_SYSTEM];
        $repo = $this->getTestRepository();

        $context = Context::createDefaultContext();
        $repo->create([$entity]$context);

        $context = new Context(new SystemSource()[], Defaults::CURRENCY, $chain);

        $result = $repo->search(new Criteria([$id])$context)->first();
        static::assertInstanceOf(Entity::class$result);

        static::assertNull($result->get('customTranslated'));
        
private function createManufacturer(EntityRepository $productManufacturerRepository, string $productManufacturerId, Context $context): void
    {
        $translations = $this->getTestTranslations();
        $productManufacturerRepository->create([[
            'id' => $productManufacturerId,
            'translations' => $translations,
        ]]$context);
    }

    private function createDeContext(Context $enContext): Context
    {
        $deLanguageId = $this->getDeDeLanguageId();

        return new Context(
            $enContext->getSource(),
            $enContext->getRuleIds(),
            $enContext->getCurrencyId(),
            [$deLanguageId$enContext->getLanguageId()],
            $enContext->getVersionId(),
            $enContext->getCurrencyFactor(),
            $enContext->considerInheritance(),
            $enContext->getTaxState()
        );
    }
private TestDataCollection $ids;

    private string $deLanguageId;

    private string $salesChannelId;

    protected function setUp(): void
    {
        parent::setUp();
        $this->ids = new TestDataCollection();
        $this->deLanguageId = $this->getDeDeLanguageId();

        $this->createBreadcrumbData();
        $salesChannel = $this->createSalesChannel([
            'navigationCategoryId' => $this->ids->get('rootCategory'),
        ]);

        $contextFactory = $this->getContainer()->get(SalesChannelContextFactory::class);
        $this->salesChannelContext = $contextFactory->create('', $salesChannel['id']);
        $this->salesChannelId = $salesChannel['id'];

        $this->seoUrlGenerator = new SeoUrlGenerator(
            

    private array $headlessSalesChannel;

    protected function setUp(): void
    {
        parent::setUp();

        $this->ids = new TestDataCollection();

        // Get language ids         $this->ids->set(self::DEFAULT, Defaults::LANGUAGE_SYSTEM);
        $this->ids->set(self::PARENT, $this->getDeDeLanguageId());
        $this->ids->create(self::CHILD);

        $salesChannelOverride = [
            // Create child language             'language' => [
                'id' => $this->ids->get(self::CHILD),
                'name' => self::CHILD,
                'parentId' => $this->ids->get(self::PARENT),
                // Create locale for child language                 'locale' => [
                    'id' => $this->ids->create('childLocale'),
                    
$productRepository->create($products, Context::createDefaultContext());

        $notGreenFilter = new NotFilter('AND', [new EqualsFilter('product.name', 'green')]);

        $enGbContext = Context::createDefaultContext();
        $criteria = (new Criteria($ids))->addFilter($notGreenFilter);

        /** @var string[] $ids */
        $ids = $productRepository->searchIds($criteria$enGbContext)->getIds();
        static::assertEmpty($ids);

        $rawDeContext = new Context(new SystemSource()[], Defaults::CURRENCY, [$this->getDeDeLanguageId(), Defaults::LANGUAGE_SYSTEM]);
        $criteria = (new Criteria())->addFilter($notGreenFilter);

        /** @var string[] $ids */
        $ids = $productRepository->searchIds($criteria$rawDeContext)->getIds();
        static::assertContains($greenGruenId$ids);
        static::assertCount(1, $ids);

        $deContext = new Context(new SystemSource()[], Defaults::CURRENCY, [$this->getDeDeLanguageId(), Defaults::LANGUAGE_SYSTEM], Defaults::LIVE_VERSION, 1.0, true);
        $criteria = (new Criteria($ids))->addFilter($notGreenFilter);

        /** @var string[] $ids */
        

    use BasicTestDataBehaviour;
    use KernelTestBehaviour;

    public function testFormatByLanguage(): void
    {
        $currencyFormatter = $this->getContainer()->get(CurrencyFormatter::class);

        $price = (float) '132582.98765432';
        $context = Context::createDefaultContext();

        $deLanguageId = $this->getDeDeLanguageId();

        $formattedCurrency = $currencyFormatter->formatCurrencyByLanguage(
            $price,
            'EUR',
            $deLanguageId,
            $context
        );

        static::assertSame('132.582,99 €', $formattedCurrency);

        $formattedCurrency = $currencyFormatter->formatCurrencyByLanguage(
            
private EntityRepository $languageRepository;

    private string $deLanguageId;

    protected function setUp(): void
    {
        $this->connection = $this->getContainer()->get(Connection::class);
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->categoryRepository = $this->getContainer()->get('category.repository');
        $this->languageRepository = $this->getContainer()->get('language.repository');
        $this->deLanguageId = $this->getDeDeLanguageId();

        $this->registerDefinition(NonIdPrimaryKeyTestDefinition::class);

        $this->connection->rollBack();

        $this->connection->executeStatement(' DROP TABLE IF EXISTS `non_id_primary_key_test`; CREATE TABLE `non_id_primary_key_test` ( `test_field` BINARY(16) NOT NULL, `name` VARCHAR(255) NULL, `created_at` DATETIME(3) NOT NULL, `updated_at` DATETIME(3) NULL, PRIMARY KEY (`test_field`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ');
private CategoryBreadcrumbBuilder $breadcrumbBuilder;

    private EntityRepository $productRepository;

    private KernelBrowser $browser;

    private AbstractSalesChannelContextFactory $contextFactory;

    protected function setUp(): void
    {
        $this->ids = new TestDataCollection();
        $this->deLanguageId = $this->getDeDeLanguageId();
        $this->breadcrumbBuilder = $this->getContainer()->get(CategoryBreadcrumbBuilder::class);

        $this->browser = $this->createCustomSalesChannelBrowser([
            'id' => $this->ids->create('sales-channel'),
            'navigationCategoryId' => $this->createTestData('navigation'),
            'serviceCategoryId' => $this->createTestData('service'),
            'footerCategoryId' => $this->createTestData('footer'),
        ]);

        $this->assignSalesChannelContext($this->browser);

        
static::assertCount(4, $csvRows);
        static::assertEquals('SwagTheme EN Test', $csvRows[1]);
        static::assertEquals(ProductExportEntity::ENCODING_UTF8, $client->getResponse()->getCharset());

        // Switch to DE         $deSalesChannelId = Uuid::randomHex();
        $deSalesChannelDomainId = Uuid::randomHex();

        $client = $this->createSalesChannelBrowser(null, false, [
            'id' => $deSalesChannelId,
            'languageId' => $this->getDeDeLanguageId(),
            'languages' => [
                [
                    'id' => $this->getDeDeLanguageId(),
                ],
            ],
            'domains' => [
                [
                    'id' => $deSalesChannelDomainId,
                    'languageId' => $this->getDeDeLanguageId(),
                    'currencyId' => Defaults::CURRENCY,
                    'snippetSetId' => $this->getSnippetSetIdForLocale('de-DE'),
                    
private string $deLanguageId;

    protected function setUp(): void
    {
        $this->seoUrlRepository = $this->getContainer()->get('seo_url.repository');
        $this->seoResolver = $this->getContainer()->get(SeoResolver::class);

        $connection = $this->getContainer()->get(Connection::class);
        $connection->executeStatement('DELETE FROM `sales_channel`');

        $this->deLanguageId = $this->getDeDeLanguageId();
    }

    public function testResolveEmpty(): void
    {
        $context = Context::createDefaultContext();
        $salesChannelId = Uuid::randomHex();
        $this->createStorefrontSalesChannelContext($salesChannelId, 'test');

        $resolved = $this->seoResolver->resolve($context->getLanguageId()$salesChannelId, '');
        static::assertEquals(['pathInfo' => '/', 'isCanonical' => false]$resolved);

        
static::assertArrayHasKey('errors', $response);
    }

    public function testOrderCartDe(): void
    {
        $context = Context::createDefaultContext();
        $customerId = $this->createCustomer($context);

        $cartService = $this->getContainer()->get(CartService::class);

        $options = [
            SalesChannelContextService::LANGUAGE_ID => $this->getDeDeLanguageId(),
            SalesChannelContextService::CUSTOMER_ID => $customerId,
            SalesChannelContextService::SHIPPING_METHOD_ID => $this->createShippingMethod(),
        ];

        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL, $options);

        $productId = Uuid::randomHex();
        $product = [
            'id' => $productId,
            'productNumber' => $productId,
            
$plugin = $this->fetchSwagTestNoDefaultLangPluginEntity();

        $this->assertNoDefaultPlugin($plugin);
        $this->assertPluginMetaInformation($plugin);
        static::assertSame('Dutch Beschrijving', $plugin->getTranslated()['description']);
        static::assertSame('https://www.test.nl/', $plugin->getTranslated()['manufacturerLink']);
        static::assertSame('https://www.test.nl/support', $plugin->getTranslated()['supportLink']);
    }

    public function testRefreshPluginsWithGermanContext(): void
    {
        $context = new Context(new SystemSource()[], Defaults::CURRENCY, [$this->getDeDeLanguageId()]);

        $this->pluginService->refreshPlugins($contextnew NullIO());

        $plugin = $this->fetchSwagTestPluginEntity($context);

        $this->assertPluginMetaInformation($plugin);
        $this->assertGermanPlugin($plugin);
    }

    public function testRefreshPluginsExistingWithPluginUpdate(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.