]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/SugarMerge/Bug43211Test.php
Release 6.2.0RC1
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / SugarMerge / Bug43211Test.php
1 <?php
2 require_once 'include/dir_inc.php';
3
4 class Bug43211Test extends Sugar_PHPUnit_Framework_TestCase  {
5         
6 var $merge;
7
8 function setUp() {
9    SugarTestMergeUtilities::setupFiles(array('Leads', 'Accounts'), array('searchdefs'), 'tests/modules/UpgradeWizard/SugarMerge/metadata_files');
10 }
11
12
13 function tearDown() {
14    SugarTestMergeUtilities::teardownFiles();
15 }
16
17 function test_leads_searchdefs_merge() {        
18    require_once 'modules/UpgradeWizard/SugarMerge/SearchMerge.php';             
19    $this->merge = new SearchMerge();
20    $this->merge->merge('Leads', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/600/modules/Leads/metadata/searchdefs.php', 'modules/Leads/metadata/searchdefs.php', 'custom/modules/Leads/metadata/searchdefs.php');
21    $this->assertTrue(file_exists('custom/modules/Leads/metadata/searchdefs.php.suback.php'));
22    require('custom/modules/Leads/metadata/searchdefs.php');
23    
24    //Here's the main test... check to see that maxColumns has been changed to 3
25    $this->assertEquals($searchdefs['Leads']['templateMeta']['maxColumns'], '3', 'Assert that maxColumns remains set to 3 for Leads module'); 
26    $fields = array();
27    foreach($searchdefs['Leads']['layout']['basic_search'] as $col_key=>$col) {
28         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
29         if(!empty($id) && !is_array($id)) {
30                    $fields[$id] = $col;
31                 }
32    }
33   
34    $this->assertTrue(count($fields) == 3, "Assert that there are 3 fields in the basic_search layout for Leads metadata");
35    $this->assertTrue(isset($fields['search_name']), "Assert that search_name field is present");
36    $this->assertTrue(isset($fields['team_name']), "Assert that team_name field is present");
37    $this->assertTrue(isset($fields['current_user_only']), "Assert that current_user_only field is present");
38    $this->assertFalse(isset($fields['open_only']), "Assert that 620 OOTB open_only field is not added since there was a customization");
39    
40    $this->assertEquals($searchdefs['Leads']['templateMeta']['maxColumnsBasic'], $searchdefs['Leads']['templateMeta']['maxColumns'], 'Assert that maxColumnsBasic is set to value of maxColumns');   
41 }
42
43
44 function test_accounts_searchdefs_merge() {     
45    require_once 'modules/UpgradeWizard/SugarMerge/SearchMerge.php';             
46    $this->merge = new SearchMerge();
47    $this->merge->merge('Accounts', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/600/modules/Accounts/metadata/searchdefs.php', 'modules/Accounts/metadata/searchdefs.php', 'custom/modules/Accounts/metadata/searchdefs.php');
48    $this->assertTrue(file_exists('custom/modules/Accounts/metadata/searchdefs.php.suback.php'));
49    require('custom/modules/Accounts/metadata/searchdefs.php');
50    //echo var_export($searchdefs['Accounts'], true);
51    
52    //Here's the main test... check to see that maxColumns is still 3 since Accounts is not a module with maxColumn altered OOTB
53    $this->assertEquals($searchdefs['Accounts']['templateMeta']['maxColumns'], '3', 'Assert that maxColumns is still 3 for Accounts module'); 
54    $fields = array();
55    foreach($searchdefs['Accounts']['layout']['basic_search'] as $col_key=>$col) {
56         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
57         if(!empty($id) && !is_array($id)) {
58                    $fields[$id] = $col;
59                 }
60    }
61   
62    $this->assertTrue(count($fields) == 3, "Assert that there are 3 fields in the basic_search layout for Leads metadata");
63    $this->assertTrue(isset($fields['name']), "Assert that name field is present");
64    $this->assertTrue(isset($fields['created_by_name']), "Assert that created_by_name field is present");
65    $this->assertTrue(isset($fields['current_user_only']), "Assert that current_user_only field is present");
66    $this->assertFalse(isset($fields['open_only']), "Assert that 620 OOTB open_only field is not added since there was a customization");
67    
68    $this->assertEquals($searchdefs['Accounts']['templateMeta']['maxColumnsBasic'], $searchdefs['Accounts']['templateMeta']['maxColumns'], 'Assert that maxColumnsBasic is set to value of maxColumns');
69 }
70
71 }
72 ?>