当前位置: 首页>>代码示例>>PHP>>正文


PHP ContactState::getAll方法代码示例

本文整理汇总了PHP中ContactState::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactState::getAll方法的具体用法?PHP ContactState::getAll怎么用?PHP ContactState::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContactState的用法示例。


在下文中一共展示了ContactState::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLoad

 public function testLoad()
 {
     $customFieldData = CustomFieldData::getByName('Titles');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('AccountTypes');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('LeadSources');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('Industries');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('MeetingCategories');
     $this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
     $this->assertEquals(0, count(ContactState::getAll()));
     $this->assertEquals(1, count(Currency::getAll()));
     $messageLogger = new MessageLogger();
     DefaultDataUtil::load($messageLogger);
     $customFieldData = CustomFieldData::getByName('Titles');
     $this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('AccountTypes');
     $this->assertEquals(3, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('LeadSources');
     $this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('Industries');
     $this->assertEquals(9, count(unserialize($customFieldData->serializedData)));
     $customFieldData = CustomFieldData::getByName('MeetingCategories');
     $this->assertEquals(2, count(unserialize($customFieldData->serializedData)));
     $this->assertEquals(6, count(ContactState::getAll()));
     $this->assertEquals(1, count(Currency::getAll()));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:29,代码来源:DefaultDataUtilTest.php

示例2: setAttributeMetadataFromForm

 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $contactStatesData = $attributeForm->contactStatesData;
     $contactStatesLabels = $attributeForm->contactStatesLabels;
     $startingStateOrder = (int) $attributeForm->startingStateOrder;
     $contactStatesDataExistingValues = $attributeForm->contactStatesDataExistingValues;
     if ($contactStatesDataExistingValues == null) {
         $contactStatesDataExistingValues = array();
     }
     if ($attributeForm instanceof ContactStateAttributeForm) {
         //update order on existing states.
         //delete removed states
         $states = ContactState::getAll('order');
         $stateNames = array();
         foreach ($states as $state) {
             if (in_array($state->name, $contactStatesDataExistingValues)) {
                 //todo: just don't match up the swap
                 $order = array_search($state->name, $contactStatesDataExistingValues);
                 $state->name = $contactStatesData[$order];
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
                 $stateNames[] = $state->name;
             } elseif (in_array($state->name, $contactStatesData)) {
                 $stateNames[] = $state->name;
                 $state->order = array_search($state->name, $contactStatesData);
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
             } else {
                 $stateNames[] = $state->name;
                 $state->delete();
             }
         }
         //add new states with correct order.
         foreach ($contactStatesData as $order => $name) {
             if (!in_array($name, $stateNames)) {
                 $state = new ContactState();
                 $state->name = $name;
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $order);
                 $saved = $state->save();
                 assert('$saved');
             }
         }
         //Set starting state by order.
         ContactsUtil::setStartingStateByOrder($startingStateOrder);
         ModelMetadataUtil::addOrUpdateRelation($modelClassName, $attributeName, $attributeLabels, $elementType, $isRequired, $isAudited, 'ContactState');
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:ContactStateModelAttributesAdapter.php

示例3: testSanitizeValueBySanitizerTypesForContactStateTypeThatIsRequired

 public function testSanitizeValueBySanitizerTypesForContactStateTypeThatIsRequired()
 {
     $contactStates = ContactState::getAll();
     $this->assertEquals(6, count($contactStates));
     //Test a required contact state with no value or default value.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => null)));
     $sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertNull($sanitizedValue);
     $this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(1, count($messages));
     $compareMessage = 'Contact - The status is required.  Neither a value nor a default was specified.';
     $this->assertEquals($compareMessage, $messages[0]);
     //Test a required contact state with a valid value, and a default value. The valid value should come through.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => $contactStates[4]->id)));
     $sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, $contactStates[5]->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($contactStates[5], $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a required contact state with no value, and a default value.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => $contactStates[4]->id)));
     $sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($contactStates[4], $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a required contact state with a value that is invalid
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultValue' => null)));
     $sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, 'somethingnotright', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(1, count($messages));
     $compareMessage = 'Contact - Status specified does not exist.';
     $this->assertEquals($compareMessage, $messages[0]);
     //Test a required contact state with a state that is for leads, not contacts.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultValue' => null)));
     $sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, $contactStates[1]->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(1, count($messages));
     $compareMessage = 'Contact - Status specified is invalid.';
     $this->assertEquals($compareMessage, $messages[0]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:54,代码来源:ContactImportSanitizerUtilTest.php

示例4: getStateIds

 public function getStateIds()
 {
     $states = ContactState::getAll('order');
     $startingStateOrder = ContactsUtil::getStartingStateOrder($states);
     $stateIds = array();
     foreach ($states as $state) {
         if ($this->shouldIncludeState($state->order, $startingStateOrder)) {
             $stateIds[] = $state->id;
         }
     }
     return $stateIds;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:12,代码来源:ContactsStateMetadataAdapter.php

示例5: makeAll

 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $contactStates = ContactState::getAll();
     $statesBeginningWithStartingState = $this->getStatesBeforeOrStartingWithStartingState($contactStates);
     $contacts = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $contact = new Contact();
         $contact->owner = $demoDataHelper->getRandomByModelName('User');
         $contact->state = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
         $this->populateModel($contact);
         $saved = $contact->save();
         assert('$saved');
         $contacts[] = $contact->id;
     }
     //We can use dummy model name here ContactsThatAreLeads, so we can distinct between contacts are leads
     $demoDataHelper->setRangeByModelName('ContactsThatAreLeads', $contacts[0], $contacts[count($contacts) - 1]);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:19,代码来源:LeadsDemoDataMaker.php

示例6: makeAll

 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $contactStates = ContactState::getAll();
     $statesBeginningWithStartingState = $this->getStatesBeforeOrStartingWithStartingState($contactStates);
     $contacts = array();
     for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
         $contact = new Contact();
         $contact->account = $demoDataHelper->getRandomByModelName('Account');
         $contact->state = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
         $contact->owner = $contact->account->owner;
         $this->populateModel($contact);
         $saved = $contact->save();
         assert('$saved');
         $contacts[] = $contact->id;
     }
     $demoDataHelper->setRangeByModelName('Contact', $contacts[0], $contacts[count($contacts) - 1]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ContactsDemoDataMaker.php

示例7: testUsingStateAdapters

 public function testUsingStateAdapters()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $contactStates = ContactState::getAll();
     $this->assertTrue(count($contactStates) > 1);
     $firstContactState = $contactStates[0];
     $lastContactState = $contactStates[count($contactStates) - 1];
     $contact = new Contact();
     $contact->title->value = 'Mr.';
     $contact->firstName = 'Sallyy';
     $contact->lastName = 'Sallyyson';
     $contact->owner = $super;
     $contact->state = $firstContactState;
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = 'sally@zurmoland.com';
     $contact->secondaryEmail = new Email();
     $contact->secondaryEmail->emailAddress = 'a19Sallyy@zurmoworld.com';
     $this->assertTrue($contact->save());
     $data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5);
     $this->assertEquals(2, count($data));
     $data = ContactSearch::getContactsByPartialFullName('sally', 5);
     $this->assertEquals(2, count($data));
     //Use contact state adapter
     $data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5, 'ContactsStateMetadataAdapter');
     $this->assertEquals(1, count($data));
     $this->assertEquals($lastContactState, $data[0]->state);
     $data = ContactSearch::getContactsByPartialFullName('sally', 5, 'ContactsStateMetadataAdapter');
     $this->assertEquals(1, count($data));
     $this->assertEquals($lastContactState, $data[0]->state);
     //Use lead state adapter
     $data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5, 'LeadsStateMetadataAdapter');
     $this->assertEquals(1, count($data));
     $this->assertEquals($firstContactState, $data[0]->state);
     $data = ContactSearch::getContactsByPartialFullName('sally', 5, 'LeadsStateMetadataAdapter');
     $this->assertEquals(1, count($data));
     $this->assertEquals($firstContactState, $data[0]->state);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:38,代码来源:ContactSearchTest.php

