/** * @param MarketingList $marketingList * @param int $entityId * @return MarketingListItem */ public function getMarketingListItem(MarketingList $marketingList, $entityId) { $marketingListItemRepository = $this->registry->getRepository(self::MARKETING_LIST_ITEM_ENTITY); $marketingListItem = $marketingListItemRepository->findOneBy(['marketingList' => $marketingList, 'entityId' => $entityId]); if (!$marketingListItem) { $marketingListItem = new MarketingListItem(); $marketingListItem->setMarketingList($marketingList)->setEntityId($entityId); $manager = $this->registry->getManagerForClass(self::MARKETING_LIST_ITEM_ENTITY); $manager->persist($marketingListItem); } return $marketingListItem; }
public function testContact() { $this->assertEmpty($this->entity->getContactedTimes()); $this->assertEmpty($this->entity->getLastContactedAt()); $this->entity->contact(); $this->assertEquals(1, $this->entity->getContactedTimes()); $this->assertInstanceOf('\\DateTime', $this->entity->getLastContactedAt()); }