Example #1
0
 /**
  * Expect that the field mapping can get the correct name for the array. If the {@link Field} annotation
  * provides a alias then we should use that instead.
  *
  * @test
  */
 public function validateFieldMappingUnderstandsName()
 {
     $annotations = new ArrayCollection();
     $builder = $this->getMockBuilder(ReflectionProperty::class);
     $builder->disableOriginalConstructor();
     $builder->setMethods(['getName']);
     /** @var MockObject|ReflectionProperty $property */
     $property = $builder->getMock();
     $property->expects($this->any())->method('getName')->willReturn('property');
     $annotations->add($field = new Field());
     $field->setReflector($property);
     $parser = new AnnotationParser(new AnnotationReader());
     $mapping = $parser->processFieldAnnotations($property, $annotations);
     $this->assertEquals($property->getName(), $mapping->getName());
     $field->name = 'property-edit';
     $mapping = $parser->processFieldAnnotations($property, $annotations);
     $this->assertEquals($field->name, $mapping->getName());
 }