示例#1
0
 public function testrefreshHooks()
 {
     //execute the method and test if it doesn't throws an exception
     try {
         LogicHook::refreshHooks();
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->fail();
     }
 }
 public function tearDown()
 {
     foreach ($this->renames as $file) {
         rename($file . ".bak", $file);
     }
     foreach ($this->deletes as $file) {
         unlink($file);
     }
     unset($GLOBALS['logic_hook']);
     LogicHook::refreshHooks();
 }
示例#3
0
 public function setUp()
 {
     $this->user = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['current_user'] = $this->user;
     //Setup logichook files
     if (file_exists($this->casesHookFile)) {
         $this->hasCustomCasesLogicHookFile = true;
         copy($this->casesHookFile, $this->casesHookFile . '.bak');
     }
     $hook_array['after_relationship_add'][] = array(1, 'Cases increment count', $this->casesCountFile, 'CaseCount', 'countMe');
     write_array_to_file("hook_array", $hook_array, $this->casesHookFile);
     $this->useOutputBuffering = false;
     LogicHook::refreshHooks();
     //now  write out the script that the logichook executes.  This will keep track of times called
     global $hookRunCount;
     $hookRunCount = 0;
     $fileCont = '<?php class CaseCount {
         function countMe($bean, $event, $arguments){
             global $hookRunCount;
             if($event =="after_relationship_add" && $arguments["module"]=="Cases" && $arguments["related_module"]=="Emails")
                 $hookRunCount++;
             }}?>';
     file_put_contents($this->casesCountFile, $fileCont);
     //setup test account for case
     $this->account = new Account();
     $this->account->name = 'test account for bug 39855';
     $this->account->assigned_user_id = 'SugarUser';
     $this->account->save();
     //create case
     $this->case = new aCase();
     $this->case->name = 'test case for unitTest 49784';
     $this->case->account_id = $this->account->id;
     $this->case->status = 'New';
     $this->case->save();
     //retrieve so we have latest info (case number)
     $this->case->retrieve($this->case->id);
     //create email with case in subject
     $this->email = new Email();
     $this->email->type = 'inbound';
     $this->email->status = 'unread';
     $this->email->from_addr_name = $this->email->cleanEmails("*****@*****.**");
     $this->email->to_addrs_names = $this->email->cleanEmails("*****@*****.**");
     $this->email->cc_addrs_names = $this->email->cleanEmails("*****@*****.**");
     $this->email->name = 'RE: [CASE:' . $this->case->case_number . '] ' . $this->case->name;
     $this->email->save();
 }
示例#4
0
 public function setUp()
 {
     //Setup mock logic hook files
     if (file_exists($this->modulesHookFile)) {
         $this->hasCustomModulesLogicHookFile = true;
         copy($this->modulesHookFile, $this->modulesHookFile . '.bak');
     } else {
         write_array_to_file("test", array(), $this->modulesHookFile);
     }
     if (file_exists($this->contactsHookFile)) {
         $this->hasCustomContactLogicHookFile = true;
         copy($this->contactsHookFile, $this->contactsHookFile . '.bak');
     } else {
         write_array_to_file("test", array(), $this->contactsHookFile);
     }
     $this->useOutputBuffering = false;
     LogicHook::refreshHooks();
 }
示例#5
0
 public function setUp()
 {
     $this->bean = new Account();
     Bug52113TestHook::$count = 0;
     LogicHook::refreshHooks();
 }