Inheritance: extends Sulu\Bundle\CoreBundle\Entity\ApiEntity, implements Sulu\Component\Contact\Model\ContactInterface, implements Sulu\Component\Persistence\Model\AuditableInterface
コード例 #1
0
 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();
 }
コード例 #2
0
 private function createContact($firstName, $lastName)
 {
     $contact = new Contact();
     $contact->setFirstName($firstName);
     $contact->setLastName($lastName);
     $this->em->persist($contact);
     return $contact;
 }
コード例 #3
0
 public function testResolveUserFunction()
 {
     $user1 = new User();
     $contact1 = new Contact();
     $contact1->setFirstName('Hikaru');
     $contact1->setLastName('Sulu');
     $user1->setContact($contact1);
     $user2 = new User();
     $contact2 = new Contact();
     $contact2->setFirstName('John');
     $contact2->setLastName('Cho');
     $user2->setContact($contact2);
     $this->userRepository->expects($this->exactly(2))->method('findUserById')->will($this->returnValueMap([[1, $user1], [2, $user2]]));
     $contact = $this->extension->resolveUserFunction(1);
     $this->assertEquals('Hikaru Sulu', $contact->getFullName());
     $contact = $this->extension->resolveUserFunction(2);
     $this->assertEquals('John Cho', $contact->getFullName());
 }
コード例 #4
0
 public function testUserBlame()
 {
     $context = $this->getContainer()->get('security.context');
     $token = new UsernamePasswordToken('test', 'test', 'test_provider', []);
     $user = new User();
     $user->setUsername('dantleech');
     $user->setPassword('foo');
     $user->setLocale('fr');
     $user->setSalt('saltz');
     $this->db('ORM')->getOm()->persist($user);
     $this->db('ORM')->getOm()->flush();
     $token->setUser($user);
     $context->setToken($token);
     $contact = new Contact();
     $contact->setFirstName('Max');
     $contact->setLastName('Mustermann');
     $contact->setPosition('CEO');
     $contact->setSalutation('Sehr geehrter Herr Dr Mustermann');
     $this->db('ORM')->getOm()->persist($contact);
     $this->db('ORM')->getOm()->flush();
     $changer = $contact->getChanger();
     $creator = $contact->getCreator();
     $this->assertSame($changer, $user);
     $this->assertSame($creator, $user);
 }
コード例 #5
0
 private function createContact($firstName, $lastName, $tags = [], $categories = [])
 {
     $contact = new Contact();
     $contact->setFirstName($firstName);
     $contact->setLastName($lastName);
     $contact->setFormOfAddress(0);
     foreach ($tags as $tag) {
         $contact->addTag($this->tags[$tag]);
     }
     foreach ($categories as $category) {
         $contact->addCategory($this->categories[$category]);
     }
     $this->em->persist($contact);
     return $contact;
 }
コード例 #6
0
ファイル: TestUserProvider.php プロジェクト: Silwereth/sulu
 /**
  * {@inheritdoc}
  */
 public function getUser()
 {
     if ($this->user) {
         return $this->user;
     }
     $user = $this->entityManager->getRepository('Sulu\\Bundle\\SecurityBundle\\Entity\\User')->findOneByUsername('test');
     if (!$user) {
         $contact = new Contact();
         $contact->setFirstName('Max');
         $contact->setLastName('Mustermann');
         $this->entityManager->persist($contact);
         $user = new User();
         $this->setCredentials($user);
         $user->setSalt('');
         $user->setLocale('en');
         $user->setContact($contact);
         $this->entityManager->persist($user);
     } else {
         $this->setCredentials($user);
     }
     $this->entityManager->flush();
     $this->user = $user;
     return $this->user;
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 public function testPutWithEmptyPassword()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('PUT', '/api/users/' . $this->user1->getId(), ['username' => 'manager', 'password' => '', 'locale' => 'en', 'contact' => ['id' => $this->contact1->getId()], 'userRoles' => [['id' => $this->user1->getId(), 'role' => ['id' => $this->role1->getId()], 'locales' => ['de', 'en']], ['id' => 2, 'role' => ['id' => $this->role2->getId()], 'locales' => ['en']]]]);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('manager', $response->username);
     $this->assertEquals('securepassword', $response->password);
     $this->assertEquals($this->contact1->getId(), $response->contact->id);
     $this->assertEquals('en', $response->locale);
     $this->assertEquals('Role1', $response->userRoles[0]->role->name);
     $this->assertEquals('de', $response->userRoles[0]->locales[0]);
     $this->assertEquals('en', $response->userRoles[0]->locales[1]);
     $this->assertEquals('Role2', $response->userRoles[1]->role->name);
     $this->assertEquals('en', $response->userRoles[1]->locales[0]);
     $refreshedUser = $this->em->getRepository('SuluSecurityBundle:User')->find($this->user1->getId());
     $this->assertEquals($this->user1->getSalt(), $refreshedUser->getSalt());
 }
