Exemplo n.º 1
0
 public function testContactsUtilGetContactStateDataKeyedById()
 {
     $contactStatesData = ContactsUtil::getContactStateDataKeyedById();
     $state1 = ContactState::getByName('New');
     $state3 = ContactState::getByName('Recycled');
     $state4 = ContactState::getByName('Dead');
     $state5 = ContactState::getByName('Qualified');
     $state6 = ContactState::getByName('Customer');
     $state7 = ContactState::getByName('Novo Hermão');
     $compareData = array($state1[0]->id => 'New', $state3[0]->id => 'Recycled', $state4[0]->id => 'Dead', $state5[0]->id => 'Qualified', $state6[0]->id => 'Customer', $state7[0]->id => 'Novo Hermão');
     $this->assertEquals($compareData, $contactStatesData);
 }
Exemplo n.º 2
0
 /**
  * Get how many records in the Contact and Lead models have each ContactState selected.
  * During testing, it is possible a contact or lead exists with a contact state id that no longer exists.
  * In that case, it is ignored from the count.
  */
 public function getCollectionCountData()
 {
     $contactStates = ContactsUtil::getContactStateDataKeyedById();
     $stateNameCountData = array();
     $idCountData = GroupedAttributeCountUtil::getCountData('Contact', 'state');
     foreach ($idCountData as $id => $count) {
         if (isset($contactStates[$id])) {
             $stateNameCountData[$contactStates[$id]] = $count;
         }
     }
     return $stateNameCountData;
 }
Exemplo n.º 3
0
 /**
  * @depends testCreateStateValues
  */
 public function testAttributesToAccount()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $industries = array('Automotive', 'Adult Entertainment', 'Financial Services', 'Mercenaries & Armaments');
     $industryFieldData = CustomFieldData::getByName('Industries');
     $industryFieldData->serializedData = serialize($industries);
     $this->assertTrue($industryFieldData->save());
     $user = UserTestHelper::createBasicUser('Bobby');
     $contact = new Contact();
     $contact->owner = $user;
     $contact->title->value = 'Mr.';
     $contact->firstName = 'Super';
     $contact->lastName = 'Man';
     $contact->companyName = 'ABC Company';
     $stateIds = ContactsUtil::getContactStateDataKeyedById();
     foreach ($stateIds as $stateId => $notUsed) {
         $stateToUse = ContactState::getById($stateId);
         break;
     }
     $contact->state = $stateToUse;
     //grab first state.
     $contact->officePhone = '1234567890';
     $contact->officeFax = '1222222222';
     $contact->industry->value = $industries[1];
     $contact->website = 'http://www.something.com';
     $contact->primaryAddress->street1 = '129 Noodle Boulevard';
     $contact->primaryAddress->street2 = 'Apartment 6000A';
     $contact->primaryAddress->city = 'Noodleville';
     $contact->primaryAddress->postalCode = '23453';
     $contact->primaryAddress->country = 'The Good Old US of A';
     $contact->secondaryAddress->street1 = '25 de Agosto 2543';
     $contact->secondaryAddress->street2 = 'Local 3';
     $contact->secondaryAddress->city = 'Ciudad de Los Fideos';
     $contact->secondaryAddress->postalCode = '5123-4';
     $contact->secondaryAddress->country = 'Latinoland';
     $this->assertTrue($contact->save());
     $id = $contact->id;
     unset($contact);
     $contact = Contact::getById($id);
     $account = new Account();
     $account = LeadsUtil::attributesToAccount($contact, $account);
     $this->assertTrue($account->save());
     $id = $account->id;
     unset($account);
     $account = Account::getById($id);
     $this->assertEquals('ABC Company', $account->name);
     $this->assertEquals('1234567890', $account->officePhone);
     $this->assertEquals('1222222222', $account->officeFax);
     $this->assertEquals('http://www.something.com', $account->website);
     $this->assertEquals($industries[1], $account->industry->value);
     $this->assertEquals('super', $account->owner->username);
     $this->assertEquals('129 Noodle Boulevard', $account->billingAddress->street1);
     $this->assertEquals('Apartment 6000A', $account->billingAddress->street2);
     $this->assertEquals('Noodleville', $account->billingAddress->city);
     $this->assertEquals('23453', $account->billingAddress->postalCode);
     $this->assertEquals('The Good Old US of A', $account->billingAddress->country);
     $this->assertEquals('25 de Agosto 2543', $account->shippingAddress->street1);
     $this->assertEquals('Local 3', $account->shippingAddress->street2);
     $this->assertEquals('Ciudad de Los Fideos', $account->shippingAddress->city);
     $this->assertEquals('5123-4', $account->shippingAddress->postalCode);
     $this->assertEquals('Latinoland', $account->shippingAddress->country);
 }