]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Import/Bug39756Test.php
Release 6.3.0beta1
[Github/sugarcrm.git] / tests / modules / Import / Bug39756Test.php
1 <?php
2
3 require_once('modules/Accounts/Account.php');
4
5 class Bug39756Test extends Sugar_PHPUnit_Framework_TestCase
6 {
7     var $_account = null;
8
9     public function setUp() 
10     {
11         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
12         $this->_account = new Account();
13         $this->_account->name = 'Account_'.create_guid();
14         $this->_account->save();
15
16     }
17     
18     public function tearDown() 
19     {
20         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
21         unset($GLOBALS['current_user']);
22         $sql = "DELETE FROM accounts where id = '{$this->_account->id}'";
23         $GLOBALS['db']->query($sql);
24     }
25     
26     public function testUpdateDateEnteredWithValue()
27     {
28         global $disable_date_format;
29         $disable_date_format = true;
30
31        $newDateEntered = '2011-01-28 11:05:10';
32        $oldDateEntered = $this->_account->date_entered;
33
34        $this->_account->update_date_entered = true;
35        $this->_account->date_entered = $newDateEntered;
36        $this->_account->save();
37
38        $acct = new Account();
39        $acct->retrieve($this->_account->id);
40        
41        $this->assertNotEquals($acct->date_entered, $oldDateEntered, "Account date_entered should not be equal to old date_entered");
42        $this->assertEquals($acct->date_entered, $newDateEntered, "Account date_entered should be equal to old date_entered");
43     }
44
45     public function testNoUpdateDateEnteredWithValue()
46     {
47         global $disable_date_format;
48         $disable_date_format = true;
49
50        $newDateEntered = '2011-01-28 11:05:10';
51        $oldDateEntered = $this->_account->date_entered;
52
53        $this->_account->date_entered = $newDateEntered;
54        $this->_account->save();
55
56        $acct = new Account();
57        $acct->retrieve($this->_account->id);
58        
59        $this->assertEquals($acct->date_entered, $oldDateEntered, "Account date_entered should be equal to old date_entered");
60        $this->assertNotEquals($acct->date_entered, $newDateEntered, "Account date_entered should not be equal to old date_entered");
61     }
62 }