]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/SugarMerge/Bug36481Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / SugarMerge / Bug36481Test.php
1 <?php
2 require_once 'include/dir_inc.php';
3
4 class Bug36481Test extends Sugar_PHPUnit_Framework_TestCase  {
5
6 var $ev_merge;
7 var $has_contacts_dir = false;
8 var $has_suback_file = false;
9
10 function setUp() {
11    global $current_user;
12    if(!isset($current_user)) {
13           $current_user = SugarTestUserUtilities::createAnonymousUser();
14    }
15    if(!file_exists("custom/modules/Contacts/metadata")){
16           mkdir_recursive("custom/modules/Contacts/metadata", true);
17    }
18    
19    if(file_exists('custom/modules/Contacts/metadata/editviewdefs.php')) {
20           $this->has_contacts_dir = true;
21           copy('custom/modules/Contacts/metadata/editviewdefs.php', 'custom/modules/Contacts/metadata/editviewdefs.php.bak');
22    }
23    
24    $this->has_suback_file = file_exists('custom/modules/Contacts/metadata/editviewdefs.php.suback.php');
25    
26    copy('tests/modules/UpgradeWizard/SugarMerge/metadata_files/custom/modules/Contacts/metadata/editviewdefs.php', 'custom/modules/Contacts/metadata/editviewdefs.php');
27 }
28
29 function tearDown() {
30         return;
31    if(!$this->has_contacts_dir) {
32           rmdir_recursive('custom/modules/Contacts');
33    }  else if(file_exists('custom/modules/Contacts/metadata/editviewdefs.php.bak')) {
34           copy('custom/modules/Contacts/metadata/editviewdefs.php.bak', 'custom/modules/Contacts/metadata/editviewdefs.php');
35       unlink('custom/modules/Contacts/metadata/editviewdefs.php.bak');
36       
37       if(!$this->has_suback_file) {
38              unlink('custom/modules/Contacts/metadata/editviewdefs.php.suback.php');
39           }
40    }
41    
42
43 }
44
45 function test_contacts_editview_merge() {
46    require_once('modules/UpgradeWizard/SugarMerge/EditViewMerge.php');  
47    $this->ev_merge = new EditViewMerge();       
48    $this->ev_merge->merge('Contacts', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/550/modules/Contacts/metadata/editviewdefs.php', 'modules/Contacts/metadata/editviewdefs.php', 'custom/modules/Contacts/metadata/editviewdefs.php');
49    $this->assertTrue(file_exists('custom/modules/Contacts/metadata/editviewdefs.php.suback.php'));
50    require('custom/modules/Contacts/metadata/editviewdefs.php');
51    $fields = array();
52    foreach($viewdefs['Contacts']['EditView']['panels'] as $panel) {
53           foreach($panel as $row) {
54                  foreach($row as $col_key=>$col) {
55                         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
56                         $fields[$id] = $col;
57                  }
58           }
59    }
60    
61    $this->assertTrue(isset($fields['test_c']), 'Assert that test_c custom field exists');
62 }
63
64
65 }
66
67 ?>