]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Emails/Bug40527Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / Emails / Bug40527Test.php
1 <?php 
2 require_once('modules/Emails/Email.php');
3
4 class Bug40527Test extends Sugar_PHPUnit_Framework_TestCase
5 {
6     private $contact;
7     private $account;
8     private $email;
9     
10         public function setUp()
11     {
12         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
13         $this->contact = SugarTestContactUtilities::createContact();
14         $this->account = SugarTestAccountUtilities::createAccount();
15         
16         $override_data = array(
17             'parent_type' => 'Accounts',
18             'parent_id' => $this->account->id,
19         );
20         $this->email   = SugarTestEmailUtilities::createEmail('', $override_data);
21         }
22
23     public function tearDown()
24     {
25         SugarTestContactUtilities::removeAllCreatedContacts();
26         SugarTestAccountUtilities::removeAllCreatedAccounts();
27         SugarTestEmailUtilities::removeAllCreatedEmails();
28         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
29         unset($GLOBALS['current_user']);
30     }
31     
32     public function testContactRelationship()
33     {
34         $this->assertTrue($this->email->parent_type == 'Accounts', "The email parent_type should be Accounts");
35         $this->assertTrue($this->email->parent_id == $this->account->id, "The email parent_id should be SDizzle");
36         
37         $this->email->fill_in_additional_detail_fields();
38         $this->assertTrue(empty($this->email->contact_id), "There should be no contact associated with the Email");
39     }
40 }