3 require_once('modules/Accounts/Account.php');
5 class Bug39756Test extends Sugar_PHPUnit_Framework_TestCase
9 public function setUp()
11 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
12 $this->_account = new Account();
13 $this->_account->name = 'Account_'.create_guid();
14 $this->_account->save();
18 public function tearDown()
20 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
21 unset($GLOBALS['current_user']);
22 $sql = "DELETE FROM accounts where id = '{$this->_account->id}'";
23 $GLOBALS['db']->query($sql);
26 public function testUpdateDateEnteredWithValue()
28 global $disable_date_format;
29 $disable_date_format = true;
31 $newDateEntered = '2011-01-28 11:05:10';
32 $oldDateEntered = $this->_account->date_entered;
34 $this->_account->update_date_entered = true;
35 $this->_account->date_entered = $newDateEntered;
36 $this->_account->save();
38 $acct = new Account();
39 $acct->retrieve($this->_account->id);
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");
45 public function testNoUpdateDateEnteredWithValue()
47 global $disable_date_format;
48 $disable_date_format = true;
50 $newDateEntered = '2011-01-28 11:05:10';
51 $oldDateEntered = $this->_account->date_entered;
53 $this->_account->date_entered = $newDateEntered;
54 $this->_account->save();
56 $acct = new Account();
57 $acct->retrieve($this->_account->id);
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");