Skip to content

Commit

Permalink
Batch DNC fix (mautic#14085)
Browse files Browse the repository at this point in the history
* Fixing batch dnc

* Loading the batch DNC form in the existing test to catch issues with it
  • Loading branch information
escopecz authored Aug 29, 2024
1 parent f66e8c9 commit b5d174f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
12 changes: 3 additions & 9 deletions app/bundles/LeadBundle/Controller/LeadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ public function batchDncAction(Request $request, DoNotContactModel $doNotContact
$this->addFlashMessage(
'mautic.lead.batch_leads_affected',
[
'%count%' => $count,
'%count%' => $count,
]
);

Expand All @@ -1754,15 +1754,9 @@ public function batchDncAction(Request $request, DoNotContactModel $doNotContact
return $this->delegateView(
[
'viewParameters' => [
'form' => $this->createForm(
DncType::class,
[],
[
'action' => $route,
]
)->createView(),
'form' => $this->createForm(DncType::class, [], ['action' => $route])->createView(),
],
'contentTemplate' => 'MauticLeadBundle:Batch:form.html.php',
'contentTemplate' => '@MauticLead/Batch/form.html.twig',
'passthroughVars' => [
'activeLink' => '#mautic_contact_index',
'mauticContent' => 'leadBatch',
Expand Down
20 changes: 12 additions & 8 deletions app/bundles/LeadBundle/Tests/Controller/LeadControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,14 +936,18 @@ public function testBatchDncIsNotUpdatingLeadEntities(): void
$this->em->flush();
$this->em->clear();

$payload = [
'lead_batch_dnc' => [
'reason' => 'Test Reason',
'ids' => json_encode([$contact->getId()]),
],
];

$this->client->request(Request::METHOD_POST, '/s/contacts/batchDnc', $payload, [], $this->createAjaxHeaders());
$this->client->request(Request::METHOD_GET, '/s/contacts/batchDnc', [], [], $this->createAjaxHeaders());
Assert::assertTrue($this->client->getResponse()->isOk());
$crawler = new Crawler(json_decode($this->client->getResponse()->getContent(), true)['newContent'], $this->client->getInternalRequest()->getUri());
$form = $crawler->selectButton('Save')->form();
$form->setValues(
[
'lead_batch_dnc[reason]' => 'Test Reason',
'lead_batch_dnc[ids]' => json_encode([$contact->getId()]),
]
);
$crawler = $this->client->submit($form);
$this->assertTrue($this->client->getResponse()->isOk(), $this->client->getResponse()->getContent());

$clientResponse = $this->client->getResponse();

Expand Down

0 comments on commit b5d174f

Please sign in to comment.