Currency example



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

use Shopware\Bundle\StoreFrontBundle\Struct\Currency;

class CurrencyHydrator extends Hydrator
{
    public function hydrate($data)
    {
        $currency = new Currency();
        $currency->setId((int) $data['__currency_id']);
        $currency->setName($data['__currency_name']);
        $currency->setFactor((float) $data['__currency_factor']);
        $currency->setCurrency($data['__currency_currency']);
        $currency->setSymbol($data['__currency_templatechar']);
        $currency->setSymbolPosition($data['__currency_symbol_position']);

        return $currency;
    }
}
\Locale::setDefault($this->defaultLocale);
    }

    protected function createValidator(): CurrencyValidator
    {
        return new CurrencyValidator();
    }

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

        $this->assertNoViolation();
    }

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

        $this->assertNoViolation();
    }

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