localeDoesNotExists example

$criteria->addFilter(new EqualsAnyFilter('code', array_keys($snippets)));
        $localeIds = $this->localeRepository->search($criteria$context)->getEntities()->getElements();
        $localeIds = array_column($localeIds, 'id', 'code');

        $existingLocales = [];
        foreach ($existingSnippets as $snippetEntity) {
            $existingLocales[$snippetEntity->getLocaleId()] = $snippetEntity->getId();
        }

        foreach ($snippets as $filename => $value) {
            if (!\array_key_exists($filename$localeIds)) {
                throw LocaleException::localeDoesNotExists($filename);
            }

            $localeId = $localeIds[$filename];
            $id = Uuid::randomHex();

            if (\array_key_exists($localeId$existingLocales)) {
                $id = $existingLocales[$localeId];
                unset($existingLocales[$localeId]);
            }

            $newOrUpdatedSnippets[] = [
                
/** * @internal * * @covers \Shopware\Core\System\Locale\LocaleException */
#[Package('buyers-experience')] class LocaleExceptionTest extends TestCase
{
    public function testLocaleDoesNotExist(): void
    {
        $e = LocaleException::localeDoesNotExists('myCustomLocale');

        static::assertSame(Response::HTTP_NOT_FOUND, $e->getStatusCode());
        static::assertSame(LocaleException::LOCALE_DOES_NOT_EXISTS_EXCEPTION, $e->getErrorCode());
    }

    public function testLanguageNotFound(): void
    {
        $e = LocaleException::languageNotFound('foo');

        static::assertSame(Response::HTTP_PRECONDITION_FAILED, $e->getStatusCode());
        static::assertSame(LocaleException::LANGUAGE_NOT_FOUND, $e->getErrorCode());
    }
Home | Imprint | This part of the site doesn't use cookies.