function it_fails_if_the_locale_is_not_valid($context, $channelManager, AbstractProductProcessor $value, HasValidDefaultLocale $constraint, Channel $channel, Locale $locale)
 {
     $value->getChannel()->willReturn('channel');
     $channelManager->getChannelByCode(Argument::any())->willReturn($channel);
     $channel->getLocales()->willReturn([$locale]);
     $locale->getCode()->willReturn('fr_FR');
     $value->getDefaultLocale()->willReturn('us_US');
     $constraint->message = 'The given default locale is not valid (check that the selected locale is in channel\'s locales)';
     $context->addViolationAt('defaultLocale', 'The given default locale is not valid (check that the selected locale is in channel\'s locales)', ['defaultLocale'])->shouldBeCalled();
     $this->validate($value, $constraint);
 }
 /**
  * Checks if the passed value is valid.
  *
  * @param AbstractProductProcessor $value      The value that should be validated
  * @param Constraint               $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$value instanceof AbstractProductProcessor) {
         return null;
     }
     if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) {
         foreach ($channel->getLocales() as $locale) {
             if ($locale->getCode() === $value->getDefaultLocale()) {
                 return null;
             }
         }
     }
     $this->context->addViolationAt('defaultLocale', $constraint->message, ['defaultLocale']);
 }