/**
  * @param int                     $campaignId
  * @param CampaignStatsRepository $campaignStatsRepository
  * @param CampaignRepository      $campaignRepository
  * @return \Response
  */
 public function show($campaignId, CampaignStatsRepository $campaignStatsRepository, CampaignRepository $campaignRepository)
 {
     $campaign = $campaignRepository->find($campaignId);
     if (!$campaign) {
         $this->failure('Invalid Campaign ID');
     }
     if ($campaign->remoteCampaignId()) {
         $campaignStatsRepository->setDomain($campaign->getFromEmailDomain());
         $campaignStats = $campaignStatsRepository->find($campaign->remoteCampaignId());
         return $this->success($campaignStats->stats());
     } else {
         return $this->success(['delivered' => 0, 'dropped' => 0, 'opened' => 0, 'clicked' => 0, 'complained' => 0, 'bounced' => 0, 'unsubscribed' => 0]);
     }
 }
 /**
  * @test
  */
 function testShow()
 {
     $campaignData = ['id' => 50, 'domain' => 'gmail.com', 'fromEmail' => new Email('*****@*****.**'), 'remoteCampaignId' => 'hyght'];
     $this->campaignRepository = Mockery::mock('App\\AmbitiousMailSender\\Campaigns\\CampaignRepository', 'CampaignRepository');
     $this->campaignRepository->shouldReceive('find')->once()->andReturn(new \App\AmbitiousMailSender\Campaigns\Campaign($campaignData));
     $this->app->instance('App\\AmbitiousMailSender\\Campaigns\\CampaignRepository', $this->campaignRepository);
     $campaignStatsData = ['id' => 1, 'submitted' => 100, 'delivered' => 60, 'dropped' => 10, 'bounced' => 5, 'clicked' => 60, 'opened' => 55, 'complained' => 0, 'unsubscribed' => 0];
     $this->campaignStatsRepository = Mockery::mock('App\\AmbitiousMailSender\\CampaignStats\\CampaignStatsRepository', 'CampaignStatsRepository');
     $this->campaignStatsRepository->shouldReceive('setDomain')->with('gmail.com');
     $this->campaignStatsRepository->shouldReceive('find')->with('hyght')->once()->andReturn(new \App\AmbitiousMailSender\CampaignStats\CampaignStats($campaignStatsData));
     $this->app->instance('App\\AmbitiousMailSender\\CampaignStats\\CampaignStatsRepository', $this->campaignStatsRepository);
     $this->action('GET', 'ApiV1\\CampaignController@show', ['campaignId' => 50], [], [], [], ['PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'secret']);
     unset($campaignStatsData['id']);
     $campaignStatsData['delivering'] = 30;
     $this->assertResponseOk();
     $this->assertViewHas('apiResponse', ['success' => 1, 'response' => $campaignStatsData, 'message' => '']);
 }