LocaleEntity example



    /** * @param array<int, array{id: string, code: string}> $locales */
    private function getLocaleRepository(array $locales = []): EntityRepository
    {
        $repository = $this->createMock(EntityRepository::class);

        $localeEntities = [];
        foreach ($locales as $locale) {
            $localeEntity = new LocaleEntity();
            $localeEntity->assign($locale);

            $localeEntities[] = $localeEntity;
        }

        $collection = new LocaleCollection($localeEntities);
        $entitySearchResult = new EntitySearchResult(
            LocaleDefinition::ENTITY_NAME,
            $collection->count(),
            $collection,
            null,
            
$entities[] = $languageEntity;
        }

        return new LanguageCollection($entities);
    }

    /** * @param array<string, mixed> $data */
    private function getLocaleEntity(array $data = []): LocaleEntity
    {
        $localeEntity = new LocaleEntity();

        $localeEntity->assign($data);

        return $localeEntity;
    }

    /** * @param array<int, array<int, array<string, mixed>>> $appEntities * * @return StaticEntityRepository<AppCollection> */
    
'en-GB',
            $provider->getLocaleFromContext(Context::createDefaultContext(
                new AdminApiSource(null, 'i-am-an-integration')
            ))
        );
    }

    public function testGetLocaleFromContextReturnsLocaleFromUser(): void
    {
        $context = Context::createDefaultContext(new AdminApiSource('user-id', null));

        $userLocale = new LocaleEntity();
        $userLocale->setCode('user-locale');

        $user = new UserEntity();
        $user->setUniqueIdentifier('user-identifier');
        $user->setLocale($userLocale);

        $userRepository = static::createMock(EntityRepository::class);
        $userRepository->expects(static::once())
            ->method('search')
            ->willReturn(new EntitySearchResult(
                UserDefinition::ENTITY_NAME,
                
Home | Imprint | This part of the site doesn't use cookies.