Changeset 32423
- Timestamp:
- 03/30/11 23:30:07 (2 years ago)
- Files:
-
- branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Validator/Constraints/Unique.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraint.php (modified) (8 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/All.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Blank.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Callback.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Choice.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Collection.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Country.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Date.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/DateTime.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Email.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/False.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/File.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Ip.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Language.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Locale.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Max.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/MaxLength.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Min.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/MinLength.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/NotBlank.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/NotNull.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Null.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Regex.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Time.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/True.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Type.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Url.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Constraints/Valid.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/ClassMetadata.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/Mapping/MemberMetadata.php (modified) (1 diff)
- branches/2.0/src/Symfony/Component/Validator/ValidatorContext.php (modified) (2 diffs)
- branches/2.0/src/Symfony/Component/Validator/ValidatorContextInterface.php (modified) (3 diffs)
- branches/2.0/src/Symfony/Component/Validator/ValidatorFactory.php (modified) (5 diffs)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ClassConstraint.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintA.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintB.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintC.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/FailingConstraint.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/PropertyConstraint.php (modified) (1 diff)
- branches/2.0/tests/Symfony/Tests/Component/Validator/ValidatorContextTest.php (modified) (3 diffs)
- branches/2.0/tests/Symfony/Tests/Component/Validator/ValidatorFactoryTest.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.0/src/Symfony/Bundle/DoctrineMongoDBBundle/Validator/Constraints/Unique.php
r32184 r32423 25 25 public $documentManager; 26 26 27 public function defaultOption()27 public function getDefaultOption() 28 28 { 29 29 return 'path'; 30 30 } 31 31 32 public function requiredOptions()32 public function getRequiredOptions() 33 33 { 34 34 return array('path'); … … 40 40 } 41 41 42 public function targets()42 public function getTargets() 43 43 { 44 44 return Constraint::CLASS_CONSTRAINT; branches/2.0/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml
r32184 r32423 15 15 <parameter key="validator.mapping.loader.xml_files_loader.class">Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader</parameter> 16 16 <parameter key="validator.mapping.loader.yaml_files_loader.class">Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader</parameter> 17 <parameter key="validator.mapping.loader.static_method_loader.method_name">loadValidatorMetadata</parameter>18 17 <parameter key="validator.validator_factory.class">Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory</parameter> 19 18 <parameter key="validator.annotations.namespaces" type="collection"> … … 45 44 </service> 46 45 47 <service id="validator.mapping.loader.static_method_loader" class="%validator.mapping.loader.static_method_loader.class%" public="false"> 48 <argument>%validator.mapping.loader.static_method_loader.method_name%</argument> 49 </service> 46 <service id="validator.mapping.loader.static_method_loader" class="%validator.mapping.loader.static_method_loader.class%" public="false" /> 50 47 51 48 </services> branches/2.0/src/Symfony/Component/Validator/Constraint.php
r32184 r32423 59 59 * properties. 60 60 * 61 * Alternatively you can override the method defaultOption() to return the61 * Alternatively you can override the method getDefaultOption() to return the 62 62 * name of an existing property. If no associative array is passed, this 63 63 * property is set instead. 64 64 * 65 65 * You can force that certain options are set by overriding 66 * requiredOptions() to return the names of these options. If any66 * getRequiredOptions() to return the names of these options. If any 67 67 * option is not set here, an exception is thrown. 68 68 * … … 74 74 * options 75 75 * @throws MissingOptionsException When you don't pass any of the options 76 * returned by requiredOptions()76 * returned by getRequiredOptions() 77 77 * @throws ConstraintDefinitionException When you don't pass an associative 78 * array, but defaultOption() returns78 * array, but getDefaultOption() returns 79 79 * NULL 80 80 */ … … 82 82 { 83 83 $invalidOptions = array(); 84 $missingOptions = array_flip((array)$this-> requiredOptions());84 $missingOptions = array_flip((array)$this->getRequiredOptions()); 85 85 86 86 if (is_array($options) && count($options) == 1 && isset($options['value'])) { … … 98 98 } 99 99 } else if (null !== $options && ! (is_array($options) && count($options) === 0)) { 100 $option = $this-> defaultOption();100 $option = $this->getDefaultOption(); 101 101 102 102 if (null === $option) { … … 159 159 * @see __construct() 160 160 */ 161 public function defaultOption()161 public function getDefaultOption() 162 162 { 163 163 return null; … … 172 172 * @see __construct() 173 173 */ 174 public function requiredOptions()174 public function getRequiredOptions() 175 175 { 176 176 return array(); … … 188 188 public function validatedBy() 189 189 { 190 return get_class($this) .'Validator';190 return get_class($this).'Validator'; 191 191 } 192 192 … … 200 200 * @return string|array One or more constant values 201 201 */ 202 abstract public function targets();202 abstract public function getTargets(); 203 203 } branches/2.0/src/Symfony/Component/Validator/Constraints/All.php
r32184 r32423 16 16 public $constraints = array(); 17 17 18 public function defaultOption()18 public function getDefaultOption() 19 19 { 20 20 return 'constraints'; 21 21 } 22 22 23 public function requiredOptions()23 public function getRequiredOptions() 24 24 { 25 25 return array('constraints'); … … 29 29 * {@inheritDoc} 30 30 */ 31 public function targets()31 public function getTargets() 32 32 { 33 33 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Blank.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Callback.php
r32369 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function requiredOptions()21 public function getRequiredOptions() 22 22 { 23 23 return array('methods'); … … 27 27 * {@inheritDoc} 28 28 */ 29 public function defaultOption()29 public function getDefaultOption() 30 30 { 31 31 return 'methods'; … … 35 35 * {@inheritDoc} 36 36 */ 37 public function targets()37 public function getTargets() 38 38 { 39 39 return self::CLASS_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Choice.php
r32184 r32423 26 26 * {@inheritDoc} 27 27 */ 28 public function defaultOption()28 public function getDefaultOption() 29 29 { 30 30 return 'choices'; … … 34 34 * {@inheritDoc} 35 35 */ 36 public function targets()36 public function getTargets() 37 37 { 38 38 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Collection.php
r32184 r32423 20 20 public $missingFieldsMessage = 'The fields {{ fields }} are missing'; 21 21 22 public function requiredOptions()22 public function getRequiredOptions() 23 23 { 24 24 return array('fields'); … … 28 28 * {@inheritDoc} 29 29 */ 30 public function targets()30 public function getTargets() 31 31 { 32 32 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Country.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Date.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/DateTime.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Email.php
r32184 r32423 20 20 * {@inheritDoc} 21 21 */ 22 public function targets()22 public function getTargets() 23 23 { 24 24 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/False.php
r32391 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/File.php
r32184 r32423 24 24 * {@inheritDoc} 25 25 */ 26 public function targets()26 public function getTargets() 27 27 { 28 28 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Ip.php
r32184 r32423 50 50 * {@inheritDoc} 51 51 */ 52 public function targets()52 public function getTargets() 53 53 { 54 54 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Language.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Locale.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Max.php
r32184 r32423 20 20 * {@inheritDoc} 21 21 */ 22 public function defaultOption()22 public function getDefaultOption() 23 23 { 24 24 return 'limit'; … … 28 28 * {@inheritDoc} 29 29 */ 30 public function requiredOptions()30 public function getRequiredOptions() 31 31 { 32 32 return array('limit'); … … 36 36 * {@inheritDoc} 37 37 */ 38 public function targets()38 public function getTargets() 39 39 { 40 40 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/MaxLength.php
r32184 r32423 21 21 * {@inheritDoc} 22 22 */ 23 public function defaultOption()23 public function getDefaultOption() 24 24 { 25 25 return 'limit'; … … 29 29 * {@inheritDoc} 30 30 */ 31 public function requiredOptions()31 public function getRequiredOptions() 32 32 { 33 33 return array('limit'); … … 37 37 * {@inheritDoc} 38 38 */ 39 public function targets()39 public function getTargets() 40 40 { 41 41 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Min.php
r32184 r32423 20 20 * {@inheritDoc} 21 21 */ 22 public function defaultOption()22 public function getDefaultOption() 23 23 { 24 24 return 'limit'; … … 28 28 * {@inheritDoc} 29 29 */ 30 public function requiredOptions()30 public function getRequiredOptions() 31 31 { 32 32 return array('limit'); … … 36 36 * {@inheritDoc} 37 37 */ 38 public function targets()38 public function getTargets() 39 39 { 40 40 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/MinLength.php
r32184 r32423 21 21 * {@inheritDoc} 22 22 */ 23 public function defaultOption()23 public function getDefaultOption() 24 24 { 25 25 return 'limit'; … … 29 29 * {@inheritDoc} 30 30 */ 31 public function requiredOptions()31 public function getRequiredOptions() 32 32 { 33 33 return array('limit'); … … 37 37 * {@inheritDoc} 38 38 */ 39 public function targets()39 public function getTargets() 40 40 { 41 41 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/NotBlank.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/NotNull.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Null.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Regex.php
r32184 r32423 21 21 * {@inheritDoc} 22 22 */ 23 public function defaultOption()23 public function getDefaultOption() 24 24 { 25 25 return 'pattern'; … … 29 29 * {@inheritDoc} 30 30 */ 31 public function requiredOptions()31 public function getRequiredOptions() 32 32 { 33 33 return array('pattern'); … … 37 37 * {@inheritDoc} 38 38 */ 39 public function targets()39 public function getTargets() 40 40 { 41 41 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Time.php
r32184 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/True.php
r32391 r32423 19 19 * {@inheritDoc} 20 20 */ 21 public function targets()21 public function getTargets() 22 22 { 23 23 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Type.php
r32391 r32423 20 20 * {@inheritDoc} 21 21 */ 22 public function defaultOption()22 public function getDefaultOption() 23 23 { 24 24 return 'type'; … … 28 28 * {@inheritDoc} 29 29 */ 30 public function requiredOptions()30 public function getRequiredOptions() 31 31 { 32 32 return array('type'); … … 36 36 * {@inheritDoc} 37 37 */ 38 public function targets()38 public function getTargets() 39 39 { 40 40 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Url.php
r32184 r32423 20 20 * {@inheritDoc} 21 21 */ 22 public function targets()22 public function getTargets() 23 23 { 24 24 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Constraints/Valid.php
r32184 r32423 21 21 * {@inheritDoc} 22 22 */ 23 public function targets()23 public function getTargets() 24 24 { 25 25 return self::PROPERTY_CONSTRAINT; branches/2.0/src/Symfony/Component/Validator/Mapping/ClassMetadata.php
r32184 r32423 97 97 public function addConstraint(Constraint $constraint) 98 98 { 99 if (!in_array(Constraint::CLASS_CONSTRAINT, (array)$constraint-> targets())) {99 if (!in_array(Constraint::CLASS_CONSTRAINT, (array)$constraint->getTargets())) { 100 100 throw new ConstraintDefinitionException(sprintf( 101 101 'The constraint %s cannot be put on classes', branches/2.0/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php
r32184 r32423 19 19 protected $methodName; 20 20 21 public function __construct($methodName )21 public function __construct($methodName = 'loadValidatorMetadata') 22 22 { 23 23 $this->methodName = $methodName; branches/2.0/src/Symfony/Component/Validator/Mapping/MemberMetadata.php
r32184 r32423 45 45 public function addConstraint(Constraint $constraint) 46 46 { 47 if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array)$constraint-> targets())) {47 if (!in_array(Constraint::PROPERTY_CONSTRAINT, (array)$constraint->getTargets())) { 48 48 throw new ConstraintDefinitionException(sprintf( 49 49 'The constraint %s cannot be put on properties or getters', branches/2.0/src/Symfony/Component/Validator/ValidatorContext.php
r32184 r32423 36 36 * @inheritDoc 37 37 */ 38 public function classMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory)38 public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory) 39 39 { 40 40 $this->classMetadataFactory = $classMetadataFactory; … … 46 46 * @inheritDoc 47 47 */ 48 public function constraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory)48 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory) 49 49 { 50 50 $this->constraintValidatorFactory = $constraintValidatorFactory; branches/2.0/src/Symfony/Component/Validator/ValidatorContextInterface.php
r32184 r32423 23 23 * <code> 24 24 * $validator = $context 25 * -> classMetadataFactory($customFactory)25 * ->setClassMetadataFactory($customFactory) 26 26 * ->getValidator(); 27 27 * </code> … … 36 36 * @param ClassMetadataFactoryInterface $classMetadataFactory The factory instance 37 37 */ 38 function classMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory);38 function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory); 39 39 40 40 /** … … 43 43 * @param ConstraintValidatorFactoryInterface $constraintValidatorFactory The factory instance 44 44 */ 45 function constraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory);45 function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory); 46 46 47 47 /** branches/2.0/src/Symfony/Component/Validator/ValidatorFactory.php
r32184 r32423 52 52 * <code> 53 53 * $defaultContext = new ValidatorContext(); 54 * $defaultContext-> classMetadataFactory($metadataFactory);55 * $defaultContext-> constraintValidatorFactory($validatorFactory);54 * $defaultContext->setClassMetadataFactory($metadataFactory); 55 * $defaultContext->setConstraintValidatorFactory($validatorFactory); 56 56 * $factory = new ValidatorFactory($defaultContext); 57 57 * … … 66 66 * <code> 67 67 * $form = $factory 68 * -> classMetadataFactory($customFactory);68 * ->setClassMetadataFactory($customFactory); 69 69 * ->getValidator(); 70 70 * </code> … … 144 144 } 145 145 146 $context-> classMetadataFactory(new ClassMetadataFactory($loader));147 $context-> constraintValidatorFactory(new ConstraintValidatorFactory());146 $context->setClassMetadataFactory(new ClassMetadataFactory($loader)); 147 $context->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 148 148 149 149 return new static($context); … … 167 167 * @return ValidatorContextInterface The preconfigured form context 168 168 */ 169 public function classMetadataFactory(ClassMetadataFactoryInterface $metadataFactory)169 public function setClassMetadataFactory(ClassMetadataFactoryInterface $metadataFactory) 170 170 { 171 171 $context = clone $this->defaultContext; 172 172 173 return $context-> classMetadataFactory($metadataFactory);173 return $context->setClassMetadataFactory($metadataFactory); 174 174 } 175 175 … … 181 181 * @return ValidatorContextInterface The preconfigured form context 182 182 */ 183 public function constraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory)183 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) 184 184 { 185 185 $context = clone $this->defaultContext; 186 186 187 return $context-> constraintValidatorFactory($validatorFactory);187 return $context->setConstraintValidatorFactory($validatorFactory); 188 188 } 189 189 branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ClassConstraint.php
r31885 r32423 7 7 class ClassConstraint extends Constraint 8 8 { 9 public function targets()9 public function getTargets() 10 10 { 11 11 return self::CLASS_CONSTRAINT; branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintA.php
r31885 r32423 10 10 public $property2; 11 11 12 public function defaultOption()12 public function getDefaultOption() 13 13 { 14 14 return 'property2'; 15 15 } 16 16 17 public function targets()17 public function getTargets() 18 18 { 19 19 return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintB.php
r31885 r32423 7 7 class ConstraintB extends Constraint { 8 8 9 public function targets()9 public function getTargets() 10 10 { 11 11 return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/ConstraintC.php
r31885 r32423 9 9 public $option1; 10 10 11 public function requiredOptions()11 public function getRequiredOptions() 12 12 { 13 13 return array('option1'); 14 14 } 15 15 16 public function targets()16 public function getTargets() 17 17 { 18 18 return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/FailingConstraint.php
r31885 r32423 9 9 public $message = ''; 10 10 11 public function targets()11 public function getTargets() 12 12 { 13 13 return array(self::PROPERTY_CONSTRAINT, self::CLASS_CONSTRAINT); branches/2.0/tests/Symfony/Tests/Component/Validator/Fixtures/PropertyConstraint.php
r31885 r32423 7 7 class PropertyConstraint extends Constraint 8 8 { 9 public function targets()9 public function getTargets() 10 10 { 11 11 return self::PROPERTY_CONSTRAINT; branches/2.0/tests/Symfony/Tests/Component/Validator/ValidatorContextTest.php
r32184 r32423 27 27 { 28 28 $factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); 29 $result = $this->context-> classMetadataFactory($factory);29 $result = $this->context->setClassMetadataFactory($factory); 30 30 31 31 $this->assertSame($this->context, $result); … … 36 36 { 37 37 $factory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); 38 $result = $this->context-> constraintValidatorFactory($factory);38 $result = $this->context->setConstraintValidatorFactory($factory); 39 39 40 40 $this->assertSame($this->context, $result); … … 48 48 49 49 $validator = $this->context 50 -> classMetadataFactory($metadataFactory)51 -> constraintValidatorFactory($validatorFactory)50 ->setClassMetadataFactory($metadataFactory) 51 ->setConstraintValidatorFactory($validatorFactory) 52 52 ->getValidator(); 53 53 branches/2.0/tests/Symfony/Tests/Component/Validator/ValidatorFactoryTest.php
r32184 r32423 39 39 $factory2 = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); 40 40 41 $this->defaultContext-> classMetadataFactory($factory1);41 $this->defaultContext->setClassMetadataFactory($factory1); 42 42 43 $result = $this->factory-> classMetadataFactory($factory2);43 $result = $this->factory->setClassMetadataFactory($factory2); 44 44 45 45 $this->assertSame($factory1, $this->defaultContext->getClassMetadataFactory()); … … 52 52 $factory2 = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); 53 53 54 $this->defaultContext-> constraintValidatorFactory($factory1);54 $this->defaultContext->setConstraintValidatorFactory($factory1); 55 55 56 $result = $this->factory-> constraintValidatorFactory($factory2);56 $result = $this->factory->setConstraintValidatorFactory($factory2); 57 57 58 58 $this->assertSame($factory1, $this->defaultContext->getConstraintValidatorFactory()); … … 66 66 67 67 $this->defaultContext 68 -> classMetadataFactory($metadataFactory)69 -> constraintValidatorFactory($validatorFactory);68 ->setClassMetadataFactory($metadataFactory) 69 ->setConstraintValidatorFactory($validatorFactory); 70 70 71 71 $validator = $this->factory->getValidator(); … … 83 83 $context = new ValidatorContext(); 84 84 $context 85 -> classMetadataFactory(new ClassMetadataFactory(new AnnotationLoader()))86 -> constraintValidatorFactory(new ConstraintValidatorFactory());85 ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader())) 86 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 87 87 88 88 $this->assertEquals(new ValidatorFactory($context), $factory); … … 100 100 $context = new ValidatorContext(); 101 101 $context 102 -> classMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(array(102 ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(array( 103 103 'myns' => 'My\\Namespace\\', 104 104 )))) 105 -> constraintValidatorFactory(new ConstraintValidatorFactory());105 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 106 106 107 107 $this->assertEquals(new ValidatorFactory($context), $factory); … … 115 115 $context = new ValidatorContext(); 116 116 $context 117 -> classMetadataFactory(new ClassMetadataFactory(new XmlFilesLoader(array($path))))118 -> constraintValidatorFactory(new ConstraintValidatorFactory());117 ->setClassMetadataFactory(new ClassMetadataFactory(new XmlFilesLoader(array($path)))) 118 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 119 119 120 120 $this->assertEquals(new ValidatorFactory($context), $factory); … … 128 128 $context = new ValidatorContext(); 129 129 $context 130 -> classMetadataFactory(new ClassMetadataFactory(new YamlFilesLoader(array($path))))131 -> constraintValidatorFactory(new ConstraintValidatorFactory());130 ->setClassMetadataFactory(new ClassMetadataFactory(new YamlFilesLoader(array($path)))) 131 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 132 132 133 133 $this->assertEquals(new ValidatorFactory($context), $factory); … … 141 141 $context = new ValidatorContext(); 142 142 $context 143 -> classMetadataFactory(new ClassMetadataFactory(new StaticMethodLoader('loadMetadata')))144 -> constraintValidatorFactory(new ConstraintValidatorFactory());143 ->setClassMetadataFactory(new ClassMetadataFactory(new StaticMethodLoader('loadMetadata'))) 144 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 145 145 146 146 $this->assertEquals(new ValidatorFactory($context), $factory); … … 165 165 $context = new ValidatorContext(); 166 166 $context 167 -> classMetadataFactory(new ClassMetadataFactory($chain))168 -> constraintValidatorFactory(new ConstraintValidatorFactory());167 ->setClassMetadataFactory(new ClassMetadataFactory($chain)) 168 ->setConstraintValidatorFactory(new ConstraintValidatorFactory()); 169 169 170 170 $this->assertEquals(new ValidatorFactory($context), $factory);