getLocaleIdOfSystemLanguage example

static::assertSame($englishName$payload['name']);
        static::assertSame($englishShortName$payload['shortName']);

        $germanLanguageId = Uuid::randomHex();
        $data = [
            'id' => $germanLanguageId,
            'translationCode' => [
                'name' => 'Niederländisch',
                'code' => 'x-nl_NL',
                'territory' => 'Niederlande',
            ],
            'localeId' => $this->getLocaleIdOfSystemLanguage(),
            'name' => 'nl-NL',
        ];

        $this->languageRepository->create([$data]$this->context);

        $nlName = 'Amerikaans Dollar';
        $nlShortName = 'US Dollar German';

        $data = [
            'factor' => 1,
            'symbol' => '$',
            


    public function testCloneVariantTranslation(): void
    {
        $ids = new IdsCollection();

        $this->getContainer()->get('language.repository')->create(
            [
                [
                    'id' => $ids->create('language'),
                    'name' => 'test-language',
                    'localeId' => $this->getLocaleIdOfSystemLanguage(),
                    'translationCode' => [
                        'code' => Uuid::randomHex(),
                        'name' => 'Test locale',
                        'territory' => 'test',
                    ],
                ],
            ],
            Context::createDefaultContext()
        );

        $product = (new ProductBuilder($ids, 'parent'))
            
$client = $this->getBrowser(false);

        $username = Uuid::randomHex();

        $this->getContainer()->get(Connection::class)->insert('user', [
            'id' => Uuid::randomBytes(),
            'first_name' => $username,
            'last_name' => '',
            'email' => 'test@example.com',
            'username' => $username,
            'password' => TestDefaults::HASHED_PASSWORD,
            'locale_id' => Uuid::fromHexToBytes($this->getLocaleIdOfSystemLanguage()),
            'active' => 1,
            'admin' => 1,
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $this->apiUsernames[] = $username;

        /** * Auth the api client first */
        $authPayload = [
            


    private function createLanguage(string $id, ?string $parentId = Defaults::LANGUAGE_SYSTEM): void
    {
        $languageRepository = $this->getContainer()->get('language.repository');

        $languageRepository->create(
            [
                [
                    'id' => $id,
                    'name' => sprintf('name-%s', $id),
                    'localeId' => $this->getLocaleIdOfSystemLanguage(),
                    'parentId' => $parentId,
                    'translationCode' => [
                        'id' => self::TEST_LOCALE_ID,
                        'code' => self::TEST_LANGUAGE_LOCALE_CODE,
                        'name' => 'Test locale',
                        'territory' => 'test',
                    ],
                    'salesChannels' => [
                        ['id' => TestDefaults::SALES_CHANNEL],
                    ],
                    'salesChannelDefaultAssignments' => [
                        [
'translations' => [
                    ['languageId' => Defaults::LANGUAGE_SYSTEM, 'name' => 'translated by default fallback'],
                ],
            ]
        );
    }

    public function testOnlySystemLocaleIdentifier(): void
    {
        $localeRepo = $this->getContainer()->get('locale.repository');
        /** @var LocaleEntity $locale */
        $locale = $localeRepo->search(new Criteria([$this->getLocaleIdOfSystemLanguage()]), Context::createDefaultContext())->first();

        $this->assertTranslation(
            ['name' => 'system translation'],
            [
                'translations' => [
                    $locale->getCode() => ['name' => 'system translation'],
                ],
            ]
        );
    }

    


    private function createData(): void
    {
        $products = [];

        $this->getContainer()->get('language.repository')->create(
            [
                [
                    'id' => $this->ids->create('language'),
                    'name' => 'foo',
                    'localeId' => $this->getLocaleIdOfSystemLanguage(),
                    'translationCode' => [
                        'code' => Uuid::randomHex(),
                        'name' => 'Test locale',
                        'territory' => 'test',
                    ],
                    'salesChannels' => [
                        ['id' => TestDefaults::SALES_CHANNEL],
                    ],
                ],
            ],
            Context::createDefaultContext()
        );
$this->getFrwRequestHandler()->reset();
    }

    protected function createAdminStoreContext(): Context
    {
        $userId = Uuid::randomHex();
        $storeToken = Uuid::randomHex();

        $data = [
            [
                'id' => $userId,
                'localeId' => $this->getLocaleIdOfSystemLanguage(),
                'username' => 'foobar',
                'password' => 'asdasdasdasd',
                'firstName' => 'Foo',
                'lastName' => 'Bar',
                'email' => Uuid::randomHex() . '@bar.com',
                'storeToken' => $storeToken,
            ],
        ];

        $this->getUserRepository()->create($data, Context::createDefaultContext());

        


    private function createUser(string $userId): void
    {
        $this->getContainer()->get(Connection::class)->insert('user', [
            'id' => Uuid::fromHexToBytes($userId),
            'first_name' => 'test',
            'last_name' => '',
            'email' => 'test@example.com',
            'username' => 'userTest',
            'password' => password_hash('123456', \PASSWORD_BCRYPT),
            'locale_id' => Uuid::fromHexToBytes($this->getLocaleIdOfSystemLanguage()),
            'active' => 1,
            'admin' => 1,
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);
    }

    /** * @param array<string> $privileges */
    private function createAclRole(string $aclRoleId, array $privileges): void
    {
        
$this->languageRepository->create($this->addDefaultTranslationCodes($this->addDefaultLocales($languages))$this->defaultContext);
    }

    protected function addDefaultLocales(array $languages): array
    {
        return array_map(fn ($lang) => $this->addDefaultLocale($lang)$languages);
    }

    protected function addDefaultLocale(array $lang): array
    {
        if (!isset($lang['locale']) && !isset($lang['localeId'])) {
            $lang['localeId'] = $this->getLocaleIdOfSystemLanguage();
        }
        if (isset($lang['parent']) && !isset($lang['parent']['locale']$lang['parent']['localeId'])) {
            $lang['parent']['localeId'] = $this->getLocaleIdOfSystemLanguage();
        }

        return $lang;
    }

    protected function addDefaultTranslationCodes(array $languages)
    {
        return array_map(fn ($lang) => $this->addDefaultTranslationCode($lang)$languages);
    }

    public function testVariation(array $product, array $expected, array $languageChain, Criteria $criteria, bool $sort, string $languageId): void
    {
        $this->getContainer()
            ->get('language.repository')
            ->create([
                [
                    'id' => $languageId,
                    'name' => 'sub_en',
                    'parentId' => Defaults::LANGUAGE_SYSTEM,
                    'localeId' => $this->getLocaleIdOfSystemLanguage(),
                ],
            ], Context::createDefaultContext());

        foreach ($languageChain as &$language) {
            if ($language === 'de-DE') {
                $language = $this->getDeDeLanguageId();
            }
        }

        $productId = $product['id'];
        $context = Context::createDefaultContext();

        
'username' => self::TEST_USERNAME,
        ]);
    }

    private function createUser(): string
    {
        $uuid = Uuid::randomHex();

        $this->userRepository->create([
            [
                'id' => $uuid,
                'localeId' => $this->getLocaleIdOfSystemLanguage(),
                'username' => self::TEST_USERNAME,
                'password' => self::TEST_PASSWORD,
                'firstName' => sprintf('Foo%s', Uuid::randomHex()),
                'lastName' => sprintf('Bar%s', Uuid::randomHex()),
                'email' => sprintf('%s@foo.bar', $uuid),
            ],
        ]$this->context);

        return $uuid;
    }
}
static::assertEquals(100, $productStats['max']);
    }

    public function testParentChildLocation(): void
    {
        $childId = Uuid::randomHex();
        $parentId = Uuid::randomHex();

        $data = [
            'id' => $childId,
            'name' => 'Child Language',
            'localeId' => $this->getLocaleIdOfSystemLanguage(),
            'parent' => [
                'id' => $parentId,
                'name' => 'Parent Language',
                'locale' => [
                    'code' => 'x-tst_' . Uuid::randomHex(),
                    'name' => 'test name',
                    'territory' => 'test territory',
                ],
                'translationCode' => [
                    'code' => 'x-tst_' . Uuid::randomHex(),
                    'name' => 'test name',
                    

        return $this->getContainer();
    }

    protected function runWorker(): void
    {
    }

    private function getValidLocaleId(): string
    {
        $criteria = new Criteria();
        $criteria->addFilter(new NandFilter([new EqualsFilter('id', $this->getLocaleIdOfSystemLanguage())]));
        $criteria->setLimit(1);

        $localeId = $this->getContainer()->get(\sprintf('%s.repository', LocaleDefinition::ENTITY_NAME))->searchIds($criteria, Context::createDefaultContext())->firstId();
        static::assertNotNull($localeId);

        return $localeId;
    }
}
private function createLanguage(?string $parentId = null): string
    {
        $id = Uuid::randomHex();

        $languageRepository = $this->getContainer()->get('language.repository');

        $languageRepository->create(
            [
                [
                    'id' => $id,
                    'name' => sprintf('name-%s', $id),
                    'localeId' => $this->getLocaleIdOfSystemLanguage(),
                    'parentId' => $parentId,
                    'translationCode' => [
                        'code' => Uuid::randomHex(),
                        'name' => 'Test locale',
                        'territory' => 'test',
                    ],
                    'salesChannels' => [
                        ['id' => TestDefaults::SALES_CHANNEL],
                    ],
                    'salesChannelDefaultAssignments' => [
                        ['id' => TestDefaults::SALES_CHANNEL],
                    ],
/** * @return array<string, array<string, mixed>> */
    protected function prepareUsers(int $num = 1): array
    {
        $data = [];
        for ($i = 1; $i <= $num; ++$i) {
            $uuid = Uuid::randomHex();

            $data[Uuid::fromHexToBytes($uuid)] = [
                'id' => $uuid,
                'localeId' => $this->getLocaleIdOfSystemLanguage(),
                'username' => sprintf('foobar%d', $i),
                'password' => TestDefaults::HASHED_PASSWORD,
                'firstName' => sprintf('Foo%d', $i),
                'lastName' => sprintf('Bar%d', $i),
                'email' => sprintf('fo%d@ob.ar', $i),
            ];
        }
        $this->userRepository->create(array_values($data)$this->context);

        return $data;
    }

    
Home | Imprint | This part of the site doesn't use cookies.