Skip to content

Commit

Permalink
(2.5) ElementMetadata is deprecated in favor of ElementMetadata
Browse files Browse the repository at this point in the history
Sf <2.5 compatibility is taken care of
  • Loading branch information
wouterj committed Feb 27, 2015
1 parent 2090cc8 commit 190dc4e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Tests/Command/ExplainAdminCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 190dc4e

Please sign in to comment.