Spaces:
No application file
No application file
File size: 1,622 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<?php
namespace Mautic\CampaignBundle\Tests\Service;
use Mautic\CampaignBundle\Entity\CampaignRepository;
use Mautic\CampaignBundle\Service\Campaign;
use Mautic\EmailBundle\Entity\EmailRepository;
/**
* @deprecated to be removed in 6.0
*/
class CampaignTest extends \PHPUnit\Framework\TestCase
{
public function testHasUnpublishedEmail(): void
{
$campaignId = 1;
$campaignRepository = $this->createMock(CampaignRepository::class);
$campaignRepository
->expects($this->once())
->method('fetchEmailIdsById')
->with($campaignId)
->willReturn([]);
$emailRepository = $this->createMock(EmailRepository::class);
$campaignService = new Campaign($campaignRepository, $emailRepository);
$this->assertFalse($campaignService->hasUnpublishedEmail($campaignId));
$emailIds = [1, 2.3];
$hasUnpublishedEmails = true;
$campaignRepository = $this->createMock(CampaignRepository::class);
$campaignRepository
->expects($this->once())
->method('fetchEmailIdsById')
->with($campaignId)
->willReturn($emailIds);
$emailRepository = $this->createMock(EmailRepository::class);
$emailRepository
->expects($this->once())
->method('isOneUnpublished')
->with($emailIds)
->willReturn($hasUnpublishedEmails);
$campaignService = new Campaign($campaignRepository, $emailRepository);
$this->assertTrue($campaignService->hasUnpublishedEmail($campaignId));
}
}
|