]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/SugarMerge/Bug37850Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / SugarMerge / Bug37850Test.php
1 <?php
2 require_once 'include/dir_inc.php';
3
4 class Bug37850Test extends Sugar_PHPUnit_Framework_TestCase  {
5
6 var $merge;
7
8 function setUp() {
9    SugarTestMergeUtilities::setupFiles(array('Leads'), array('detailviewdefs'), 'tests/modules/UpgradeWizard/SugarMerge/od_metadata_files');
10 }
11
12
13 function tearDown() {
14    SugarTestMergeUtilities::teardownFiles();
15 }
16
17
18 function test_600_leads_detailview_merge() {                    
19    $this->assertTrue(file_exists('custom/modules/Leads/metadata/detailviewdefs.php'));  
20    require('custom/modules/Leads/metadata/detailviewdefs.php');
21    $pre_upgrade_fields = array();
22    $pre_upgrade_panels = array();
23    foreach($viewdefs['Leads']['DetailView']['panels'] as $panel_key=>$panel) {
24           $pre_upgrade_panels[$panel_key] = $panel_key;
25           foreach($panel as $row) {
26                  foreach($row as $col_key=>$col) {
27                         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
28                         if(!empty($id) && !is_array($id)) {
29                            $pre_upgrade_fields[$id] = $col;
30                         }
31                  }
32           }
33    }    
34         
35    $this->assertTrue(isset($pre_upgrade_fields['created_by']), 'Assert that the created_by index existed in 551 metadata file');
36    $this->assertTrue(!isset($pre_upgrade_fields['date_entered']), 'Assert that the date_entered did not exist in 551 metadata file');
37    
38    require_once('modules/UpgradeWizard/SugarMerge/DetailViewMerge.php');
39    $this->merge = new DetailViewMerge();        
40    $this->merge->merge('Leads', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/551/modules/Leads/metadata/detailviewdefs.php', 'modules/Leads/metadata/detailviewdefs.php', 'custom/modules/Leads/metadata/detailviewdefs.php');
41    $this->assertTrue(file_exists('custom/modules/Leads/metadata/detailviewdefs.php.suback.php'));
42    require('custom/modules/Leads/metadata/detailviewdefs.php');
43    $fields = array();
44    $new_fields = array();
45    foreach($viewdefs['Leads']['DetailView']['panels'] as $panel) {
46           foreach($panel as $row) {
47                  foreach($row as $col_key=>$col) {
48                         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
49                         $fields[$id] = $col;
50                     if(!empty($id) && !isset($pre_upgrade_fields[$id])) {
51                            $new_fields[$id] = $id;
52                         }                       
53                  }
54           }
55    }
56    
57    $this->assertTrue(!isset($new_fields['created_by']), 'Assert that the created_by index does not exists in the merged metadata file');
58    $this->assertTrue(isset($new_fields['date_entered']), 'Assert that the date_entered field now exists in the merged metadata file');
59 }
60
61
62
63
64 }
65
66 ?>