2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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 'ModuleInstall/PackageManager/PackageManager.php';
39 class Bug39980Test extends Sugar_PHPUnit_Framework_TestCase
42 public function tearDown()
44 if (is_file(Bug39980PackageManger::$manifest_location))
45 unlink(Bug39980PackageManger::$manifest_location);
48 public function testGetinstalledPackagesUninstallable()
50 $pm = new Bug39980PackageManger();
51 $pm->extractManifest(0, 0);
52 $packs = $pm->getinstalledPackages();
53 //Its confusing, but "UNINSTALLABLE" in file_install means the package is NOT uninstallable
54 $this->assertEquals("UNINSTALLABLE", $packs[0]['file_install']);
59 class Bug39980PackageManger extends PackageManager {
60 static $manifest_location = "cache/Bug39980manifest.php";
62 public function __construct() {
63 parent::__construct();
64 $this->manifest_content = <<<EOQ
67 'acceptable_sugar_versions' =>
71 'acceptable_sugar_flavors' =>
80 'is_uninstallable' => false,
81 'name' => 'test_file_1',
82 'published_date' => '2010-10-20 22:10:01',
84 'version' => '1287612601',
85 'remove_tables' => 'prompt',
87 \$installdefs = array (
92 'from' => '<basepath>/Extension/modules/Cases/Ext/Vardefs/dummy_extension2.php',
93 'to' => 'custom/Extension/modules/Cases/Ext/Vardefs/dummy_extension2.php',
101 public function getInstalled($types)
103 include($this->extractManifest(0,0));
105 'manifest' => (isset($manifest) ? $manifest : ''),
106 'installdefs' => (isset($installdefs) ? $installdefs : ''),
107 'upgrade_manifest' => (isset($upgrade_manifest) ? $upgrade_manifest : '')
111 'filename' => Bug39980PackageManger::$manifest_location,
112 'manifest' => base64_encode(serialize($sm)),
113 'date_entered' => '1/1/2010',
115 'module_dir' => 'Administration' ,
116 'id' => 'b4d22740-4e96-65b3-b712-4ca230d95987' ,
117 'md5sum' => 'fe221d731d8c624f15712878300aa907' ,
119 'version' => '1285697780' ,
120 'status' => 'installed' ,
121 'name' => 'test_file_1' ,
122 'description' => '' ,
129 public function extractManifest($filename, $base_tmp_upgrade_dir)
131 if (!is_file(Bug39980PackageManger::$manifest_location))
132 file_put_contents(Bug39980PackageManger::$manifest_location, $this->manifest_content);
134 return Bug39980PackageManger::$manifest_location;