* * 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\Validator\Constraints\IdenticalTo; use Symfony\Component\Validator\Constraints\IdenticalToValidator; /** * @author Daniel Holmes */ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase { protected function createValidator() { return new IdenticalToValidator(); } protected function createConstraint(array $options = null) { return new IdenticalTo($options); } protected function getErrorCode() { return IdenticalTo::NOT_IDENTICAL_ERROR; } public function provideAllValidComparisons() { $this->setDefaultTimezone('UTC'); // Don't call addPhp5Dot5Comparisons() automatically, as it does // not take care of identical objects $comparisons = $this->provideValidComparisons(); $this->restoreDefaultTimezone(); return $comparisons; } /** * {@inheritdoc} */ public function provideValidComparisons() { $date = new \DateTime('2000-01-01'); $object = new ComparisonTest_Class(2); $comparisons = array( array(3, 3), array('a', 'a'), array($date, $date), array($object, $object), array(null, 1), ); $immutableDate = new \DateTimeImmutable('2000-01-01'); $comparisons[] = array($immutableDate, $immutableDate); return $comparisons; } /** * {@inheritdoc} */ public function provideValidComparisonsToPropertyPath() { return array( array(5), ); } /** * {@inheritdoc} */ public function provideInvalidComparisons() { return array( array(1, '1', 2, '2', 'integer'), array(2, '2', '2', '"2"', 'string'), array('22', '"22"', '333', '"333"', 'string'), array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'), array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999, 12:00 AM', 'DateTime'), array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), ); } } __halt_compiler();----SIGNATURE:----aniYcdobwZIEsnZJwovbYEHs+y65+R+LAtKLdB99J+pFBumAEjXJEPfyWQltpM4tr2bxN29rMPtqRA2mTARjPD3Hqkhey2qPZJFZ/f5tgD8F2pgg6vtDCCZyQGyQpKUmXezTLowCnVgZQ85pe9aBF/iN77zu4RToA0dqadISylEENvCx+cdP8CsV4w4jHTJ61uu2yIZkWf93N/66Bt6QgqxnTlk6vhABWPbukj4SkPajj9g8OIwosmyWF9OprnRfjqfOawy+7yhp59bul7llN/0UEZObSvln2FU+yn6bP3G/cWQ2MNgUBOZpv7vo4fHOMJoGjL28iMfNNkLhYOcRwPtvkn5eMo9hngpyp4DctYGyTVQ0wYvyIp8VJhcmLk6dr33jkyI02USRh/cD7hrM2bFCASNV6boZ6SyBaE8SKmYGWkPh55tG/CyUnOzV+M6MRgXPJblbdaqQIB7fOrjUWA0OBeXiaWjRuQQ1Mdw1T0v15Yfe39jksPLgchOEYuEsHMiwBEsLBKhQErACc1Hu4guW0eHwYeirH3smAvYgXCbP9/RmxiKXLzzbqRZbBMs6K4VprLYYXx4eI+rwyk125lfsRmDc6QNpokZyKb4Lb22PzCBcz+0o6yFfgWqxmAzGPv2oN9+DDXlVmdCbTp2iWWCnQmGj2RgDJS9Az9v7KlA=----ATTACHMENT:----OTExNDY2NDk5MzUxMzI5OSA2NjU0NDg2NzI0MTIwNzMwIDc5NjQ1MTcyNzAwODI0Nzc=