Spaces:
No application file
No application file
File size: 1,473 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 |
<?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;
}
}
|