Locale example



namespace Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\Hydrator;

use Shopware\Bundle\StoreFrontBundle\Struct\Locale;

class LocaleHydrator extends Hydrator
{
    public function hydrate($data)
    {
        $locale = new Locale();
        $locale->setId((int) $data['__locale_id']);
        $locale->setLocale($data['__locale_locale']);
        $locale->setLanguage($data['__locale_language']);
        $locale->setTerritory($data['__locale_territory']);

        return $locale;
    }
}
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class LocaleValidatorTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): LocaleValidator
    {
        return new LocaleValidator();
    }

    public function testNullIsValid()
    {
        $this->validator->validate(null, new Locale());

        $this->assertNoViolation();
    }

    public function testEmptyStringIsValid()
    {
        $this->validator->validate('', new Locale());

        $this->assertNoViolation();
    }

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