added test for staticClassLoader in LazyLoadingMetadatafactory
This commit is contained in:
parent
d3673a83ae
commit
a266ff799c
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
|
||||||
|
class EntityStaticCar extends EntityStaticVehicle
|
||||||
|
{
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata)
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('wheels', new Length(array('max' => 99)));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
|
||||||
|
class EntityStaticCarTurbo extends EntityStaticCar
|
||||||
|
{
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata)
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('wheels', new Length(array('max' => 99)));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
|
use Symfony\Component\Validator\Constraints\Length;
|
||||||
|
|
||||||
|
class EntityStaticVehicle
|
||||||
|
{
|
||||||
|
public $wheels;
|
||||||
|
|
||||||
|
public static function loadValidatorMetadata(ClassMetadata $metadata)
|
||||||
|
{
|
||||||
|
$metadata->addPropertyConstraint('wheels', new Length(array('max' => 99)));
|
||||||
|
}
|
||||||
|
}
|
@ -168,6 +168,21 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
|
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGroupsFromParent()
|
||||||
|
{
|
||||||
|
$reader = new \Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader();
|
||||||
|
$factory = new LazyLoadingMetadataFactory($reader);
|
||||||
|
$metadata = $factory->getMetadataFor('Symfony\Component\Validator\Tests\Fixtures\EntityStaticCarTurbo');
|
||||||
|
$classMetaData = $metadata->getPropertyMetadata('wheels');
|
||||||
|
$constraints = $classMetaData[0]->getConstraints();
|
||||||
|
$groups = $constraints[0]->groups;
|
||||||
|
|
||||||
|
$this->assertContains('Default', $groups);
|
||||||
|
$this->assertContains('EntityStaticCarTurbo', $groups);
|
||||||
|
$this->assertContains('EntityStaticCar', $groups);
|
||||||
|
$this->assertContains('EntityStaticVehicle', $groups);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestLoader implements LoaderInterface
|
class TestLoader implements LoaderInterface
|
||||||
|
Reference in New Issue
Block a user