]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/SugarMerge/Bug43226Test.php
Release 6.2.0RC1
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / SugarMerge / Bug43226Test.php
1 <?php
2 require_once 'include/dir_inc.php';
3
4 class Bug43226Test extends Sugar_PHPUnit_Framework_TestCase  {
5         
6 var $merge;
7
8 function setUp() {
9    SugarTestMergeUtilities::setupFiles(array('Documents'), array('editviewdefs'), 'tests/modules/UpgradeWizard/SugarMerge/metadata_files');
10 }
11
12
13 function tearDown() {
14    SugarTestMergeUtilities::teardownFiles();
15 }
16
17 function test_uploadfile_convert_merge_600() {
18    require_once 'modules/UpgradeWizard/SugarMerge/EditViewMerge.php';
19    $this->merge = new EditViewMerge();
20    $this->merge->merge('Documents', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/600/modules/Documents/metadata/editviewdefs.php','modules/Documents/metadata/editviewdefs.php','custom/modules/Documents/metadata/editviewdefs.php');
21
22    require('custom/modules/Documents/metadata/editviewdefs.php');
23
24    $foundUploadFile = 0;
25    $foundFilename = 0;
26
27    foreach ( $viewdefs['Documents']['EditView']['panels'] as $panel ) {
28        foreach ( $panel as $row ) {
29            foreach ( $row as $col ) {
30                if ( is_array($col) ) {
31                    $fieldName = $col['name'];
32                } else {
33                    $fieldName = $col;
34                }
35                
36                if ( $fieldName == 'filename' ) {
37                    $foundFilename++;
38                } else if ( $fieldName == 'uploadfile' ) {
39                    $foundUploadFile++;
40                }
41            }
42        }
43    }
44    
45    $this->assertTrue($foundUploadFile==0,'Uploadfile field still exists, should be filename');
46    $this->assertTrue($foundFilename>0,'Filename field doesn\'t exit, it should');
47
48    if ( file_exists('custom/modules/Documents/metadata/editviewdefs-testback.php') ) {
49        copy('custom/modules/Documents/metadata/editviewdefs-testback.php','custom/modules/Documents/metadata/editviewdefs.php');
50        unlink('custom/modules/Documents/metadata/editviewdefs-testback.php');
51    }
52 }
53
54 function test_uploadfile_convert_merge_610() {
55    require_once 'modules/UpgradeWizard/SugarMerge/EditViewMerge.php';
56    $this->merge = new EditViewMerge();
57    $this->merge->merge('Documents', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/610/modules/Documents/metadata/editviewdefs.php','modules/Documents/metadata/editviewdefs.php','custom/modules/Documents/metadata/editviewdefs.php');
58
59    require('custom/modules/Documents/metadata/editviewdefs.php');
60
61    $foundUploadFile = 0;
62    $foundFilename = 0;
63
64    foreach ( $viewdefs['Documents']['EditView']['panels'] as $panel ) {
65        foreach ( $panel as $row ) {
66            foreach ( $row as $col ) {
67                if ( is_array($col) ) {
68                    $fieldName = $col['name'];
69                } else {
70                    $fieldName = $col;
71                }
72                
73                if ( $fieldName == 'filename' ) {
74                    $foundFilename++;
75                } else if ( $fieldName == 'uploadfile' ) {
76                    $foundUploadFile++;
77                }
78            }
79        }
80    }
81    
82    $this->assertTrue($foundUploadFile==0,'Uploadfile field still exists, should be filename');
83    $this->assertTrue($foundFilename>0,'Filename field doesn\'t exit, it should');
84
85    if ( file_exists('custom/modules/Documents/metadata/editviewdefs-testback.php') ) {
86        copy('custom/modules/Documents/metadata/editviewdefs-testback.php','custom/modules/Documents/metadata/editviewdefs.php');
87        unlink('custom/modules/Documents/metadata/editviewdefs-testback.php');
88    }
89 }
90
91 }