obj = new Contact(); } public function tearDown() { if (! empty($this->obj->id)) { $this->obj->db->query("DELETE FROM contacts WHERE id = '" . $this->obj->id . "'"); } unset($this->obj); } public function testAuditForRelatedFields() { $test_account_name = 'test account name after'; $account = SugarTestAccountUtilities::createAccount(); $this->obj->field_defs['account_name']['audited'] = 1; $this->obj->name = 'test'; $this->obj->account_id = $account->id; $this->obj->save(); $this->obj->retrieve(); $this->obj->account_name = $test_account_name; $changes = $this->obj->db->getAuditDataChanges($this->obj); $this->assertEquals($changes['account_name']['after'], $test_account_name); SugarTestAccountUtilities::removeAllCreatedAccounts(); } }