mautic / app /bundles /LeadBundle /Tests /Command /DeduplicateIdsCommandFunctionalTest.php
chrisbryan17's picture
Upload folder using huggingface_hub
d2897cd verified
<?php
declare(strict_types=1);
namespace Mautic\LeadBundle\Tests\Command;
use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use Mautic\LeadBundle\Command\DeduplicateIdsCommand;
use Mautic\LeadBundle\Entity\Lead;
use PHPUnit\Framework\Assert;
final class DeduplicateIdsCommandFunctionalTest extends MauticMysqlTestCase
{
public function testDeduplicateCommandWithContactIdsParam(): void
{
$contactRepository = $this->em->getRepository(Lead::class);
Assert::assertSame(0, $contactRepository->count([]), 'Some contacts were forgotten to remove from other tests');
$contact1 = $this->saveContact('[email protected]');
$this->saveContact('[email protected]');
$contact2 = $this->saveContact('[email protected]');
$this->saveContact('[email protected]');
$contact3 = $this->saveContact('[email protected]');
$this->saveContact('[email protected]');
$this->em->flush();
Assert::assertSame(6, $contactRepository->count([]));
$this->testSymfonyCommand(DeduplicateIdsCommand::NAME, ['--contact-ids' => "{$contact1->getId()},{$contact2->getId()},{$contact3->getId()}"]);
Assert::assertSame(3, $contactRepository->count([]));
}
private function saveContact(string $email): Lead
{
$contact = new Lead();
$contact->setEmail($email);
$contact->setDateIdentified(new \DateTime());
$this->em->persist($contact);
return $contact;
}
}