function it_checks_an_invalid_product_value_for_multiple_reference_data(ConfigurationInterface $configuration)
 {
     $this->beConstructedWith('spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomInvalidProductValue');
     $configuration->getType()->willReturn(ConfigurationInterface::TYPE_MULTI);
     $configuration->getName()->willReturn('fabrics');
     $this->check($configuration)->shouldReturn(false);
     $this->getFailure()->shouldReturn('Please implement the accessors "getFabrics, setFabrics, addFabric, removeFabric" for ' . '"spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomInvalidProductValue".');
 }
 function it_checks_an_invalid_many_to_many_relationship($classMetadata, ConfigurationInterface $configuration)
 {
     $classMetadata->getAssociationMapping('fabrics')->willReturn(['type' => ClassMetadataInfo::MANY_TO_MANY, 'isOwningSide' => false]);
     $configuration->getType()->willReturn(ConfigurationInterface::TYPE_MULTI);
     $configuration->getName()->willReturn('fabrics');
     $this->check($configuration)->shouldReturn(false);
     $this->getFailure()->shouldReturn('Please configure your "spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomValidProductValue" ' . 'relation "fabrics" correctly. You can take the relation "options" as example.');
 }
 function it_checks_an_invalid_many_to_many_relationship($classMetadata, ConfigurationInterface $configuration)
 {
     $classMetadata->getFieldMapping('fabrics')->willReturn(['type' => 'entities', 'isOwningSide' => false, 'idsField' => 'fabricIds']);
     $classMetadata->getFieldMapping('fabricIds')->willReturn(['type' => 'collection']);
     $configuration->getType()->willReturn(ConfigurationInterface::TYPE_MULTI);
     $configuration->getName()->willReturn('fabrics');
     $this->check($configuration)->shouldReturn(false);
     $this->getFailure()->shouldReturn('Please configure the type and the owning side correctly in your ' . '"spec\\Pim\\Bundle\\ReferenceDataBundle\\RequirementChecker\\CustomValidProductValue" "fabrics" relation. ' . 'You can take the relation "options" as example.');
 }
 /**
  * {@inheritdoc}
  */
 public function check(ConfigurationInterface $configuration)
 {
     try {
         $isFieldCollectionOk = true;
         $isFieldOk = $this->checkFieldMapping($configuration->getName(), $configuration->getType());
         if (ConfigurationInterface::TYPE_MULTI === $configuration->getType()) {
             $isFieldCollectionOk = $this->checkCollectionFieldMapping($configuration->getName());
         }
     } catch (\Exception $e) {
         $this->failure = $e->getMessage();
         return false;
     }
     if (!$isFieldOk || !$isFieldCollectionOk) {
         $relationExample = ConfigurationInterface::TYPE_MULTI === $configuration->getType() ? 'options' : 'option';
         $this->failure .= sprintf(' You can take the relation "%s" as example.', $relationExample);
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function check(ConfigurationInterface $configuration)
 {
     $reflection = new \ReflectionClass($this->productValueClass);
     foreach ($this->getRequiredAccessorForSimpleReferenceData($configuration->getName()) as $accessor) {
         if (!$reflection->hasMethod($accessor)) {
             $this->missingAccessors[] = $accessor;
         }
     }
     if (ConfigurationInterface::TYPE_MULTI === $configuration->getType()) {
         foreach ($this->getRequiredAccessorForMultipleReferenceData($configuration->getName()) as $accessor) {
             if (!$reflection->hasMethod($accessor)) {
                 $this->missingAccessors[] = $accessor;
             }
         }
     }
     if (0 !== count($this->missingAccessors)) {
         $this->failure = sprintf('Please implement the accessors "%s" for "%s".', implode(', ', $this->missingAccessors), $this->productValueClass);
         return false;
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function check(ConfigurationInterface $configuration)
 {
     try {
         $mapping = $this->getAssociationMapping($configuration->getName());
     } catch (\Exception $e) {
         $this->failure = $e->getMessage();
         return false;
     }
     if (ConfigurationInterface::TYPE_MULTI === $configuration->getType()) {
         $expectedType = ClassMetadataInfo::MANY_TO_MANY;
         $relationExample = 'options';
     } else {
         $expectedType = ClassMetadataInfo::MANY_TO_ONE;
         $relationExample = 'option';
     }
     if ($mapping['type'] !== $expectedType || true !== $mapping['isOwningSide']) {
         $this->failure = sprintf('Please configure your "%s" relation "%s" correctly. ' . 'You can take the relation "%s" as example.', $this->productValueClass, $configuration->getName(), $relationExample);
         return false;
     }
     return true;
 }