function it_get_the_labels_of_multiple_values($repository, $renderer, ReferenceDataInterface $referenceData1, ReferenceDataInterface $referenceData2)
 {
     $this->beConstructedWith($repository, $renderer, ['multiple' => true]);
     $referenceData1->getId()->willReturn(13);
     $renderer->render($referenceData1)->willReturn('[Good luck]');
     $referenceData2->getId()->willReturn(456);
     $renderer->render($referenceData2)->willReturn('[Random label]');
     $this->getOptions([$referenceData1, $referenceData2])->shouldReturn([['id' => 13, 'text' => '[Good luck]'], ['id' => 456, 'text' => '[Random label]']]);
 }
 /**
  * @param ReferenceDataInterface $referenceData
  * @param bool                   $fallbackOnCode
  *
  * @return string|null
  */
 public function render(ReferenceDataInterface $referenceData, $fallbackOnCode = true)
 {
     if (null !== ($labelProperty = $referenceData::getLabelProperty())) {
         $getter = MethodNameGuesser::guess('get', $labelProperty);
         $label = $referenceData->{$getter}();
         if (!empty($label)) {
             return $label;
         }
     }
     if ($fallbackOnCode) {
         return sprintf('[%s]', $referenceData->getCode());
     }
     return null;
 }
 function it_normalizes_a_reference_data_model(ReferenceDataInterface $starship)
 {
     $starship->getCode()->willReturn('battlecruiser');
     $this->normalize($starship, 'xml', [])->shouldReturn(['code' => 'battlecruiser']);
     $this->normalize($starship, 'json', [])->shouldReturn(['code' => 'battlecruiser']);
 }
 function it_normalizes_reference_data_using_the_default_format(ReferenceDataInterface $referenceData)
 {
     $referenceData->getCode()->willReturn('my_code');
     $this->normalize($referenceData, null, ['field_name' => 'color'])->shouldReturn(['color' => 'my_code']);
 }
 function it_normalizes_a_reference_data_into_mongodb_document(ReferenceDataInterface $refData)
 {
     $refData->getId()->willReturn('ref_id');
     $this->normalize($refData, 'mongodb_document')->shouldReturn('ref_id');
 }