4 * This test verifies the fixes to properly store the items in the BreadCrumbStack class
8 require_once 'SugarTestUserUtilities.php';
9 require_once 'SugarTestAccountUtilities.php';
10 require_once 'SugarTestContactUtilities.php';
11 require_once 'modules/Trackers/TrackerManager.php';
13 class Bug40019_Test extends Sugar_PHPUnit_Framework_TestCase
15 private $anonymous_user;
16 private $saved_current_user;
18 public function setUp()
20 $this->anonymous_user = SugarTestUserUtilities::createAnonymousUser();
21 if(!empty($GLOBALS['current_user']))
23 $this->saved_current_user = $GLOBALS['current_user'];
25 $GLOBALS['current_user'] = $this->anonymous_user;
30 $account = SugarTestAccountUtilities::createAccount();
31 $contact = SugarTestContactUtilities::createContact();
33 $trackerManager = TrackerManager::getInstance();
34 $trackerManager->unPause();
35 if($monitor = $trackerManager->getMonitor('tracker')) {
36 $monitor->setEnabled(true);
38 $monitor->setValue('date_modified', gmdate($GLOBALS['timedate']->get_db_date_time_format()));
39 $monitor->setValue('user_id', $GLOBALS['current_user']->id);
40 $monitor->setValue('module_name', $account->module_dir);
41 $monitor->setValue('action', 'detailview');
42 $monitor->setValue('item_id', $account->id);
43 $monitor->setValue('item_summary', $account->name);
44 $monitor->setValue('visible',1);
45 $trackerManager->saveMonitor($monitor, true, true);
47 $monitor = $trackerManager->getMonitor('tracker');
48 $monitor->setValue('date_modified', gmdate($GLOBALS['timedate']->get_db_date_time_format()));
49 $monitor->setValue('user_id', $GLOBALS['current_user']->id);
50 $monitor->setValue('module_name', $contact->module_dir);
51 $monitor->setValue('action', 'detailview');
52 $monitor->setValue('item_id', $contact->id);
53 $monitor->setValue('item_summary', $contact->name);
54 $monitor->setValue('visible',1);
55 $trackerManager->saveMonitor($monitor, true, true);
60 public function tearDown()
62 $GLOBALS['db']->query("DELETE FROM tracker WHERE user_id = '{$this->anonymous_user->id}'");
63 SugarTestAccountUtilities::removeAllCreatedAccounts();
64 SugarTestContactUtilities::removeAllCreatedContacts();
65 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
66 if(!empty($this->saved_current_user))
68 $GLOBALS['current_user'] = $this->saved_current_user;
74 public function testBreadCrumbStack()
76 $GLOBALS['sugar_config']['history_max_viewed'] = 50;
77 $breadCrumbStack = new BreadCrumbStack($GLOBALS['current_user']->id);
78 $list = $breadCrumbStack->getBreadCrumbList('Accounts');
79 $this->assertEquals(count($list), 10, 'Assert that there are 10 entries for Accounts module');
81 $list = $breadCrumbStack->getBreadCrumbList('Contacts');
82 $this->assertEquals(count($list), 10, 'Assert that there are 10 entries for Contacts module');
85 $GLOBALS['sugar_config']['history_max_viewed'] = 10;
86 $breadCrumbStack = new BreadCrumbStack($GLOBALS['current_user']->id);
87 $list = $breadCrumbStack->getBreadCrumbList(array('Accounts', 'Contacts'));
90 foreach($list as $list_entry)
92 switch ($list_entry['module_name'])
103 $this->assertEquals($contacts, 5, 'Assert there are 5 entries found for Contacts using array filter of Contacts & Accounts');
104 $this->assertEquals($accounts, 5, 'Assert there are 5 entries found for Accounts using array filter of Contacts & Accounts');