Spaces:
No application file
No application file
File size: 2,278 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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<?php
declare(strict_types=1);
namespace Mautic\EmailBundle\Tests\Functional;
use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use Mautic\EmailBundle\Entity\Email;
use Mautic\EmailBundle\Entity\Stat;
use Mautic\LeadBundle\Entity\Lead;
use Mautic\LeadBundle\Entity\LeadList;
use Mautic\LeadBundle\Entity\ListLead;
use PHPUnit\Framework\Assert;
use Symfony\Component\HttpFoundation\Request;
final class PendingCountTest extends MauticMysqlTestCase
{
/**
* There was an issue that if there is a lead_id = null in the email_stats associated with an email
* then the pending count was always 0 even if there are contacts waiting for sent.
*/
public function testPendingCountWithDeletedContactsInEmailStats(): void
{
$contact = new Lead();
$contact->setEmail('[email protected]');
$segment = new LeadList();
$segment->setName('Segment A');
$segment->setPublicName('Segment A');
$segment->setAlias('segment-a');
$segmentRef = new ListLead();
$segmentRef->setLead($contact);
$segmentRef->setList($segment);
$segmentRef->setDateAdded(new \DateTime());
$email = new Email();
$email->setName('Email A');
$email->setSubject('Email A Subject');
$email->setEmailType('list');
$email->addList($segment);
$emailStat = new Stat();
$emailStat->setEmail($email);
$emailStat->setLead(null);
$emailStat->setEmailAddress('[email protected]');
$emailStat->setDateSent(new \DateTime());
$this->em->persist($segment);
$this->em->persist($contact);
$this->em->persist($segmentRef);
$this->em->persist($email);
$this->em->persist($emailStat);
$this->em->flush();
// The counts are loaded via ajax call after the email list page loads, so checking the ajax request instead of the HTML.
$this->client->request(Request::METHOD_GET, '/s/ajax?action=email:getEmailCountStats', ['id' => $email->getId()]);
Assert::assertSame(
'{"id":'.$email->getId().',"pending":"1 Pending","queued":0,"sentCount":"0 Sent","readCount":"0 Read","readPercent":"0% Read"}',
$this->client->getResponse()->getContent()
);
}
}
|