" " 'Bugs', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', 'display_label' => 'Opportunities', ), array( 'module' => 'Opportunities', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', 'display_label' => 'Bugs', ), ); $this->writeTestFiles($files); $this->uninstallLabels($labelDefinitions); $this->assertFileNotExists( 'custom/Extension/modules/relationships/language/Bugs.php', 'Not deleted empty file' ); $this->assertFileNotExists( 'custom/Extension/modules/relationships/language/Opportunities.php', 'Not deleted empty file' ); } /** * @group 56228 */ public function testUninstallWithFilesModStr() { $files = array( 'custom/Extension/modules/relationships/language/Bugs.php' => " " 'Bugs', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', 'display_label' => 'Opportunities', ), array( 'module' => 'Opportunities', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', 'display_label' => 'Bugs', ), ); $this->writeTestFiles($files); $this->uninstallLabels($labelDefinitions); $this->assertFileNotExists('custom/Extension/modules/relationships/language/Opportunities.php'); $this->assertFileExists('custom/Extension/modules/relationships/language/Bugs.php'); require('custom/Extension/modules/relationships/language/Bugs.php'); $this->assertArrayNotHasKey('LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', $mod_strings); $this->assertArrayNotHasKey('LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', $mod_strings); } /** * @group 56228 */ public function testUninstallWithFilesAppStr() { $files = array( 'custom/Extension/modules/relationships/language/application.php' => " 'application', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', 'display_label' => 'Opportunities', ), array( 'module' => 'application', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', 'display_label' => 'Bugs', ), ); $this->writeTestFiles($files); $this->uninstallLabels($labelDefinitions); $this->assertFileExists('custom/Extension/modules/relationships/language/application.php'); require('custom/Extension/modules/relationships/language/application.php'); $this->assertArrayNotHasKey('LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', $app_list_strings); $this->assertArrayNotHasKey('LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', $app_list_strings); } /** * @group 56228 */ public function testUninstallNoFilesAppStr() { $files = array( 'custom/Extension/modules/relationships/language/application.php' => " 'application', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_OPPORTUNITIES_TITLE', 'display_label' => 'Opportunities', ), array( 'module' => 'application', 'system_label' => 'LBL_OPPORTUNITIES_BUGS_1_FROM_BUGS_TITLE', 'display_label' => 'Bugs', ), ); $this->writeTestFiles($files); $this->uninstallLabels($labelDefinitions); $this->assertFileNotExists('custom/Extension/modules/relationships/language/application.php'); } /** * @group 56228 */ public function testUninstallExtLabels() { $files = array( 'custom/Extension/modules/Bugs/Ext/Language/en_us.customopportunities_bugs_1.php' => 'some text', 'custom/Extension/modules/Opportunities/Ext/Language/en_us.customopportunities_bugs_1.php' => 'some text', 'custom/Extension/application/Ext/Language/en_us.customopportunities_bugs_1.php' => 'some text' ); $labelDefinitions = array( array( 'module' => 'Bugs', ), array( 'module' => 'Opportunities', ), array( 'module' => 'application', ), ); $this->writeTestFiles($files); $oModuleInstaller = new ModuleInstaller(); $oModuleInstaller->id_name = 'customopportunities_bugs_1'; $oModuleInstaller->uninstallExtLabels($labelDefinitions); foreach(array_keys($files) as $fileName){ $this->assertFileNotExists($fileName); } } private function uninstallLabels($labelDefinitions) { $oModuleInstaller = new ModuleInstaller(); $oModuleInstaller->uninstallLabels('custom/Extension/modules/relationships/language/', $labelDefinitions); } private function writeTestFiles($files) { foreach ($files as $fileName => $sContent) { $this->fileNames[] = $fileName; if (!file_exists($fileName)){ mkdir_recursive(dirname($fileName)); } file_put_contents($fileName, $sContent); } } public function tearDown() { foreach ($this->fileNames as $fileNames) { @unlink($fileNames); } parent::tearDown(); } }