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(); }
/** * @param Fax $fax * @param $entry * * @throws EntityNotFoundException * * @return bool */ protected function updateFax(Fax $fax, $entry) { $success = true; $faxType = $this->em->getRepository(self::$faxTypeEntityName)->find($entry['faxType']['id']); if (!$faxType) { throw new EntityNotFoundException(self::$faxTypeEntityName, $entry['faxType']['id']); } else { $fax->setFax($entry['fax']); $fax->setFaxType($faxType); } return $success; }
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; }
private function initOrm() { $account = new Account(); $account->setName('Company'); $account->setPlaceOfJurisdiction('Feldkirch'); $parentAccount = new Account(); $parentAccount->setName('Parent'); $parentAccount->setPlaceOfJurisdiction('Feldkirch'); $childAccount = new Account(); $childAccount->setName('Child'); $childAccount->setPlaceOfJurisdiction('Feldkirch'); $childAccount->setParent($parentAccount); $this->account = $account; $this->childAccount = $childAccount; $this->parentAccount = $parentAccount; $urlType = new UrlType(); $urlType->setName('Private'); $this->urlType = $urlType; $url = new Url(); $url->setUrl('http://www.company.example'); $this->url = $url; $url->setUrlType($urlType); $account->addUrl($url); $this->emailType = new EmailType(); $this->emailType->setName('Private'); $this->email = new Email(); $this->email->setEmail('*****@*****.**'); $this->email->setEmailType($this->emailType); $account->addEmail($this->email); $phoneType = new PhoneType(); $phoneType->setName('Private'); $this->phoneType = $phoneType; $phone = new Phone(); $phone->setPhone('123456789'); $phone->setPhoneType($phoneType); $account->addPhone($phone); $faxType = new FaxType(); $faxType->setName('Private'); $this->faxType = $faxType; $fax = new Fax(); $fax->setFax('123654789'); $fax->setFaxType($faxType); $account->addFax($fax); $country = new Country(); $country->setName('Musterland'); $country->setCode('ML'); $this->country = $country; $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($country); $address->setAddition(''); $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; $accountAddress = new AccountAddress(); $accountAddress->setAddress($address); $accountAddress->setAccount($account); $accountAddress->setMain(true); $account->addAccountAddress($accountAddress); $address->addAccountAddress($accountAddress); $contact = new Contact(); $contact->setFirstName('Vorname'); $contact->setLastName('Nachname'); $contact->setMiddleName('Mittelname'); $contact->setFormOfAddress(0); $accountContact = new AccountContact(); $accountContact->setContact($contact); $accountContact->setAccount($account); $accountContact->setMain(true); $account->addAccountContact($accountContact); $note = new Note(); $note->setValue('Note'); $account->addNote($note); $this->initLogo(); $account->setLogo($this->logo); $this->em->persist($account); $this->em->persist($childAccount); $this->em->persist($parentAccount); $this->em->persist($urlType); $this->em->persist($url); $this->em->persist($this->emailType); $this->em->persist($accountContact); $this->em->persist($this->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(); }
public function testPut() { $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()], 'avatar' => ['id' => $this->avatar->getId()], 'emails' => [['id' => $this->email->getId(), 'email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']], ['email' => '*****@*****.**', 'emailType' => ['id' => $this->emailType->getId(), 'name' => 'Private']]], 'phones' => [['id' => $this->phone->getId(), 'phone' => '321654987', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']], ['phone' => '789456123', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']], ['phone' => '147258369', 'phoneType' => ['id' => $this->phoneType->getId(), 'name' => 'Private']]], 'faxes' => [['id' => $this->fax->getId(), 'fax' => '321654987-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']], ['fax' => '789456123-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']], ['fax' => '147258369-1', 'faxType' => ['id' => $this->faxType->getId(), 'name' => 'Private']]], 'addresses' => [['id' => $this->address->getId(), 'title' => 'work', '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', 'note' => 'note']], 'notes' => [['id' => $this->note->getId(), 'value' => 'Note 1_1']], 'salutation' => 'Sehr geehrter John', 'formOfAddress' => ['id' => 0], 'categories' => [['id' => $this->category->getId()], ['id' => $this->category2->getId()]]]); $response = json_decode($client->getResponse()->getContent()); $this->assertEquals('John', $response->firstName); $this->assertEquals('Doe', $response->lastName); $this->assertEquals('MSc', $response->title->title); $this->assertEquals('*****@*****.**', $response->emails[0]->email); $this->assertEquals('*****@*****.**', $response->emails[1]->email); $this->assertEquals('321654987', $response->phones[0]->phone); $this->assertEquals('789456123', $response->phones[1]->phone); $this->assertEquals('147258369', $response->phones[2]->phone); $this->assertEquals('321654987-1', $response->faxes[0]->fax); $this->assertEquals('789456123-1', $response->faxes[1]->fax); $this->assertEquals('147258369-1', $response->faxes[2]->fax); $this->assertEquals('Street', $response->addresses[0]->street); $this->assertEquals('2', $response->addresses[0]->number); $this->assertEquals('9999', $response->addresses[0]->zip); $this->assertEquals('Springfield', $response->addresses[0]->city); $this->assertEquals('Colorado', $response->addresses[0]->state); $this->assertEquals('Note 1_1', $response->notes[0]->value); $this->assertEquals(1, count($response->notes)); $this->assertEquals('note', $response->addresses[0]->note); $this->assertEquals(true, $response->addresses[0]->billingAddress); $this->assertEquals(true, $response->addresses[0]->primaryAddress); $this->assertEquals(false, $response->addresses[0]->deliveryAddress); $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity); $this->assertEquals('6850', $response->addresses[0]->postboxPostcode); $this->assertEquals('4711', $response->addresses[0]->postboxNumber); $this->assertEquals(0, $response->formOfAddress); $this->assertEquals('Sehr geehrter John', $response->salutation); $this->assertObjectHasAttribute('avatar', $response); $this->assertObjectHasAttribute('thumbnails', $response->avatar); $this->assertObjectHasAttribute('100x100', $response->avatar->thumbnails); $this->assertTrue(is_string($response->avatar->thumbnails->{'100x100'})); $this->assertEquals(2, count($response->categories)); $client->request('GET', '/api/contacts/' . $response->id); $response = json_decode($client->getResponse()->getContent()); $this->assertEquals('John', $response->firstName); $this->assertEquals('Doe', $response->lastName); $this->assertEquals('MSc', $response->title->title); $this->assertEquals('*****@*****.**', $response->emails[0]->email); $this->assertEquals('*****@*****.**', $response->emails[1]->email); $this->assertEquals('321654987', $response->phones[0]->phone); $this->assertEquals('789456123', $response->phones[1]->phone); $this->assertEquals('147258369', $response->phones[2]->phone); $this->assertEquals('321654987-1', $response->faxes[0]->fax); $this->assertEquals('789456123-1', $response->faxes[1]->fax); $this->assertEquals('147258369-1', $response->faxes[2]->fax); $this->assertEquals('Street', $response->addresses[0]->street); $this->assertEquals('2', $response->addresses[0]->number); $this->assertEquals('9999', $response->addresses[0]->zip); $this->assertEquals('Springfield', $response->addresses[0]->city); $this->assertEquals('Colorado', $response->addresses[0]->state); $this->assertEquals('Note 1_1', $response->notes[0]->value); $this->assertEquals(1, count($response->notes)); $this->assertEquals('work', $response->addresses[0]->title); $this->assertEquals(true, $response->addresses[0]->billingAddress); $this->assertEquals(true, $response->addresses[0]->primaryAddress); $this->assertEquals(false, $response->addresses[0]->deliveryAddress); $this->assertEquals('Dornbirn', $response->addresses[0]->postboxCity); $this->assertEquals('6850', $response->addresses[0]->postboxPostcode); $this->assertEquals('4711', $response->addresses[0]->postboxNumber); $this->assertEquals(0, $response->formOfAddress); $this->assertEquals('Sehr geehrter John', $response->salutation); $this->assertObjectHasAttribute('avatar', $response); $this->assertObjectHasAttribute('thumbnails', $response->avatar); $this->assertObjectHasAttribute('100x100', $response->avatar->thumbnails); $this->assertTrue(is_string($response->avatar->thumbnails->{'100x100'})); $this->assertEquals(2, count($response->categories)); }