Inheritance: implements JsonSerializable
Exemple #1
0
 /**
  * @Given the email type :type exists
  */
 public function theEmailTypeExists($type)
 {
     $emailType = new EmailType();
     $emailType->setName($type);
     $this->getEntityManager()->persist($emailType);
     $this->getEntityManager()->flush();
 }
 protected function initOrm()
 {
     $this->purgeDatabase();
     $contact = new Contact();
     $contact->setFirstName('Max');
     $contact->setLastName('Mustermann');
     $this->em->persist($contact);
     $this->em->flush();
     $emailType = new EmailType();
     $emailType->setName('Private');
     $this->em->persist($emailType);
     $this->em->flush();
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $this->em->persist($email);
     $this->em->flush();
     $role1 = new Role();
     $role1->setName('Role1');
     $role1->setSystem('Sulu');
     $this->em->persist($role1);
     $this->em->flush();
     $user = new User();
     $user->setUsername('admin');
     $user->setPassword('securepassword');
     $user->setSalt('salt');
     $user->setLocale('de');
     $user->setContact($contact);
     $this->em->persist($user);
     $this->em->flush();
     $userRole1 = new UserRole();
     $userRole1->setRole($role1);
     $userRole1->setUser($user);
     $userRole1->setLocale(json_encode(['de', 'en']));
     $this->em->persist($userRole1);
     $this->em->flush();
     $permission1 = new Permission();
     $permission1->setPermissions(122);
     $permission1->setRole($role1);
     $permission1->setContext('Context 1');
     $this->em->persist($permission1);
     $this->em->flush();
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $this->em->persist($tag1);
     $this->em->flush();
     $tag2 = new Tag();
     $tag2->setName('tag2');
     $this->em->persist($tag2);
     $this->em->flush();
     $tag3 = new Tag();
     $tag3->setName('tag3');
     $this->em->persist($tag3);
     $this->em->flush();
     $tag4 = new Tag();
     $tag4->setName('tag4');
     $this->em->persist($tag4);
     $this->em->flush();
 }
 public function testPrimaryAddressHandlingPut()
 {
     $client = $this->createTestClient();
     $client->request('PUT', '/api/contacts/' . $this->contact->getId(), ['firstName' => 'John', 'lastName' => 'Doe', 'title' => $this->contactTitle->getId(), 'position' => ['id' => $this->contactPosition->getId(), 'position' => $this->contactPosition->getPosition()], 'emails' => [['id' => $this->email->getId(), 'email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']]], 'addresses' => [['id' => $this->address->getId(), 'street' => 'Street', 'number' => '2', 'zip' => '9999', 'city' => 'Springfield', 'state' => 'Colorado', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'billingAddress' => true, 'primaryAddress' => true, 'deliveryAddress' => false, 'postboxCity' => 'Dornbirn', 'postboxPostcode' => '6850', 'postboxNumber' => '4711'], ['street' => 'Street 1', 'number' => '2', 'zip' => '9999', 'city' => 'Springfield', 'state' => 'Colorado', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'billingAddress' => true, 'primaryAddress' => true, 'deliveryAddress' => false, 'postboxCity' => 'Dornbirn', 'postboxPostcode' => '6850', 'postboxNumber' => '4711'], ['street' => 'Street 2', 'number' => '2', 'zip' => '9999', 'city' => 'Springfield', 'state' => 'Colorado', 'country' => ['id' => $this->country->getId(), 'name' => 'Musterland', 'code' => 'ML'], 'addressType' => ['id' => $this->addressType->getId(), 'name' => 'Private'], 'billingAddress' => true, 'primaryAddress' => true, 'deliveryAddress' => false, 'postboxCity' => 'Dornbirn', 'postboxPostcode' => '6850', 'postboxNumber' => '4711']], 'salutation' => 'Sehr geehrter John', 'formOfAddress' => ['id' => 0]]);
     $response = json_decode($client->getResponse()->getContent());
     usort($response->addresses, $this->sortAddressesPrimaryLast());
     $this->assertEquals(false, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[1]->primaryAddress);
     $this->assertEquals(true, $response->addresses[2]->primaryAddress);
     $client->request('GET', '/api/contacts/' . $response->id);
     $response = json_decode($client->getResponse()->getContent());
     usort($response->addresses, $this->sortAddressesPrimaryLast());
     $this->assertEquals(false, $response->addresses[0]->primaryAddress);
     $this->assertEquals(false, $response->addresses[1]->primaryAddress);
     $this->assertEquals(true, $response->addresses[2]->primaryAddress);
 }
 public function initOrm()
 {
     $this->purgeDatabase();
     $contact = new Contact();
     $contact->setFirstName('Max');
     $contact->setLastName('Mustermann');
     $contact->setPosition('CEO');
     $contact->setFormOfAddress(1);
     $contact->setSalutation('Sehr geehrter Herr Dr Mustermann');
     $this->contact = $contact;
     $title = new ContactTitle();
     $title->setTitle('MSc');
     $contact->setTitle($title);
     $position = new Position();
     $position->setPosition('Manager');
     $account = new Account();
     $account->setLft(0);
     $account->setRgt(1);
     $account->setDepth(0);
     $account->setName('Musterfirma');
     $account1 = new Account();
     $account1->setLft(0);
     $account1->setRgt(1);
     $account1->setDepth(0);
     $account1->setName('Musterfirma');
     $phoneType = new PhoneType();
     $phoneType->setName('Private');
     $phone = new Phone();
     $phone->setPhone('123456789');
     $phone->setPhoneType($phoneType);
     $contact->addPhone($phone);
     $emailType = new EmailType();
     $emailType->setName('Private');
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $contact->addEmail($email);
     $faxType = new FaxType();
     $faxType->setName('Private');
     $this->faxType = $faxType;
     $fax = new Fax();
     $fax->setFax('123654789');
     $fax->setFaxType($faxType);
     $contact->addFax($fax);
     $country1 = new Country();
     $country1->setName('Musterland');
     $country1->setCode('ML');
     $country2 = new Country();
     $country2->setName('United States');
     $country2->setCode('US');
     $addressType = new AddressType();
     $addressType->setName('Private');
     $address = new Address();
     $address->setStreet('Musterstraße');
     $address->setNumber('1');
     $address->setZip('0000');
     $address->setCity('Musterstadt');
     $address->setState('Musterland');
     $address->setCountry($country1);
     $address->setAddressType($addressType);
     $address->setBillingAddress(true);
     $address->setPrimaryAddress(true);
     $address->setDeliveryAddress(false);
     $address->setPostboxCity('Dornbirn');
     $address->setPostboxPostcode('6850');
     $address->setPostboxNumber('4711');
     $contactAddress = new ContactAddress();
     $contactAddress->setAddress($address);
     $contactAddress->setContact($contact);
     $contactAddress->setMain(true);
     $contact->addContactAddress($contactAddress);
     $address->addContactAddress($contactAddress);
     $note = new Note();
     $note->setValue('Note');
     $contact->addNote($note);
     $this->setUpMediaEntities($contact);
     $this->em->persist($contact);
     $this->em->persist($title);
     $this->em->persist($position);
     $this->em->persist($account);
     $this->em->persist($account1);
     $this->em->persist($phoneType);
     $this->em->persist($phone);
     $this->em->persist($faxType);
     $this->em->persist($fax);
     $this->em->persist($emailType);
     $this->em->persist($email);
     $this->em->persist($country1);
     $this->em->persist($country2);
     $this->em->persist($addressType);
     $this->em->persist($contactAddress);
     $this->em->persist($address);
     $this->em->persist($note);
     $this->em->flush();
 }
 public function setUp()
 {
     $this->em = $this->db('ORM')->getOm();
     $this->purgeDatabase();
     $emailType = new EmailType();
     $emailType->setName('Private');
     $this->em->persist($emailType);
     $email1 = new Email();
     $email1->setEmail('*****@*****.**');
     $email1->setEmailType($emailType);
     $this->em->persist($email1);
     // Contact
     $contact1 = new Contact();
     $contact1->setFirstName('Max');
     $contact1->setLastName('Mustermann');
     $contact1->addEmail($email1);
     $this->em->persist($contact1);
     $this->contact1 = $contact1;
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $this->em->persist($email);
     $contact2 = new Contact();
     $contact2->setFirstName('Max');
     $contact2->setLastName('Muster');
     $contact2->addEmail($email);
     $this->em->persist($contact2);
     $this->contact2 = $contact2;
     $contact3 = new Contact();
     $contact3->setFirstName('Disabled');
     $contact3->setLastName('User');
     $contact3->addEmail($email);
     $this->em->persist($contact3);
     $this->contact3 = $contact3;
     $this->em->flush();
     $role1 = new Role();
     $role1->setName('Role1');
     $role1->setSystem('Sulu');
     $this->em->persist($role1);
     $this->role1 = $role1;
     $role2 = new Role();
     $role2->setName('Role2');
     $role2->setSystem('Sulu');
     $this->em->persist($role2);
     $this->role2 = $role2;
     // User 1
     $user = new User();
     $user->setUsername('admin');
     $user->setEmail('*****@*****.**');
     $user->setPassword('securepassword');
     $user->setSalt('salt');
     $user->setLocale('de');
     $user->setContact($contact2);
     $this->em->persist($user);
     $this->user1 = $user;
     // User 2
     $user1 = new User();
     $user1->setUsername('disabled');
     $user1->setEmail('*****@*****.**');
     $user1->setPassword('securepassword');
     $user1->setSalt('salt');
     $user1->setLocale('de');
     $user1->setContact($contact3);
     $user1->setEnabled(false);
     $this->em->persist($user1);
     $this->user2 = $user1;
     $this->em->flush();
     $userRole1 = new UserRole();
     $userRole1->setRole($role1);
     $userRole1->setUser($user);
     $userRole1->setLocale(json_encode(['de', 'en']));
     $this->em->persist($userRole1);
     $userRole2 = new UserRole();
     $userRole2->setRole($role2);
     $userRole2->setUser($user);
     $userRole2->setLocale(json_encode(['de', 'en']));
     $this->em->persist($userRole2);
     $userRole3 = new UserRole();
     $userRole3->setRole($role2);
     $userRole3->setUser($user);
     $userRole3->setLocale(json_encode(['de', 'en']));
     $this->em->persist($userRole3);
     $permission1 = new Permission();
     $permission1->setPermissions(122);
     $permission1->setRole($role1);
     $permission1->setContext('Context 1');
     $this->em->persist($permission1);
     $permission2 = new Permission();
     $permission2->setPermissions(122);
     $permission2->setRole($role2);
     $permission2->setContext('Context 2');
     $this->em->persist($permission2);
     // user groups
     $group1 = new Group();
     $group1->setName('Group1');
     $group1->setLft(0);
     $group1->setRgt(0);
     $group1->setDepth(0);
     $this->em->persist($group1);
     $this->group1 = $group1;
     $group2 = new Group();
     $group2->setName('Group2');
     $group2->setLft(0);
     $group2->setRgt(0);
     $group2->setDepth(0);
     $this->em->persist($group2);
     $this->group2 = $group2;
     $this->em->flush();
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     // phone types
     $metadata = $manager->getClassMetaData(PhoneType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $phoneType1 = new PhoneType();
     $phoneType1->setId(1);
     $phoneType1 = $manager->merge($phoneType1);
     $phoneType1->setName('phone.work');
     $phoneType2 = new PhoneType();
     $phoneType2->setId(2);
     $phoneType2 = $manager->merge($phoneType2);
     $phoneType2->setName('phone.home');
     $phoneType3 = new PhoneType();
     $phoneType3->setId(3);
     $phoneType3 = $manager->merge($phoneType3);
     $phoneType3->setName('phone.mobile');
     // email types
     $metadata = $manager->getClassMetaData(EmailType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $emailType1 = new EmailType();
     $emailType1->setId(1);
     $emailType1 = $manager->merge($emailType1);
     $emailType1->setName('email.work');
     $this->addReference('email.type.work', $emailType1);
     $emailType2 = new EmailType();
     $emailType2->setId(2);
     $emailType2 = $manager->merge($emailType2);
     $emailType2->setName('email.home');
     $this->addReference('email.type.home', $emailType2);
     // address types
     $metadata = $manager->getClassMetaData(AddressType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $addressType1 = new AddressType();
     $addressType1->setId(1);
     $addressType1 = $manager->merge($addressType1);
     $addressType1->setName('address.work');
     $addressType2 = new AddressType();
     $addressType2->setId(2);
     $addressType2 = $manager->merge($addressType2);
     $addressType2->setName('address.home');
     // url types
     $metadata = $manager->getClassMetaData(UrlType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $urlType1 = new UrlType();
     $urlType1->setId(1);
     $urlType1 = $manager->merge($urlType1);
     $urlType1->setName('url.work');
     $urlType2 = new UrlType();
     $urlType2->setId(2);
     $urlType2 = $manager->merge($urlType2);
     $urlType2->setName('url.home');
     // fax types
     $metadata = $manager->getClassMetaData(FaxType::class);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $faxType1 = new FaxType();
     $faxType1->setId(1);
     $faxType1 = $manager->merge($faxType1);
     $faxType1->setName('fax.work');
     $faxType2 = new FaxType();
     $faxType2->setId(2);
     $faxType2 = $manager->merge($faxType2);
     $faxType2->setName('fax.home');
     $manager->flush();
 }
Exemple #7
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $phoneType1 = new PhoneType();
     $phoneType1->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($phoneType1));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $phoneType1->setName('phone.work');
     $manager->persist($phoneType1);
     $phoneType2 = new PhoneType();
     $phoneType2->setId(2);
     $phoneType2->setName('phone.home');
     $manager->persist($phoneType2);
     $phoneType3 = new PhoneType();
     $phoneType3->setId(3);
     $phoneType3->setName('phone.mobile');
     $manager->persist($phoneType3);
     $emailType1 = new EmailType();
     $emailType1->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($emailType1));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $emailType1->setName('email.work');
     $manager->persist($emailType1);
     $this->addReference('email.type.work', $emailType1);
     $emailType2 = new EmailType();
     $emailType2->setId(2);
     $emailType2->setName('email.home');
     $manager->persist($emailType2);
     $this->addReference('email.type.home', $emailType2);
     $addressType1 = new AddressType();
     $addressType1->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($addressType1));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $addressType1->setName('address.work');
     $manager->persist($addressType1);
     $addressType2 = new AddressType();
     $addressType2->setId(2);
     $addressType2->setName('address.home');
     $manager->persist($addressType2);
     $urlType1 = new UrlType();
     $urlType1->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($urlType1));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $urlType1->setName('url.work');
     $manager->persist($urlType1);
     $urlType2 = new UrlType();
     $urlType2->setId(2);
     $urlType2->setName('url.home');
     $manager->persist($urlType2);
     $manager->flush();
     $faxType1 = new FaxType();
     $faxType1->setId(1);
     // force id = 1
     $metadata = $manager->getClassMetaData(get_class($faxType1));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $faxType1->setName('fax.work');
     $manager->persist($faxType1);
     $faxType2 = new FaxType();
     $faxType2->setId(2);
     $faxType2->setName('fax.home');
     $manager->persist($faxType2);
     $manager->flush();
 }
 private function initOrm()
 {
     $this->account = new Account();
     $this->account->setName('Company');
     $this->account->setDisabled(0);
     $this->account->setPlaceOfJurisdiction('Feldkirch');
     $urlType = new UrlType();
     $urlType->setName('Private');
     $url = new Url();
     $url->setUrl('http://www.company.example');
     $url->setUrlType($urlType);
     $this->account->addUrl($url);
     $emailType = new EmailType();
     $emailType->setName('Private');
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $this->account->addEmail($email);
     $phoneType = new PhoneType();
     $phoneType->setName('Private');
     $phone = new Phone();
     $phone->setPhone('123456789');
     $phone->setPhoneType($phoneType);
     $this->account->addPhone($phone);
     $faxType = new FaxType();
     $faxType->setName('Private');
     $fax = new Fax();
     $fax->setFax('123654789');
     $fax->setFaxType($faxType);
     $this->account->addFax($fax);
     $country = new Country();
     $country->setName('Musterland');
     $country->setCode('ML');
     $addressType = new AddressType();
     $addressType->setName('Private');
     $address = new Address();
     $address->setStreet('Musterstraße');
     $address->setNumber('1');
     $address->setZip('0000');
     $address->setCity('Musterstadt');
     $address->setState('Musterland');
     $address->setCountry($country);
     $address->setAddressType($addressType);
     $address->setBillingAddress(true);
     $address->setPrimaryAddress(true);
     $address->setDeliveryAddress(false);
     $address->setPostboxCity('Dornbirn');
     $address->setPostboxPostcode('6850');
     $address->setPostboxNumber('4711');
     $accountAddress = new AccountAddress();
     $accountAddress->setAddress($address);
     $accountAddress->setAccount($this->account);
     $accountAddress->setMain(true);
     $this->account->addAccountAddress($accountAddress);
     $address->addAccountAddress($accountAddress);
     $contact = new Contact();
     $contact->setFirstName('Vorname');
     $contact->setLastName('Nachname');
     $contact->setMiddleName('Mittelname');
     $contact->setDisabled(0);
     $contact->setFormOfAddress(0);
     $accountContact = new AccountContact();
     $accountContact->setContact($contact);
     $accountContact->setAccount($this->account);
     $accountContact->setMain(true);
     $this->account->addAccountContact($accountContact);
     $note = new Note();
     $note->setValue('Note');
     $this->account->addNote($note);
     $this->setUpMediaEntities();
     $this->em->persist($this->account);
     $this->em->persist($urlType);
     $this->em->persist($url);
     $this->em->persist($emailType);
     $this->em->persist($accountContact);
     $this->em->persist($email);
     $this->em->persist($phoneType);
     $this->em->persist($phone);
     $this->em->persist($country);
     $this->em->persist($addressType);
     $this->em->persist($address);
     $this->em->persist($accountAddress);
     $this->em->persist($note);
     $this->em->persist($faxType);
     $this->em->persist($fax);
     $this->em->persist($contact);
     $this->em->flush();
 }
