2 require_once('modules/Contacts/Contact.php');
8 class ComposePackageTest extends Sugar_PHPUnit_Framework_TestCase
14 public function setUp()
16 global $current_user, $currentModule ;
17 $mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
20 require('include/modules.php');
21 $GLOBALS['beanList'] = $beanList;
22 $GLOBALS['beanFiles'] = $beanFiles;
23 $current_user = SugarTestUserUtilities::createAnonymousUser();
25 $time = date('Y-m-d H:i:s');
27 $contact = new Contact();
28 $contact->id = 'c_'.$unid;
29 $contact->first_name = 'testfirst';
30 $contact->last_name = 'testlast';
31 $contact->new_with_id = true;
32 $contact->disable_custom_fields = true;
37 public function tearDown()
39 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
40 unset($GLOBALS['current_user']);
41 unset($GLOBALS['beanFiles']);
42 unset($GLOBALS['beanList']);
44 $GLOBALS['db']->query("DELETE FROM contacts WHERE id= '{$this->c->id}'");
49 public function testComposeFromMethodCallNoData()
51 $_REQUEST['forQuickCreate'] = true;
52 require_once('modules/Emails/Compose.php');
54 $compose_data = generateComposeDataPackage($data,FALSE);
56 $this->assertEquals('', $compose_data['to_email_addrs']);
59 public function testComposeFromMethodCallForContact()
61 $_REQUEST['forQuickCreate'] = true;
62 require_once('modules/Emails/Compose.php');
64 $data['parent_type'] = 'Contacts';
65 $data['parent_id'] = $this->c->id;
67 $compose_data = generateComposeDataPackage($data,FALSE);
69 $this->assertEquals('Contacts', $compose_data['parent_type']);
70 $this->assertEquals($this->c->id, $compose_data['parent_id']);
71 $this->assertEquals($this->c->name, $compose_data['parent_name']);