public function __construct(Contact $model = null, $attributeName = null) { assert('$model != null'); assert('$attributeName != null && is_string($attributeName)'); parent::__construct($model, $attributeName); $this->contactStatesData = ContactsUtil::getContactStateDataKeyedByOrder(); $this->contactStatesLabels = ContactsUtil::getContactStateLabelsKeyedByLanguageAndOrder(); $startingState = ContactsUtil::getStartingState(); $this->startingStateOrder = $startingState->order; }
/** * @depends testLayoutsLoadOkAfterCustomFieldsPlacedForContactsModule */ public function testSuperUserModifyContactStatesDefaultValueItemsInDropDown() { $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); //test existing ContactState changes to labels. $extraPostData = array('startingStateOrder' => '4', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'In ProgressD', 'RecycledC', 'QualifiedA', 'CustomerF', 'YRE'), 'contactStatesDataExistingValues' => array('New', 'In Progress', 'Recycled', 'Qualified', 'Customer', 'YRE')); $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state'); $compareData = array('New', 'In ProgressD', 'RecycledC', 'QualifiedA', 'CustomerF', 'YRE'); $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder()); //todo: test that the changed labels, updated the existing data if any existed. //Removing ContactStates items $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'RecycledC', 'QualifiedA')); $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state'); $compareData = array('New', 'RecycledC', 'QualifiedA'); $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder()); //Adding ContactStates items $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'RecycledC', 'QualifiedA', 'NewItem', 'NewItem2')); $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state'); $compareData = array('New', 'RecycledC', 'QualifiedA', 'NewItem', 'NewItem2'); $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder()); //Changing order of ContactStates items $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'NewItem2', 'RecycledC', 'QualifiedA', 'NewItem')); $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state'); $compareData = array('New', 'NewItem2', 'RecycledC', 'QualifiedA', 'NewItem'); $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder()); //test trying to save 2 ContactStates with the same name (QualifiedA is twice) $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'NewItem2', 'QualifiedA', 'QualifiedA', 'NewItem')); $this->setGetArray(array('moduleClassName' => 'ContactsModule', 'attributeTypeName' => 'ContactState', 'attributeName' => 'state')); $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData))); $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit'); $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50. //test trying to save 0 ContactStates $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array()); $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData))); $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit'); $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50. //test trying to save contact states that are shorter than the minimum length. $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('NA', ' NB', 'NC')); $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData))); $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit'); $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50. }
public function testContactsUtilGetContactStateDataKeyedByOrder() { $contactStatesData = ContactsUtil::getContactStateDataKeyedByOrder(); $compareData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Dead', 4 => 'Qualified', 5 => 'Customer', 6 => 'Novo Hermão'); $this->assertEquals($compareData, $contactStatesData); }