Exemple #9
0
 private function prepareUser($username, $password, $enabled = true, $locked = false)
 {
     $emailType = new EmailType();
     $emailType->setName('Private');
     $this->em->persist($emailType);
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $this->em->persist($email);
     $contact1 = new Contact();
     $contact1->setFirstName('Max');
     $contact1->setLastName('Muster');
     $contact1->addEmail($email);
     $this->em->persist($contact1);
     $user = new User();
     $user->setUsername($username);
     $user->setPassword($password);
     $user->setSalt('salt');
     $user->setLocale('de');
     $user->setContact($contact1);
     $user->setEnabled($enabled);
     $user->setLocked($locked);
     $this->em->persist($user);
     $role = new Role();
     $role->setName('Sulu');
     $role->setSystem('Sulu');
     $this->em->persist($role);
     $userRole = new UserRole();
     $userRole->setRole($role);
     $userRole->setUser($user);
     $userRole->setLocale('');
     $this->em->persist($userRole);
     $this->em->flush();
     return $user;
 }
 private function initOrm()
 {
     $this->purgeDatabase();
     $contact = new Contact();
     $contact->setFirstName('Max');
     $contact->setLastName('Mustermann');
     $contact->setPosition('CEO');
     $contact->setFormOfAddress(1);
     $contact->setSalutation('Sehr geehrter Herr Dr Mustermann');
     $contact->setDisabled(0);
     $this->contact = $contact;
     $title = new ContactTitle();
     $title->setTitle('MSc');
     $contact->setTitle($title);
     $position = new Position();
     $position->setPosition('Manager');
     $account = new Account();
     $account->setLft(0);
     $account->setRgt(1);
     $account->setDepth(0);
     $account->setName('Musterfirma');
     $this->account = $account;
     $account1 = new Account();
     $account1->setLft(0);
     $account1->setRgt(1);
     $account1->setDepth(0);
     $account1->setName('Musterfirma');
     $this->account1 = $account1;
     $phoneType = new PhoneType();
     $phoneType->setName('Private');
     $this->phoneType = $phoneType;
     $phone = new Phone();
     $phone->setPhone('123456789');
     $phone->setPhoneType($phoneType);
     $contact->addPhone($phone);
     $this->phone = $phone;
     $emailType = new EmailType();
     $emailType->setName('Private');
     $this->emailType = $emailType;
     $email = new Email();
     $email->setEmail('*****@*****.**');
     $email->setEmailType($emailType);
     $contact->addEmail($email);
     $this->email = $email;
     $faxType = new FaxType();
     $faxType->setName('Private');
     $this->faxType = $faxType;
     $fax = new Fax();
     $fax->setFax('123654789');
     $fax->setFaxType($faxType);
     $contact->addFax($fax);
     $this->fax = $fax;
     $country1 = new Country();
     $country1->setName('Musterland');
     $country1->setCode('ML');
     $this->country = $country1;
     $country2 = new Country();
     $country2->setName('United States');
     $country2->setCode('US');
     $this->country2 = $country2;
     $addressType = new AddressType();
     $addressType->setName('Private');
     $this->addressType = $addressType;
     $address = new Address();
     $address->setStreet('Musterstraße');
     $address->setNumber('1');
     $address->setZip('0000');
     $address->setCity('Musterstadt');
     $address->setState('Musterland');
     $address->setCountry($country1);
     $address->setAddressType($addressType);
     $address->setBillingAddress(true);
     $address->setPrimaryAddress(true);
     $address->setDeliveryAddress(false);
     $address->setPostboxCity('Dornbirn');
     $address->setPostboxPostcode('6850');
     $address->setPostboxNumber('4711');
     $address->setNote('Note');
     $this->address = $address;
     $contactAddress = new ContactAddress();
     $contactAddress->setAddress($address);
     $contactAddress->setContact($contact);
     $contactAddress->setMain(true);
     $this->contactAddress = $contactAddress;
     $contact->addContactAddress($contactAddress);
     $address->addContactAddress($contactAddress);
     $note = new Note();
     $note->setValue('Note');
     $this->note = $note;
     $contact->addNote($note);
     $this->em->persist($contact);
     $this->em->persist($title);
     $this->em->persist($position);
     $this->em->persist($account);
     $this->em->persist($account1);
     $this->em->persist($phoneType);
     $this->em->persist($phone);
     $this->em->persist($faxType);
     $this->em->persist($fax);
     $this->em->persist($emailType);
     $this->em->persist($email);
     $this->em->persist($country1);
     $this->em->persist($country2);
     $this->em->persist($addressType);
     $this->em->persist($contactAddress);
     $this->em->persist($address);
     $this->em->persist($note);
     /* First Category
        -------------------------------------*/
     $category = new Category();
     $category->setKey('first-category-key');
     $this->category = $category;
     // name for first category
     $categoryTrans = new CategoryTranslation();
     $categoryTrans->setLocale('en');
     $categoryTrans->setTranslation('First Category');
     $categoryTrans->setCategory($category);
     $category->addTranslation($categoryTrans);
     // meta for first category
     $categoryMeta = new CategoryMeta();
     $categoryMeta->setLocale('en');
     $categoryMeta->setKey('description');
     $categoryMeta->setValue('Description of Category');
     $categoryMeta->setCategory($category);
     $category->addMeta($categoryMeta);
     $this->em->persist($category);
     /* Second Category
        -------------------------------------*/
     $category2 = new Category();
     $category2->setKey('second-category-key');
     $this->category2 = $category2;
     // name for second category
     $categoryTrans2 = new CategoryTranslation();
     $categoryTrans2->setLocale('de');
     $categoryTrans2->setTranslation('Second Category');
     $categoryTrans2->setCategory($category2);
     $category2->addTranslation($categoryTrans2);
     // meta for second category
     $categoryMeta2 = new CategoryMeta();
     $categoryMeta2->setLocale('de');
     $categoryMeta2->setKey('description');
     $categoryMeta2->setValue('Description of second Category');
     $categoryMeta2->setCategory($category2);
     $category2->addMeta($categoryMeta2);
     $this->em->persist($category2);
     $this->em->flush();
     $this->contactTitle = $title;
     $this->contactPosition = $position;
 }