Exemplo n.º 1
0
 protected function setUp()
 {
     IntlTestHelper::requireIntl($this);
     $this->context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContext', array(), array(), '', false);
     $this->validator = new CurrencyValidator();
     $this->validator->initialize($this->context);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider buildFormProvider
  *
  * @param array  $configData
  * @param string $defaultLang
  * @param array  $choicesKeysExpected
  */
 public function testBuildForm(array $configData, $defaultLang, array $choicesKeysExpected)
 {
     IntlTestHelper::requireIntl($this);
     \Locale::setDefault($defaultLang);
     $this->cmMock->expects($this->at(0))->method('get')->with($this->equalTo(LanguageType::CONFIG_KEY), $this->equalTo(true))->will($this->returnValue($defaultLang));
     $this->cmMock->expects($this->at(1))->method('get')->with($this->equalTo(TranslationStatusInterface::CONFIG_KEY))->will($this->returnValue($configData));
     $form = $this->factory->create($this->formType);
     $choices = $form->getConfig()->getOption('choices');
     $this->assertEquals($choicesKeysExpected, array_keys($choices));
 }
 /**
  * @dataProvider provideInvalidComparisons
  * @param mixed  $dirtyValue
  * @param mixed  $dirtyValueAsString
  * @param mixed  $comparedValue
  * @param mixed  $comparedValueString
  * @param string $comparedValueType
  */
 public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     if ($dirtyValue instanceof \DateTime) {
         IntlTestHelper::requireIntl($this);
     }
     $constraint = $this->createConstraint(array('value' => $comparedValue));
     $constraint->message = 'Constraint Message';
     $this->validator->validate($dirtyValue, $constraint);
     $this->assertViolation('Constraint Message', array('{{ value }}' => $dirtyValueAsString, '{{ compared_value }}' => $comparedValueString, '{{ compared_value_type }}' => $comparedValueType));
 }
 /**
  * @dataProvider provideInvalidComparisons
  *
  * @param mixed  $dirtyValue
  * @param mixed  $dirtyValueAsString
  * @param mixed  $comparedValue
  * @param mixed  $comparedValueString
  * @param string $comparedValueType
  */
 public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     if ($dirtyValue instanceof \DateTime) {
         IntlTestHelper::requireIntl($this);
         if (PHP_VERSION_ID < 50304 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
             $this->markTestSkipped('Intl supports formatting DateTime objects since 5.3.4');
         }
     }
     $constraint = $this->createConstraint(array('value' => $comparedValue));
     $constraint->message = 'Constraint Message';
     $this->validator->validate($dirtyValue, $constraint);
     $this->buildViolation('Constraint Message')->setParameter('{{ value }}', $dirtyValueAsString)->setParameter('{{ compared_value }}', $comparedValueString)->setParameter('{{ compared_value_type }}', $comparedValueType)->assertRaised();
 }
Exemplo n.º 5
0
 /**
  * @dataProvider getSoonerThanTenthMarch2014
  */
 public function testInvalidDatesCombinedMin($value, $dateTimeAsString)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     IntlTestHelper::requireIntl($this);
     $constraint = new Range(array('min' => 'March 10, 2014', 'max' => 'March 20, 2014', 'minMessage' => 'myMinMessage', 'maxMessage' => 'myMaxMessage'));
     $this->validator->validate($value, $constraint);
     $this->buildViolation('myMinMessage')->setParameter('{{ value }}', $dateTimeAsString)->setParameter('{{ limit }}', 'Mar 10, 2014, 12:00 AM')->setCode(Range::BELOW_RANGE_ERROR)->assertRaised();
 }
Exemplo n.º 6
0
 protected function setUp()
 {
     IntlTestHelper::requireIntl($this);
     parent::setUp();
 }
 /**
  * @dataProvider countryChoiceChoicesProvider
  */
 public function testCountryChoiceChoices(array $choices, $expectedChoicesCount, array $expectedChoices)
 {
     IntlTestHelper::requireIntl($this);
     if (method_exists('Symfony\\Component\\Form\\FormTypeInterface', 'getName')) {
         $type = new PhoneNumberType();
     } else {
         $type = 'Misd\\PhoneNumberBundle\\Form\\Type\\PhoneNumberType';
     }
     $form = $this->factory->create($type, null, array('widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE, 'country_choices' => $choices));
     $view = $form->createView();
     $choices = $view['country']->vars['choices'];
     $this->assertCount($expectedChoicesCount, $choices);
     foreach ($expectedChoices as $expectedChoice) {
         $this->assertContains($expectedChoice, $choices, '', false, false);
     }
 }
Exemplo n.º 8
0
 protected function setUp()
 {
     // Locale extends \Locale, so intl must be present
     IntlTestHelper::requireIntl($this);
 }
Exemplo n.º 9
0
 protected function setUp()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     // Locale extends \Locale, so intl must be present
     IntlTestHelper::requireIntl($this);
 }
Exemplo n.º 10
0
 /**
  * @dataProvider getSoonerThanTenthMarch2014
  */
 public function testInvalidDatesCombinedMin($value)
 {
     // Conversion of dates to string differs between ICU versions
     // Make sure we have the correct version loaded
     IntlTestHelper::requireIntl($this);
     $constraint = new Range(array('min' => 'March 10, 2014', 'max' => 'March 20, 2014', 'minMessage' => 'myMinMessage', 'maxMessage' => 'myMaxMessage'));
     $this->validator->validate($value, $constraint);
     $this->assertViolation('myMinMessage', array('{{ value }}' => $value, '{{ limit }}' => 'Mar 10, 2014, 12:00 AM'));
 }
Exemplo n.º 11
0
 protected function setUp()
 {
     IntlTestHelper::requireIntl($this);
     parent::setUp();
     $this->defaultTimezone = date_default_timezone_get();
 }