2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
37 require_once 'include/dir_inc.php';
38 require_once('modules/UpgradeWizard/UpgradeRemoval.php');
40 class Bug49955Test extends Sugar_PHPUnit_Framework_TestCase {
45 SugarTestMergeUtilities::setupFiles(array('Notes'), array('editviewdefs'), 'tests/modules/UpgradeWizard/SugarMerge/metadata_files');
47 if(file_exists('custom/backup/modules/DocumentRevisions'))
49 rmdir_recursive('custom/backup/modules/DocumentRevisions');
52 file_put_contents('modules/DocumentRevisions/EditView.html', 'test');
53 file_put_contents('modules/DocumentRevisions/DetailView.html', 'test');
54 file_put_contents('modules/DocumentRevisions/EditView.php', 'test');
55 file_put_contents('modules/DocumentRevisions/DetailView.php', 'test');
60 SugarTestMergeUtilities::teardownFiles();
62 if(file_exists('custom/backup/modules/DocumentRevisions'))
64 rmdir_recursive('custom/backup/modules/DocumentRevisions');
67 if(file_exists('modules/DocumentRevisions/EditView.html'))
69 unlink('modules/DocumentRevisions/EditView.html');
72 if(file_exists('modules/DocumentRevisions/DetailView.html'))
74 unlink('modules/DocumentRevisions/DetailView.html');
77 if(file_exists('modules/DocumentRevisions/EditView.php'))
79 unlink('modules/DocumentRevisions/EditView.php');
82 if(file_exists('modules/DocumentRevisions/DetailView.php'))
84 unlink('modules/DocumentRevisions/DetailView.php');
88 function test_filename_convert_merge() {
89 require_once 'modules/UpgradeWizard/SugarMerge/EditViewMerge.php';
90 $this->merge = new EditViewMerge();
91 $this->merge->merge('Notes', 'tests/modules/UpgradeWizard/SugarMerge/metadata_files/610/modules/Notes/metadata/editviewdefs.php','modules/Notes/metadata/editviewdefs.php','custom/modules/Notes/metadata/editviewdefs.php');
92 require('custom/modules/Notes/metadata/editviewdefs.php');
97 foreach ( $viewdefs['Notes']['EditView']['panels'] as $panel ) {
98 foreach ( $panel as $row ) {
99 foreach ( $row as $col ) {
100 if ( is_array($col) ) {
101 $fieldName = $col['name'];
106 if ( $fieldName == 'filename' ) {
114 $this->assertNotEmpty($fileField,'Filename field doesn\'t exit, it should');
115 $this->assertTrue(is_string($fileField) && $fileField == 'filename', 'Filename field not converted to string');
117 if ( file_exists('custom/modules/Notes/metadata/editviewdefs-testback.php') ) {
118 copy('custom/modules/Notes/metadata/editviewdefs-testback.php','custom/modules/Notes/metadata/editviewdefs.php');
119 unlink('custom/modules/Notes/metadata/editviewdefs-testback.php');
122 //Now test the DocumentRevisions cleanup
123 $instance = new UpgradeRemoval49955Mock();
124 $instance->processFilesToRemove($instance->getFilesToRemove(624));
125 $this->assertTrue(!file_exists('modules/DocumentRevisions/EditView.html'));
126 $this->assertTrue(!file_exists('modules/DocumentRevisions/DetaillView.html'));
127 $this->assertTrue(!file_exists('modules/DocumentRevisions/EditView.php'));
128 $this->assertTrue(!file_exists('modules/DocumentRevisions/DetailView.html'));
134 class UpgradeRemoval49955Mock extends UpgradeRemoval
137 public function getFilesToRemove($version)
140 $files[] = 'modules/DocumentRevisions/EditView.html';
141 $files[] = 'modules/DocumentRevisions/DetailView.html';
142 $files[] = 'modules/DocumentRevisions/EditView.php';
143 $files[] = 'modules/DocumentRevisions/DetailView.php';