Exemplo n.º 1
0
 public function testContactsUtilSetStartingStateByOrder()
 {
     $startingStateId = ContactsUtil::getStartingStateId();
     $startingState = ContactState::getById($startingStateId);
     $startingState->delete();
     $this->assertEquals(6, count(ContactState::GetAll()));
     ContactsUtil::setStartingStateByOrder(2);
     $startingStateId = ContactsUtil::getStartingStateId();
     $states = ContactState::getAll('order');
     $this->assertEquals($states[1]->id, $startingStateId);
     $startingState = ContactState::getByName('Recycled');
     $this->assertEquals(1, count($startingState));
     $this->assertEquals($startingState[0]->id, $startingStateId);
 }
 /**
  * Get an array of states from the starting state onwards, id/translated label pairings of the
  * existing contact states ordered by order.
  * @param string $language
  * @return array
  */
 public static function getLeadStateDataFromStartingStateLabelByLanguage($language)
 {
     assert('is_string($language)');
     $leadStatesData = array();
     $states = ContactState::getAll('order');
     $startingState = ContactsUtil::getStartingStateId();
     foreach ($states as $state) {
         if ($startingState == $state->id) {
             break;
         }
         $state->name = ContactsUtil::resolveStateLabelByLanguage($state, $language);
         $leadStatesData[] = $state;
     }
     return $leadStatesData;
 }
Exemplo n.º 3
0
 public function testIsStateALeadByStateName()
 {
     $allContactStates = ContactState::GetAll();
     $this->assertGreaterThan(1, count($allContactStates));
     foreach ($allContactStates as $contactState) {
         if ($contactState->id < ContactsUtil::getStartingStateId()) {
             $isStateALeadByStateNameCorrect = true;
         } else {
             $isStateALeadByStateNameCorrect = false;
         }
         $isStateALead = LeadsUtil::isStateALeadByStateName($contactState->name);
         $this->assertEquals($isStateALead, $isStateALeadByStateNameCorrect);
     }
 }