/**
  * {@inheritdoc}
  */
 public function init(Transport $transportEntity)
 {
     $apiKey = $transportEntity->getSettingsBag()->get('apiKey');
     if (!$apiKey) {
         throw new RequiredOptionException('apiKey');
     }
     $this->client = $this->mailChimpClientFactory->create($apiKey);
 }
 /**
  * @dataProvider commandMemberActivityOptionsProvider
  * @param string $commandName
  * @param array $params
  * @param string $entity
  * @param array $data
  * @param string $assertMethod
  * @param int $assertCount
  * @param array $expectedList
  */
 public function testSyncMemberActivity($commandName, array $params, $entity, $data, $assertMethod, $assertCount, $expectedList)
 {
     $this->entityBody->expects($this->at(1))->method('readLine')->will($this->returnValue($data['line1_data']));
     $this->entityBody->expects($this->at(2))->method('readLine')->will($this->returnValue($data['line2_data']));
     if (isset($params['--integration-id'])) {
         $params['--integration-id'] = (string) $this->getReference('mailchimp:channel_' . $params['--integration-id'])->getId();
     }
     $result = $this->runCommand($commandName, $params);
     foreach ($expectedList as $expected) {
         $this->assertContains($expected, $result);
     }
     if ($assertMethod) {
         $listRepo = $this->getContainer()->get('doctrine')->getRepository('OroCRMMailChimpBundle:' . $entity);
         $list = $listRepo->findAll();
         $this->{$assertMethod}($assertCount, count($list));
     }
 }
 /**
  * @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);
 }