setLastName() 공개 메소드

public setLastName ( $lastName )
 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);
 }
예제 #2
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();
 }
예제 #3
0
 private function createContact($firstName, $lastName)
 {
     $contact = new Contact();
     $contact->setFirstName($firstName);
     $contact->setLastName($lastName);
     $this->em->persist($contact);
     return $contact;
 }
예제 #4
0
 /**
  * @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();
 }
예제 #5
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());
 }
예제 #6
0
 /**
  * {@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 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();
 }
예제 #8
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);
 }
예제 #9
0
 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();
 }
예제 #10
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();
 }
예제 #11
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;
 }
예제 #12
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;
 }
예제 #13
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;
 }
예제 #14
0
 public function testGetListIdsOrder()
 {
     $contact1 = new Contact();
     $contact1->setFirstName('Erika');
     $contact1->setLastName('Mustermann');
     $this->em->persist($contact1);
     $contact2 = new Contact();
     $contact2->setFirstName('Anne');
     $contact2->setLastName('Mustermann');
     $this->em->persist($contact2);
     $contact3 = new Contact();
     $contact3->setFirstName('Otto');
     $contact3->setLastName('Mustermann');
     $this->em->persist($contact3);
     $this->em->flush();
     $ids = sprintf('%s,%s,%s', $contact3->getId(), $contact1->getId(), $contact2->getId());
     $client = $this->createTestClient();
     $client->request('GET', '/api/contacts?flat=true&ids=' . $ids);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(3, $response->total);
     $this->assertEquals($contact3->getId(), $response->_embedded->contacts[0]->id);
     $this->assertEquals($contact1->getId(), $response->_embedded->contacts[1]->id);
     $this->assertEquals($contact2->getId(), $response->_embedded->contacts[2]->id);
 }