createCustom(); $this->acc = SugarTestAccountUtilities::createAccount(); $this->acc2 = SugarTestAccountUtilities::createAccount(); } public function tearDown() { $this->custField->delete($this->df); $_REQUEST['repair_silent']=1; $rc = new RepairAndClear(); $rc->repairAndClearAll(array("clearAll", "rebuildExtensions"), array("Accounts"), false, false); SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); SugarTestAccountUtilities::removeAllCreatedAccounts(); SugarTestHelper::tearDown(); $GLOBALS['reload_vardefs'] = true; $o = new Account(); $GLOBALS['reload_vardefs'] = false; } public function createCustom(){ //create new varchar widget and associate with Accounts $this->custField = get_widget('varchar'); $this->custField->id = 'Accounts'.$this->custFieldName; $this->custField->name = $this->custFieldName; $this->custField->type = 'varchar'; $this->custField->label = 'LBL_' . strtoupper($this->custFieldName); $this->custField->vname = 'LBL_' . strtoupper($this->custFieldName); $this->custField->len = 255; $this->custField->custom_module = 'Accounts'; $this->custField->required = 0; $this->custField->default = 'goofy'; $this->acc = new Account(); $this->df = new DynamicField('Accounts'); $this->df->setup($this->acc); $this->df->addFieldObject($this->custField); $this->df->buildCache('Accounts'); $this->custField->save($this->df); VardefManager::clearVardef(); VardefManager::refreshVardefs('Accounts', 'Account'); //Now create the meta files to make this a Calculated Field. $fn = $this->custFieldName; $extensionContent = <<custFileDirPath = create_custom_directory($this->custFileDirPath); $fileLoc = $this->custFileDirPath.'sugarfield_'.$this->custFieldName.'.php'; file_put_contents($fileLoc, $extensionContent); //run repair and clear to make sure the meta gets picked up $_REQUEST['repair_silent']=1; $rc = new RepairAndClear(); $rc->repairAndClearAll(array("clearAll", "rebuildExtensions"), array("Accounts"), false, false); $fn = $this->custFieldName; } public function testMergeWithCalculatedField() { //recreate expected request and post superglobals for savemerge.php $_REQUEST = $_POST = array( 'module' => 'MergeRecords', 'record' => $this->acc->id, 'merge_module' => 'Accounts', 'action' => 'SaveMerge', 'return_module' => 'Accounts', 'return_action' => 'index', 'change_parent' => 0, 'remove' => 0, 'merged_links' => 'assigned_user_link,member_of', 'merged_ids' => array ($this->acc2->id), 'button' => 'Save Merge', 'name' => 'SugarAccount1091847479', 'date_entered' => '04/08/2013 03:18pm', 'date_modified' => '04/08/2013 03:18pm', 'team_name' => 'team_name', 'team_name_field' => 'team_name_table', 'team_name_collection_0' => 'Global', 'id_team_name_collection_0' => 1, 'primary_team_name_collection' => 0, 'noRedirect' => 1, ); //call SaveMerge so the account beans can be merged require_once('modules/MergeRecords/SaveMerge.php'); //make sure fatal error is not being output $this->expectOutputNotRegex('/fatal/i', 'Failure message is appearing during merge'); } }