]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/MVC/View/Bug40019Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / MVC / View / Bug40019Test.php
1 <?php 
2 require_once('include/MVC/View/SugarView.php');
3
4 class Bug40019Test extends Sugar_PHPUnit_Framework_TestCase
5 {   
6     public function setUp() 
7         {
8         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
9         
10             global $sugar_config;
11             $max = $sugar_config['history_max_viewed'];
12             
13             $contacts = array();
14             for($i = 0; $i < $max + 1; $i++){
15                 $contacts[$i] = SugarTestContactUtilities::createContact();
16                 SugarTestTrackerUtility::insertTrackerEntry($contacts[$i], 'detailview');
17             }
18         
19             for($i = 0; $i < $max + 1; $i++){
20                 $account[$i] = SugarTestAccountUtilities::createAccount();
21             SugarTestTrackerUtility::insertTrackerEntry($account[$i], 'detailview');
22             }
23             
24             $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
25         }
26         
27         public function tearDown() 
28         {
29             SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
30             SugarTestContactUtilities::removeAllCreatedContacts();
31             SugarTestAccountUtilities::removeAllCreatedAccounts();
32             SugarTestTrackerUtility::removeAllTrackerEntries();
33         unset($GLOBALS['current_user']);
34         unset($GLOBALS['app_strings']);
35         }
36         
37         // Currently, getBreadCrumbList in BreadCrumbStack.php limits you to 10
38         // Also, the Constructor in BreadCrumbStack.php limits it to 10 too.
39     /*
40      * @group bug40019
41      */
42         public function testModuleMenuLastViewedForModule()
43         {
44             global $sugar_config;
45             $max = $sugar_config['history_max_viewed'];
46             
47             $tracker = new Tracker();
48             $history = $tracker->get_recently_viewed($GLOBALS['current_user']->id, 'Contacts');
49             
50             $expected = $max > 10 ? 10 : $max;
51         
52         $this->assertTrue(count($history) == $expected);
53         }
54     
55         // Currently, getBreadCrumbList in BreadCrumbStack.php limits you to 10
56     /*
57      * @group bug40019
58      */
59         public function testModuleMenuLastViewedForAll()
60         {
61             global $sugar_config;
62             $max = $sugar_config['history_max_viewed'];
63             
64             $tracker = new Tracker();
65             $history = $tracker->get_recently_viewed($GLOBALS['current_user']->id, '');
66             
67             $expected = $max > 10 ? 10 : $max;
68             
69         $this->assertTrue(count($history) == $expected);
70         }
71 }