3 class Bug36978Test extends Sugar_PHPUnit_Framework_TestCase {
6 var $has_custom_table_dictionary;
12 $this->markTestSkipped("Skipping unless otherwise specified");
17 $GLOBALS['current_user'] = $admin->retrieve('1');
19 $GLOBALS['app_list_strings'] = return_app_list_strings_language('en_us');
21 //Create the custom relationships
22 if(!file_exists('custom/Extension/modules/abc_Test/Ext/Vardefs')) {
23 mkdir_recursive('custom/Extension/modules/abc_Test/Ext/Vardefs');
26 if(!file_exists('custom/Extension/modules/abc_Test/Ext/Layoutdefs')) {
27 mkdir_recursive('custom/Extension/modules/abc_Test/Ext/Layoutdefs');
30 if(!file_exists('modules/abc_Test/metadata')) {
31 mkdir_recursive('modules/abc_Test/metadata');
34 if( $fh = @fopen('modules/abc_Test/metadata/studio.php', 'w+') )
37 \$GLOBALS['studioDefs']['abc_Test'] = array(
45 if( $fh = @fopen('custom/Extension/modules/abc_Test/Ext/Vardefs/test.php', 'w+') )
50 \$dictionary["abc_Test"]["fields"]["abc_test_abc_test"] = array (
51 'name' => 'abc_test_abc_test',
53 'relationship' => 'abc_test_abc_test',
56 'vname' => 'LBL_ABC_TEST_ABC_TEST_FROM_ABC_TEST_L_TITLE',
60 \$dictionary["abc_Test"]["fields"]["abc_test_abc_test_name"] = array (
61 'name' => 'abc_test_abc_test_name',
64 'vname' => 'LBL_ABC_TEST_ABC_TEST_FROM_ABC_TEST_L_TITLE',
66 'id_name' => 'abc_test_ab6dabc_test_ida',
67 'link' => 'abc_test_abc_test',
68 'table' => 'abc_test',
69 'module' => 'abc_Test',
74 \$dictionary["abc_Test"]["fields"]["abc_test_ab6dabc_test_ida"] = array (
75 'name' => 'abc_test_ab6dabc_test_ida',
77 'relationship' => 'abc_test_abc_test',
79 'reportable' => false,
81 'vname' => 'LBL_ABC_TEST_ABC_TEST_FROM_ABC_TEST_R_TITLE',
90 //Create the custom relationships
91 if(!file_exists('custom/metadata')) {
92 mkdir_recursive('custom/metadata');
95 if( $fh = @fopen('custom/metadata/abc_test_abc_testMetaData.php', 'w+') )
100 \$dictionary["abc_test_abc_test"] = array (
101 'true_relationship_type' => 'one-to-many',
104 'abc_test_abc_test' =>
106 'lhs_module' => 'abc_Test',
107 'lhs_table' => 'abc_test',
109 'rhs_module' => 'abc_Test',
110 'rhs_table' => 'abc_test',
112 'relationship_type' => 'one-to-many',
113 'join_table' => 'abc_test_abc_test_c',
114 'join_key_lhs' => 'abc_test_ab6dabc_test_ida',
115 'join_key_rhs' => 'abc_test_aed49bc_test_idb',
118 'table' => 'abc_test_abc_test_c',
129 'name' => 'date_modified',
130 'type' => 'datetime',
142 'name' => 'abc_test_ab6dabc_test_ida',
148 'name' => 'abc_test_aed49bc_test_idb',
157 'name' => 'abc_test_abc_testspk',
166 'name' => 'abc_test_abc_test_ida1',
170 0 => 'abc_test_ab6dabc_test_ida',
175 'name' => 'abc_test_abc_test_alt',
176 'type' => 'alternate_key',
179 0 => 'abc_test_aed49bc_test_idb',
188 fputs( $fh, $string);
193 if(!file_exists('custom/Extension/application/Ext/TableDictionary')) {
194 mkdir_recursive('custom/Extension/application/Ext/TableDictionary');
198 if( $fh = @fopen('custom/Extension/application/Ext/TableDictionary/abc_test_abc_test.php', 'w+') )
202 include('custom/metadata/abc_test_abc_testMetaData.php');
205 fputs( $fh, $string);
209 $this->rel_guid = create_guid();
210 $sql = "INSERT INTO relationships (id, relationship_name, lhs_module, lhs_table, lhs_key, rhs_module, rhs_table, rhs_key, join_table, join_key_lhs, join_key_rhs, relationship_type, reverse, deleted) VALUES ('{$this->rel_guid}', 'abc_test_abc_test', 'abc_Test', 'abc_test', 'id', 'abc_Test', 'abc_test', 'id', 'abc_test_abc_test_c', 'abc_test_ab6abc_test_id', 'abc_test_aed49bc_test_id', 'one-to-many', 0, 0)";
211 $GLOBALS['db']->query($sql);
213 $rel = new Relationship();
214 $rel->delete_cache();
215 $rel->build_relationship_cache();
217 $this->moduleList = $GLOBALS['moduleList'];
220 function tearDown() {
221 if(file_exists('custom/Extension/modules/abc_Test/Ext/Vardefs/test.php')) {
222 unlink('custom/Extension/modules/abc_Test/Ext/Vardefs/test.php');
225 if(file_exists('custom/metadata/abc_test_abc_testMetaData.php')) {
226 unlink('custom/metadata/abc_test_abc_testMetaData.php');
229 if(file_exists('custom/Extension/application/Ext/TableDictionary/abc_test_abc_test.php')) {
230 unlink('custom/Extension/application/Ext/TableDictionary/abc_test_abc_test.php');
233 if(file_exists('modules/abc_Test/metadata/studio.php')) {
234 unlink('modules/abc_Test/metadata/studio.php');
237 rmdir_recursive('custom/Extension/modules/abc_Test/Ext/Vardefs');
238 rmdir_recursive('custom/Extension/modules/abc_Test/Ext/Layoutdefs');
239 rmdir_recursive('custom/Extension/modules/abc_Test/Ext');
240 rmdir_recursive('custom/Extension/modules/abc_Test');
241 rmdir_recursive('modules/abc_Test/metadata');
242 rmdir_recursive('modules/abc_Test');
244 $sql = "DELETE FROM relationships WHERE id = '{$this->rel_guid}'";
245 $GLOBALS['db']->query($sql);
247 $GLOBALS['moduleList'] = $this->moduleList;
251 function test_upgrade_custom_relationships() {
252 $GLOBALS['moduleList'] = array();
253 $GLOBALS['moduleList'][] = 'abc_Test';
254 $GLOBALS['beanList']['abc_Test'] = 'abc_Test';
256 include('modules/Administration/upgrade_custom_relationships.php');
257 upgrade_custom_relationships();
258 include('custom/Extension/modules/abc_Test/Ext/Vardefs/test.php');