/**
  * @param StaticSegment $value
  * @param UniqueStaticSegmentNameConstraint|Constraint $constraint
  */
 public function validate($value, Constraint $constraint)
 {
     if ($value instanceof StaticSegment && !$value->getOriginId()) {
         $this->transport->init($value->getChannel()->getTransport());
         $segments = $this->transport->getListStaticSegments($value->getSubscribersList());
         foreach ($segments as $segment) {
             if ($segment['name'] == $value->getName()) {
                 $this->context->addViolationAt('name', $constraint->message);
                 break;
             }
         }
     }
 }
 /**
  * @expectedException \OroCRM\Bundle\MailChimpBundle\Exception\RequiredOptionException
  * @expectedExceptionMessage Option "apiKey" is required
  */
 public function testInitFails()
 {
     $transportEntity = new MailChimpTransportEntity();
     $this->clientFactory->expects($this->never())->method($this->anything());
     $this->transport->init($transportEntity);
 }