示例8: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $user = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $user;
     ContactsModule::loadStartingData();
     $contactData = array('Sam' => '123-456-789', 'Sally' => '123-456-789', 'Sarah' => '123-456-789', 'Jason' => '123-456-789', 'James' => '123-456-789', 'Roger' => '987-654-321');
     $contactStates = ContactState::getAll();
     $lastContactState = $contactStates[count($contactStates) - 1];
     foreach ($contactData as $firstName => $phone) {
         $contact = new Contact();
         $contact->title->value = 'Mr.';
         $contact->firstName = $firstName;
         $contact->lastName = 'son';
         $contact->owner = $user;
         $contact->state = $lastContactState;
         $contact->mobilePhone = $phone;
         $contact->officePhone = $phone . 'X';
         $contact->primaryEmail->emailAddress = strtolower($firstName) . '@zurmoland.com';
         $contact->secondaryEmail->emailAddress = strtolower($firstName) . '@zurmoworld.com';
         $contact->save();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:ContactDedupeRulesTest.php

示例9: makeAll

 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $contactStates = ContactState::getAll();
     $statesBeginningWithStartingState = ContactsDemoDataMaker::getStatesBeforeOrStartingWithStartingState($contactStates);
     $contactWebForms = array();
     for ($this->index = 0; $this->index < 5; $this->index++) {
         $contactWebForm = new ContactWebForm();
         $contactWebForm->owner = $demoDataHelper->getRandomByModelName('User');
         $contactWebForm->defaultOwner = $contactWebForm->owner;
         $contactWebForm->defaultState = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
         $this->populateModel($contactWebForm);
         $contactWebForm->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $contactWebForm->save();
         assert('$saved');
         $contactWebForm = ContactWebForm::getById($contactWebForm->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($contactWebForm, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $contactWebForm->save();
         $contactWebForms[] = $contactWebForm->id;
     }
     $demoDataHelper->setRangeByModelName('ContactWebForm', $contactWebForms[0], $contactWebForms[count($contactWebForms) - 1]);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:ContactWebFormDemoDataMaker.php

示例10: testWorkflowDoesLinkRelatedModelWhenPermissionsIsSetToOwner

 public function testWorkflowDoesLinkRelatedModelWhenPermissionsIsSetToOwner()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $contactStates = ContactState::getAll();
     $this->assertEquals(0, Contact::getCount());
     //Create workflow
     $workflow = new Workflow();
     $workflow->setDescription('aDescription');
     $workflow->setIsActive(true);
     $workflow->setOrder(5);
     $workflow->setModuleClassName('AccountsModule');
     $workflow->setName('myFirstWorkflow');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTriggersStructure('1');
     //Add action
     $action = new ActionForWorkflowForm('Account', Workflow::TYPE_ON_SAVE);
     $action->type = ActionForWorkflowForm::TYPE_CREATE;
     $action->relation = 'contacts';
     $attributes = array('lastName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'smith'), 'firstName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'john'), 'owner__User' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => Yii::app()->user->userModel->id), 'state' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $contactStates[0]->id));
     $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
     $workflow->addAction($action);
     //Create the saved Workflow
     $savedWorkflow = new SavedWorkflow();
     SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
     $account = new Account();
     $account->name = 'myTestAccount';
     $account->owner = $super;
     $account->save();
     RedBeanModel::forgetAll();
     $contacts = Contact::getAll();
     $this->assertCount(1, $contacts);
     $this->assertEquals('myTestAccount', $contacts[0]->account->name);
     $this->assertEquals('john smith', strval($account->contacts[0]));
     $this->assertTrue($account->contacts[0]->id > 0);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:38,代码来源:AccountPermissionsSuperUserWalkthroughTest.php