コード例 #9
0
ファイル: ContactContext.php プロジェクト: kriswillis/sulu
 /**
  * @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->setDisabled(0);
     $contact->setFormOfAddress(0);
     $this->getEntityManager()->persist($email);
     $this->getEntityManager()->persist($contact);
     $this->getEntityManager()->flush();
 }
コード例 #10
0
 /**
  * Test if deleteinfo returns correct data.
  */
 public function testGetDeleteInfoById()
 {
     // modify test data
     for ($i = 0; $i < 5; ++$i) {
         $contact = new Contact();
         $contact->setFirstName('Vorname ' . $i);
         $contact->setLastName('Nachname ' . $i);
         $contact->setMiddleName('Mittelname ' . $i);
         $contact->setFormOfAddress(0);
         $this->em->persist($contact);
         $accountContact = new AccountContact();
         $accountContact->setContact($contact);
         $accountContact->setAccount($this->account);
         $accountContact->setMain(true);
         $this->em->persist($accountContact);
         $this->account->addAccountContact($accountContact);
     }
     $this->em->flush();
     $numContacts = $this->account->getAccountContacts()->count();
     $client = $this->createAuthenticatedClient();
     $client->request('GET', '/api/accounts/' . $this->account->getId() . '/deleteinfo');
     $this->assertEquals('200', $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     // number of returned contacts has to be less or equal 3
     $this->assertEquals(3, count($response->contacts));
     // return full number of contacts related to account
     $this->assertEquals($numContacts, $response->numContacts);
     // allowed if no subaccount exists
     $this->assertEquals(0, $response->numChildren);
 }
コード例 #11
0
ファイル: ContactManager.php プロジェクト: Silwereth/sulu
 /**
  * Takes a contact entity and a locale and returns the api object.
  *
  * @param Contact $contact
  * @param string $locale
  *
  * @return ContactApi
  */
 protected function getApiObject($contact, $locale)
 {
     $apiObject = new ContactApi($contact, $locale);
     if ($contact->getAvatar()) {
         $apiAvatar = $this->mediaManager->getById($contact->getAvatar()->getId(), $locale);
         $apiObject->setAvatar($apiAvatar);
     }
     return $apiObject;
 }
コード例 #12
0
ファイル: ContactManager.php プロジェクト: kriswillis/sulu
 /**
  * removes the address relation from a contact and also deletes the address if it has no more relations.
  *
  * @param Contact        $contact
  * @param ContactAddress $contactAddress
  *
  * @return mixed|void
  *
  * @throws \Exception
  */
 public function removeAddressRelation($contact, $contactAddress)
 {
     if (!$contact || !$contactAddress) {
         throw new \Exception('Contact and ContactAddress cannot be null');
     }
     // reload address to get all data (including relational data)
     /** @var Address $address */
     $address = $contactAddress->getAddress();
     $address = $this->em->getRepository('SuluContactBundle:Address')->findById($address->getId());
     $isMain = $contactAddress->getMain();
     // remove relation
     $contact->removeContactAddress($contactAddress);
     $address->removeContactAddress($contactAddress);
     // if was main, set a new one
     if ($isMain) {
         $this->setMainForCollection($contact->getContactAddresses());
     }
     // delete address if it has no more relations
     if (!$address->hasRelations()) {
         $this->em->remove($address);
     }
     $this->em->remove($contactAddress);
 }
コード例 #13
0
ファイル: UserRepositoryTest.php プロジェクト: ollietb/sulu
 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;
 }
コード例 #14
0
 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;
 }
コード例 #15
0
ファイル: AbstractContactManager.php プロジェクト: sulu/sulu
 /**
  * Process all notes from request.
  *
  * @param Contact $contact The contact on which is worked
  * @param $notes
  *
  * @return bool True if the processing was successful, otherwise false
  */
 public function processNotes($contact, $notes)
 {
     $get = function ($note) {
         return $note->getId();
     };
     $delete = function ($note) use($contact) {
         $contact->removeNote($note);
         return true;
     };
     $update = function ($note, $matchedEntry) {
         return $this->updateNote($note, $matchedEntry);
     };
     $add = function ($note) use($contact) {
         return $this->addNote($contact, $note);
     };
     $entities = $contact->getNotes();
     $result = $this->processSubEntities($entities, $notes, $get, $add, $update, $delete);
     $this->resetIndexOfSubentites($entities);
     return $result;
 }
コード例 #16
0
 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();
 }
コード例 #17
0
 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();
 }