From 190dc4e8c58338bb5d4a69e1d1119eabd7c233a5 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Thu, 26 Feb 2015 18:24:59 +0100 Subject: [PATCH] (2.5) ElementMetadata is deprecated in favor of ElementMetadata Sf <2.5 compatibility is taken care of --- Tests/Command/ExplainAdminCommandTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Tests/Command/ExplainAdminCommandTest.php b/Tests/Command/ExplainAdminCommandTest.php index c88fad5441..23c67fa7a3 100644 --- a/Tests/Command/ExplainAdminCommandTest.php +++ b/Tests/Command/ExplainAdminCommandTest.php @@ -23,7 +23,6 @@ use Sonata\AdminBundle\Builder\ListBuilderInterface; use Symfony\Component\Form\FormBuilder; use Sonata\AdminBundle\Admin\FieldDescriptionInterface; -use Symfony\Component\Validator\Mapping\ElementMetadata; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Email; @@ -171,11 +170,18 @@ public function testExecute() ->with($this->equalTo('Acme\Entity\Foo')) ->will($this->returnValue($metadata)); - $propertyMetadata = $this->getMockForAbstractClass('Symfony\Component\Validator\Mapping\ElementMetadata'); + if (class_exists('Symfony\Component\Validator\Mapping\GenericMetadata')) { + $class = 'GenericMetadata'; + } else { + // Symfony <2.5 compatibility + $class = 'ElementMetadata'; + } + + $propertyMetadata = $this->getMockForAbstractClass('Symfony\Component\Validator\Mapping\\'.$class); $propertyMetadata->constraints = array(new NotNull(), new Length(array('min' => 2, 'max' => 50, 'groups' => array('create', 'edit'),))); $metadata->properties = array('firstName' => $propertyMetadata); - $getterMetadata = $this->getMockForAbstractClass('Symfony\Component\Validator\Mapping\ElementMetadata'); + $getterMetadata = $this->getMockForAbstractClass('Symfony\Component\Validator\Mapping\\'.$class); $getterMetadata->constraints = array(new NotNull(), new Email(array('groups' => array('registration', 'edit'),))); $metadata->getters = array('email' => $getterMetadata);