示例11: testGetContactsByAnyEmailAddress

 public function testGetContactsByAnyEmailAddress()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $contactStates = ContactState::getAll();
     $this->assertTrue(count($contactStates) > 1);
     $firstContactState = $contactStates[0];
     $contact = new Contact();
     $contact->title->value = 'Mr.';
     $contact->firstName = 'test';
     $contact->lastName = 'contact';
     $contact->owner = $super;
     $contact->state = $firstContactState;
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = 'zurmo@test.com';
     $contact->secondaryEmail = new Email();
     $contact->secondaryEmail->emailAddress = 'zurmo2@test.com';
     $this->assertTrue($contact->save());
     $data = ContactSearch::getContactsByAnyEmailAddress('zurmo@test.com');
     $this->assertEquals(1, count($data));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:21,代码来源:ContactSearchTest.php

示例12: testContactsUtilSetStartingStateByOrder

 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);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:14,代码来源:ContactTest.php

示例13: testUpdateRelatedCatalogItemOnAProductBySellPriceCriteria

 public function testUpdateRelatedCatalogItemOnAProductBySellPriceCriteria()
 {
     $super = User::getByUsername('super');
     $contactStates = ContactState::getAll();
     //Create workflow
     $workflow = new Workflow();
     $workflow->setDescription('aDescription');
     $workflow->setIsActive(true);
     $workflow->setOrder(1);
     $workflow->setModuleClassName('ProductsModule');
     $workflow->setName('myFirstProductWorkflow');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTriggersStructure('1');
     //Add Trigger
     $trigger = new TriggerForWorkflowForm('ProductsModule', 'Product', Workflow::TYPE_ON_SAVE);
     $trigger->attributeIndexOrDerivedType = 'sellPrice';
     $trigger->value = 600;
     $trigger->operator = 'greaterThanOrEqualTo';
     $workflow->addTrigger($trigger);
     //Add action
     $currencies = Currency::getAll();
     $action = new ActionForWorkflowForm('Product', Workflow::TYPE_ON_SAVE);
     $action->type = ActionForWorkflowForm::TYPE_UPDATE_RELATED;
     $action->relation = 'productTemplate';
     $attributes = array('description' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Set Price'), 'priceFrequency' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 2), 'listPrice' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 800, 'currencyId' => $currencies[0]->id), 'cost' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 700, 'currencyId' => $currencies[0]->id));
     $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
     $workflow->addAction($action);
     //Create the saved Workflow
     $savedWorkflow = new SavedWorkflow();
     SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
     $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('superProductTemplate');
     $productTemplates = ProductTemplate::getByName('superProductTemplate');
     $product = ProductTestHelper::createProductByNameForOwner('Test Product', $super);
     $this->assertTrue($product->id > 0);
     $product->productTemplate = $productTemplates[0];
     //Change product sell price
     $product->sellPrice->value = 650;
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $product));
     $saved = $product->save();
     $this->assertTrue($saved);
     $productId = $product->id;
     $product->forget();
     $product = Product::getById($productId);
     $this->assertEquals('Set Price', $product->productTemplate->description);
     $this->assertEquals(2, $product->productTemplate->priceFrequency);
     $this->assertEquals(700, $product->productTemplate->cost->value);
     $this->assertEquals(800, $product->productTemplate->listPrice->value);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:51,代码来源:WorkflowDocumentationTest.php

