/**
* @Given the contact :firstName :lastName with :typeName email :email exists
*/
public function theContactExists($firstName, $lastName, $typeName, $emailAddress)
{
$type = $this->getEntityManager()->getRepository('SuluContactBundle:EmailType')->findOneByName($typeName);
if (!$type) {
throw new \InvalidArgumentException(sprintf('No email type "%s" found', $typeName));
}
$contact = new Contact();
$contact->setFirstName($firstName);
$contact->setLastName($lastName);
$email = new Email();
$email->setEmail($emailAddress);
$email->setEmailType($type);
$contact->addEmail($email);
$contact->setFormOfAddress(0);
$this->getEntityManager()->persist($email);
$this->getEntityManager()->persist($contact);
$this->getEntityManager()->flush();
}