client->request(Request::METHOD_GET, '/dwc/slot-a');
Assert::assertSame(Response::HTTP_NO_CONTENT, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent());
}
public function testDwcGetEndpointForASlotAndContact(): void
{
$contact = new Lead();
$contact->setEmail('johana@doe.email');
$dwc = new DynamicContent();
$dwc->setContent('content');
$dwc->setName('Slot A');
$dwc->setSlotName('slot-a');
$dwcContact = new DynamicContentLeadData();
$dwcContact->setDateAdded(new \DateTime());
$dwcContact->setDynamicContent($dwc);
$dwcContact->setLead($contact);
$dwcContact->setSlot($dwc->getSlotName());
$stat = new Stat();
$stat->setLead($contact);
$stat->setTrackingHash('tracking-hash-1');
$stat->setEmailAddress($contact->getEmail());
$stat->setDateSent(new \DateTime());
$this->em->persist($contact);
$this->em->persist($stat);
$this->em->persist($dwc);
$this->em->persist($dwcContact);
$this->em->flush();
$ct = ClickthroughHelper::encodeArrayForUrl(['stat' => 'tracking-hash-1']);
$this->client->request(Request::METHOD_GET, "/dwc/slot-a?ct={$ct}");
Assert::assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent());
$responseArray = json_decode($this->client->getResponse()->getContent(), true);
Assert::assertSame('content', $responseArray['content']);
}
public function testCreateDwc(): void
{
$payload = [
'name' => 'API test',
'content' => 'API test',
];
$this->client->request(Request::METHOD_POST, '/api/dynamiccontents/new', $payload);
Assert::assertSame(Response::HTTP_CREATED, $this->client->getResponse()->getStatusCode(), $this->client->getResponse()->getContent());
}
}