* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Currency; use Symfony\Component\Validator\Constraints\CurrencyValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class CurrencyValidatorTest extends ConstraintValidatorTestCase { protected function createValidator() { return new CurrencyValidator(); } public function testNullIsValid() { $this->validator->validate(null, new Currency()); $this->assertNoViolation(); } public function testEmptyStringIsValid() { $this->validator->validate('', new Currency()); $this->assertNoViolation(); } /** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException */ public function testExpectsStringCompatibleType() { $this->validator->validate(new \stdClass(), new Currency()); } /** * @dataProvider getValidCurrencies */ public function testValidCurrencies($currency) { $this->validator->validate($currency, new Currency()); $this->assertNoViolation(); } /** * @dataProvider getValidCurrencies **/ public function testValidCurrenciesWithCountrySpecificLocale($currency) { IntlTestHelper::requireFullIntl($this, false); \Locale::setDefault('en_GB'); $this->validator->validate($currency, new Currency()); $this->assertNoViolation(); } public function getValidCurrencies() { return array( array('EUR'), array('USD'), array('SIT'), array('AUD'), array('CAD'), ); } /** * @dataProvider getInvalidCurrencies */ public function testInvalidCurrencies($currency) { $constraint = new Currency(array( 'message' => 'myMessage', )); $this->validator->validate($currency, $constraint); $this->buildViolation('myMessage') ->setParameter('{{ value }}', '"'.$currency.'"') ->setCode(Currency::NO_SUCH_CURRENCY_ERROR) ->assertRaised(); } public function getInvalidCurrencies() { return array( array('EN'), array('foobar'), ); } } __halt_compiler();----SIGNATURE:----J+9zbvwsGVgO1H30KUhVROLMptKqMet72zMISotKo6B55xOJXhG0fNvxnSqt0pmcrKHN7g84Fu8mthnbaoS+bsdxcXputLyQbFtjKT07UDpp9I6M9h6kMiyIq5ddxgvLHq6HA/nUimLjjJxvfbe5tYsOOYccHiiYYWhjNmEpJNdXaw6tqXHh7dxFn9oULanVPN0QjvqC3awRdaxFXJKXtUD/2MFQurgGJe8ly+uiexTVT1pAIRdd19RJThi9X5li9HPCaNuxoyVpwgqdrQ0hjD5ZrNKsmPZueAS5uTROgBAxwfQZBWLmUcvpI3EC9/cMYQ8VXRQHp2tcXL+HgE9JQdSkSf18QUUhWg/YO8pG7oOVzOuRZYR3ZsxNuyAHkJ75I0oGJZ9EO9is7SbTIi4UEEAnpRMl0kNFUf+dnzqQfK+Pt/vo3Jj50s2ZKn4iH+0gp8tsQm+13jaerkrTAs33LlvOkygLy/qcr6VSqvRzRq3cwhLVlA/W7mcvV6v8+eS/vpvR6MPvjDSwz3O9QF4JaLTnhsaJQpRfiC3/GnLT+AICj+hq/JR3jjQahzJ0UrQ9ujMB/fT8OEtMw2W094sypr5AD6ddDOb9cWYZNtUtT9pCyuqRTGuOU4U6pLnU0eygMpnm+pOve3clvsZA/5hwNAOI4Yig63H11O9vUuLrtPM=----ATTACHMENT:----MTM5Njc2MTk2NjQzNjA3MiA4Njc4MTQ2ODc2MzczMTQyIDIyNjU1MDU3NzQ4NjM0ODM=