]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/UpgradeWizard/SugarMerge/Bug37921Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / modules / UpgradeWizard / SugarMerge / Bug37921Test.php
1 <?php
2 require_once 'include/dir_inc.php';
3
4 class Bug37921Test extends Sugar_PHPUnit_Framework_TestCase  {
5
6 var $merge;
7
8 function setUp() {
9    SugarTestMergeUtilities::setupFiles(array('Notes'), array('searchdefs'), 'tests/modules/UpgradeWizard/SugarMerge/od_metadata_files');
10 }
11
12
13 function tearDown() {
14    SugarTestMergeUtilities::teardownFiles();
15 }
16
17
18 function test_elster_notes_searchdefs_merge() {                 
19    require_once 'modules/UpgradeWizard/SugarMerge/SearchMerge.php';             
20    $this->merge = new SearchMerge();    
21    $this->merge->merge('Notes', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/551/modules/Notes/metadata/searchdefs.php', 'modules/Notes/metadata/searchdefs.php', 'custom/modules/Notes/metadata/searchdefs.php');
22    $this->assertTrue(file_exists('custom/modules/Notes/metadata/searchdefs.php.suback.php'));
23    require('custom/modules/Notes/metadata/searchdefs.php');
24    $fields = array();
25    
26
27    foreach($searchdefs['Notes']['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) == 2, "Assert that there are 2 fields in the basic_search layout for Notes metadata");
35    
36    $fields = array();
37    foreach($searchdefs['Notes']['layout']['advanced_search'] as $col_key=>$col) {
38         $id = is_array($col) && isset($col['name']) ? $col['name'] : $col;
39         if(!empty($id)) {
40                 $fields[$id] = $col;
41         }
42    }
43    $this->assertTrue(count($fields) == 7, "Assert that there are 7 fields in the advanced_search layout for Notes metadata");
44 }
45
46
47 }
48 ?>