PropertyMetadataTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Validator\Mapping;
  11. require_once __DIR__.'/../Fixtures/Entity.php';
  12. use Symfony\Component\Validator\Mapping\PropertyMetadata;
  13. use Symfony\Tests\Component\Validator\Fixtures\Entity;
  14. class PropertyMetadataTest extends \PHPUnit_Framework_TestCase
  15. {
  16. const CLASSNAME = 'Symfony\Tests\Component\Validator\Fixtures\Entity';
  17. public function testInvalidPropertyName()
  18. {
  19. $this->setExpectedException('Symfony\Component\Validator\Exception\ValidatorException');
  20. new PropertyMetadata(self::CLASSNAME, 'foobar');
  21. }
  22. public function testGetValueFromPrivateProperty()
  23. {
  24. $entity = new Entity('foobar');
  25. $metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
  26. $this->assertEquals('foobar', $metadata->getValue($entity));
  27. }
  28. }