示例14: testResolveUpdateRelatedActionWithStaticValues

 /**
  * @depends testResolveUpdateActionWithDynamicValues
  */
 public function testResolveUpdateRelatedActionWithStaticValues()
 {
     $contactStates = ContactState::getAll();
     $this->assertTrue($contactStates[0]->id > 0);
     $contactState = $contactStates[0];
     $currency = Currency::getByCode('USD');
     $bobby = User::getByUsername('bobby');
     $workflow = new Workflow();
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setModuleClassName('WorkflowsTest2Module');
     $data = array();
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0]['type'] = ActionForWorkflowForm::TYPE_UPDATE_RELATED;
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0]['relation'] = 'hasMany2';
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0][ActionForWorkflowForm::ACTION_ATTRIBUTES] = array('boolean' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '1'), 'boolean2' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '0'), 'currencyValue' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '362.24', 'currencyId' => $currency->id), 'date' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '2/24/2012'), 'dateTime' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '2/24/2012 03:00 AM'), 'dropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Value 1'), 'float' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '54.25'), 'integer' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '32'), 'likeContactState' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $contactState->id), 'multiDropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => array('Multi Value 1', 'Multi Value 2')), 'owner' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $bobby->id), 'phone' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '8471112222'), 'primaryAddress___street1' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '123 Main Street'), 'primaryEmail___emailAddress' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'info@zurmo.com'), 'radioDropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Radio Value 1'), 'string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'), 'tagCloud' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => array('Tag Value 1', 'Tag Value 2')), 'textArea' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'some description'), 'url' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'http://www.zurmo.com'));
     DataToWorkflowUtil::resolveActions($data, $workflow);
     $actions = $workflow->getActions();
     $this->assertCount(1, $actions);
     $this->assertEquals(ActionForWorkflowForm::TYPE_UPDATE_RELATED, $actions[0]->type);
     $this->assertEquals('hasMany2', $actions[0]->relation);
     $this->assertEquals(ActionForWorkflowForm::RELATION_FILTER_ALL, $actions[0]->relationFilter);
     $this->assertEquals(19, $actions[0]->getActionAttributeFormsCount());
     $this->assertTrue($actions[0]->getActionAttributeFormByName('boolean') instanceof CheckBoxWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('boolean')->type);
     $this->assertEquals('1', $actions[0]->getActionAttributeFormByName('boolean')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('boolean2') instanceof CheckBoxWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('boolean2')->type);
     $this->assertEquals('0', $actions[0]->getActionAttributeFormByName('boolean2')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('currencyValue') instanceof CurrencyValueWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('currencyValue')->type);
     $this->assertEquals(362.24, $actions[0]->getActionAttributeFormByName('currencyValue')->value);
     $this->assertEquals($currency->id, $actions[0]->getActionAttributeFormByName('currencyValue')->currencyId);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('currencyValue')->currencyIdType);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('date') instanceof DateWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('date')->type);
     $this->assertEquals('2012-02-24', $actions[0]->getActionAttributeFormByName('date')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('dateTime') instanceof DateTimeWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('dateTime')->type);
     $compareDateTime = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('2/24/2012 03:00 AM');
     $this->assertEquals($compareDateTime, $actions[0]->getActionAttributeFormByName('dateTime')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('dropDown') instanceof DropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('dropDown')->type);
     $this->assertEquals('Value 1', $actions[0]->getActionAttributeFormByName('dropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('float') instanceof DecimalWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('float')->type);
     $this->assertEquals('54.25', $actions[0]->getActionAttributeFormByName('float')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('integer') instanceof IntegerWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('integer')->type);
     $this->assertEquals('32', $actions[0]->getActionAttributeFormByName('integer')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('likeContactState') instanceof ContactStateWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('likeContactState')->type);
     $this->assertEquals($contactState->id, $actions[0]->getActionAttributeFormByName('likeContactState')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('multiDropDown') instanceof MultiSelectDropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('multiDropDown')->type);
     $this->assertEquals(array('Multi Value 1', 'Multi Value 2'), $actions[0]->getActionAttributeFormByName('multiDropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('owner') instanceof UserWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('owner')->type);
     $this->assertEquals($bobby->id, $actions[0]->getActionAttributeFormByName('owner')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('phone') instanceof PhoneWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('phone')->type);
     $this->assertEquals('8471112222', $actions[0]->getActionAttributeFormByName('phone')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('primaryAddress___street1') instanceof TextWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('primaryAddress___street1')->type);
     $this->assertEquals('123 Main Street', $actions[0]->getActionAttributeFormByName('primaryAddress___street1')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress') instanceof EmailWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress')->type);
     $this->assertEquals('info@zurmo.com', $actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('radioDropDown') instanceof RadioDropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('radioDropDown')->type);
     $this->assertEquals('Radio Value 1', $actions[0]->getActionAttributeFormByName('radioDropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('string') instanceof TextWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('string')->type);
     $this->assertEquals('jason', $actions[0]->getActionAttributeFormByName('string')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('tagCloud') instanceof TagCloudWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('tagCloud')->type);
     $this->assertEquals(array('Tag Value 1', 'Tag Value 2'), $actions[0]->getActionAttributeFormByName('tagCloud')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('textArea') instanceof TextAreaWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('textArea')->type);
     $this->assertEquals('some description', $actions[0]->getActionAttributeFormByName('textArea')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('url') instanceof UrlWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('url')->type);
     $this->assertEquals('http://www.zurmo.com', $actions[0]->getActionAttributeFormByName('url')->value);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:85,代码来源:DataToWorkflowUtilTest.php

示例15: testListAllContactStates

 /**
  * @depends testGetContactState
  */
 public function testListAllContactStates()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $contactStates = ContactState::getAll();
     $this->assertEquals(6, count($contactStates));
     foreach ($contactStates as $contactState) {
         $compareData[] = $this->getModelToApiDataUtilData($contactState);
     }
     $response = $this->createApiCallWithRelativeUrl('list/', 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(6, count($response['data']['items']));
     $this->assertEquals(6, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals($compareData, $response['data']['items']);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:22,代码来源:ApiRestContactStateTest.php


注:本文中的ContactState::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。