]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/OutboundEmail/Bug32487Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / OutboundEmail / Bug32487Test.php
1 <?php 
2 require_once('include/OutboundEmail/OutboundEmail.php');
3
4 /**
5  * @group bug32487
6  */
7 class Bug32487Test extends Sugar_PHPUnit_Framework_TestCase
8 {
9         var $ib = null;
10         var $outbound_id = null;
11         
12         public function setUp()
13     {
14         global $current_user, $currentModule ;
15                 $mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
16                 $current_user = SugarTestUserUtilities::createAnonymousUser();
17                 $this->outbound_id = uniqid();
18                 $time = date('Y-m-d H:i:s');
19
20                 $ib = new InboundEmail();
21                 $ib->is_personal = 1;
22                 $ib->name = "Test";
23                 $ib->port = 3309;
24                 $ib->mailbox = 'empty';
25                 $ib->created_by = $current_user->id;
26                 $ib->email_password = "pass";
27                 $ib->protocol = 'IMAP';
28                 $stored_options['outbound_email'] = $this->outbound_id;
29             $ib->stored_options = base64_encode(serialize($stored_options));
30             $ib->save();
31             $this->ib = $ib;
32         }
33
34     public function tearDown()
35     {
36         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
37         unset($GLOBALS['current_user']);
38         
39         $GLOBALS['db']->query("DELETE FROM inbound_email WHERE id= '{$this->ib->id}'");
40         
41         unset($this->ib);
42     }
43     
44         function testGetAssoicatedInboundAccountForOutboundAccounts(){
45             global $current_user;
46             $ob = new OutboundEmail();
47             $ob->id = $this->outbound_id;
48                 
49             $results = $ob->getAssociatedInboundAccounts($current_user);
50         $this->assertEquals($this->ib->id, $results[0], "Could not retrieve the inbound mail accounts for an outbound account");
51         
52         $obEmpty = new OutboundEmail();
53         $obEmpty->id = uniqid();
54                 
55             $empty_results = $obEmpty->getAssociatedInboundAccounts($current_user);
56         $this->assertEquals(0, count($empty_results), "Outbound email account returned for unspecified/empty inbound mail account.");
57     }
58 }
59 ?>