function test_installPackage() { $oPkgMgr = new OX_PluginManager(); $file = MAX_PATH . $this->testpathData . 'zipInstallTest/testPluginPackage.zip'; $oPkgMgr->clearErrors(); //install $this->assertTrue($oPkgMgr->installPackage(array('tmp_name' => $file, 'name' => 'testPluginPackage.zip'))); if (count($oPkgMgr->aErrors)) { foreach ($oPkgMgr->aErrors as $error) { $this->fail($error); } } $path = MAX_PATH . $oPkgMgr->pathPluginsAdmin . 'testPlugin/'; $this->assertTrue(file_exists($path . 'templates/testPlugin.html')); $this->assertTrue(file_exists($path . 'images/testPlugin1.jpg')); $this->assertTrue(file_exists($path . 'images/testPlugin2.jpg')); $this->assertTrue(file_exists($path . 'testPlugin-common.php')); $this->assertTrue(file_exists($path . 'testPlugin-index.php')); $this->assertTrue(file_exists($path . 'testPlugin-page.php')); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['plugins']['testPluginPackage'])); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['testPlugin'])); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['testPlugin'])); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting1'])); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting2'])); $this->assertTrue(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting3'])); $doAppVar = OA_Dal::factoryDO('application_variable'); $doAppVar->name = 'tables_testplugin'; $doAppVar->find(true); $this->assertEqual($doAppVar->value, '001'); $doAppVar = OA_Dal::factoryDO('application_variable'); $doAppVar->name = 'testPlugin_version'; $doAppVar->find(true); $this->assertEqual($doAppVar->value, '0.0.1'); $doPrefs = OA_Dal::factoryDO('preferences'); $doPrefs->preference_name = 'testPlugin_preference1'; $doPrefs->find(true); $this->assertEqual($doPrefs->account_type, OA_ACCOUNT_MANAGER); $doPrefs = OA_Dal::factoryDO('preferences'); $doPrefs->preference_name = 'testPlugin_preference2'; $doPrefs->find(true); $this->assertEqual($doPrefs->account_type, OA_ACCOUNT_ADMIN); $aTables = OA_DB_Table::listOATablesCaseSensitive('testPlugin_table'); $this->assertIsA($aTables, 'array'); $doTestPluginTable = OA_Dal::factoryDO('testPlugin_table'); $this->assertIsA($doTestPluginTable, 'DataObjects_Testplugin_table'); $this->assertEqual($id = $doTestPluginTable->insert(), 1); $this->assertTrue($doTestPluginTable->delete()); // try reinstalling $this->assertFalse($oPkgMgr->installPackage(array('tmp_name' => $file, 'name' => 'testPluginPackage.zip'))); $this->assertEqual($oPkgMgr->aErrors[0], "Plugin with this name is already installed testPluginPackage"); //uninstall $oPkgMgr->clearErrors(); $this->assertTrue($oPkgMgr->uninstallPackage('testPluginPackage')); if (count($oPkgMgr->aErrors)) { foreach ($oPkgMgr->aErrors as $error) { $this->fail($error); } } $path = MAX_PATH . $oPkgMgr->pathPluginsAdmin . 'testPlugin/'; $this->assertFalse(file_exists($path . 'templates/testPlugin.html')); $this->assertFalse(file_exists($path . 'images/testPlugin1.jpg')); $this->assertFalse(file_exists($path . 'images/testPlugin2.jpg')); $this->assertFalse(file_exists($path . 'testPlugin-common.php')); $this->assertFalse(file_exists($path . 'testPlugin-index.php')); $this->assertFalse(file_exists($path . 'testPlugin-page.php')); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['plugins']['testPluginPackage'])); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['testPlugin'])); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['testPlugin'])); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting1'])); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting2'])); $this->assertFalse(isset($GLOBALS['_MAX']['CONF']['testPlugin']['setting3'])); $doAppVar = OA_Dal::factoryDO('application_variable'); $doAppVar->name = 'tables_testplugin'; $doAppVar->find(true); $this->assertNull($doAppVar->value, 'Expected null got ' . $doAppVar->value); $doAppVar = OA_Dal::factoryDO('application_variable'); $doAppVar->name = 'testPlugin_version'; $doAppVar->find(true); $this->assertNull($doAppVar->value, 'Expected null got ' . $doAppVar->value); $doPrefs = OA_Dal::factoryDO('preferences'); $doPrefs->preference_name = 'testPlugin_preference1'; $doPrefs->find(true); $this->assertNull($doPrefs->account_type, 'Expected null got ' . $doPrefs->account_type); $doPrefs = OA_Dal::factoryDO('preferences'); $doPrefs->preference_name = 'testPlugin_preference2'; $doPrefs->find(true); $this->assertNull($doPrefs->account_type, 'Expected null got ' . $doPrefs->account_type); $aTables = OA_DB_Table::listOATablesCaseSensitive('testplugin_table'); $this->assertEqual(count($aTables), 0); TestEnv::restoreConfig(); }