PropertyMetadataTest.php 888 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Symfony\Tests\Components\Validator\Mapping;
  3. require_once __DIR__.'/../../../../../bootstrap.php';
  4. require_once __DIR__.'/../Fixtures/Entity.php';
  5. use Symfony\Components\Validator\Mapping\PropertyMetadata;
  6. use Symfony\Tests\Components\Validator\Fixtures\Entity;
  7. class PropertyMetadataTest extends \PHPUnit_Framework_TestCase
  8. {
  9. const CLASSNAME = 'Symfony\Tests\Components\Validator\Fixtures\Entity';
  10. public function testInvalidPropertyName()
  11. {
  12. $this->setExpectedException('Symfony\Components\Validator\Exception\ValidatorException');
  13. new PropertyMetadata(self::CLASSNAME, 'foobar');
  14. }
  15. public function testGetValueFromPrivateProperty()
  16. {
  17. $entity = new Entity('foobar');
  18. $metadata = new PropertyMetadata(self::CLASSNAME, 'internal');
  19. $this->assertEquals('foobar', $metadata->getValue($entity));
  20. }
  21. }