mirror of
https://github.com/e107inc/e107.git
synced 2025-04-08 14:43:36 +02:00
Basic Plugin Install/Uninstall tests added.
This commit is contained in:
parent
16e04d8287
commit
249be2979c
@ -26,92 +26,248 @@
|
||||
}*/
|
||||
}
|
||||
|
||||
private function dumpInfo($plugin)
|
||||
private function checkPlugin($plugin, $debug=false)
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
echo "Log ------------\n";
|
||||
$text = "\n\n---- Log \n\n";
|
||||
$log = e107::getPlugin()->getLog();
|
||||
|
||||
foreach($log as $line)
|
||||
{
|
||||
echo " - ".$line."\n";
|
||||
$text .= " - ".$line."\n";
|
||||
}
|
||||
echo "-------------------\n\n";
|
||||
|
||||
echo "-- Pref: plug_installed (version)\n\n";
|
||||
$text .= "----------------------------------------\n\n";
|
||||
|
||||
$text .= "---- Pref: plug_installed (version)\n\n";
|
||||
$pref = e107::getConfig('core',true,true)->get('plug_installed');
|
||||
|
||||
print_r($pref[$plugin]);
|
||||
$text .= print_r($pref[$plugin],true);
|
||||
|
||||
echo "\n-- Plugin Prefs: \n\n";
|
||||
$table = e107::pref($plugin);
|
||||
print_r($table);
|
||||
$installedPref = isset($pref[$plugin]) ? $pref[$plugin] : false;
|
||||
|
||||
$text .= "\n\n---- Plugin Prefs: \n\n";
|
||||
$pluginPref = e107::pref($plugin);
|
||||
$text .= print_r($pluginPref,true);
|
||||
|
||||
|
||||
echo "\n-- Plugin Table: ".$plugin."\n\n";
|
||||
$table = e107::getDb()->retrieve('plugin','*', "plugin_path='".$plugin."' LIMIT 1", true);
|
||||
print_r($table);
|
||||
$text .= "\n---- Plugin Table: ".$plugin."\n\n";
|
||||
$pluginTable = e107::getDb()->retrieve('plugin','*', "plugin_path='".$plugin."' LIMIT 1", true);
|
||||
$text .= print_r($pluginTable,true);
|
||||
|
||||
echo "\n-- Menu Table: ".$plugin."\n\n";
|
||||
$table = e107::getDb()->retrieve('menus','*', "menu_location = 0 AND menu_path='".$plugin."/' LIMIT 10", true);
|
||||
print_r($table);
|
||||
$text .= "\n---- Menu Table: ".$plugin."\n\n";
|
||||
$menuTable = e107::getDb()->retrieve('menus','*', "menu_location = 0 AND menu_path='".$plugin."/' LIMIT 10", true);
|
||||
$text .= print_r($menuTable, true);
|
||||
|
||||
echo "\n-- Site Links Table: ".$plugin."\n\n";
|
||||
$table = e107::getDb()->retrieve('links','*', "link_owner='".$plugin."' ", true);
|
||||
print_r($table);
|
||||
$text .= "\n---- Site Links Table: ".$plugin."\n\n";
|
||||
$linksTable = e107::getDb()->retrieve('links','*', "link_owner='".$plugin."' ", true);
|
||||
$text .= print_r($linksTable, true);
|
||||
|
||||
$dir = scandir(e_PLUGIN.$plugin);
|
||||
$corePref = e107::getConfig('core',true,true)->getPref();
|
||||
|
||||
|
||||
echo "\n-- Addons\n\n";
|
||||
echo "----------------------------------------\n";
|
||||
echo "Addon file\t\tIn Core pref e_xxxx_list\n\n";
|
||||
$text .= "\n---- Addons\n\n";
|
||||
$text .= "-------------------------------------------------------------------\n";
|
||||
$text .= "Addon file In Core pref e_xxxx_list \n";
|
||||
$text .= "-------------------------------------------------------------------\n";
|
||||
|
||||
$addonPref = array();
|
||||
|
||||
foreach($dir as $file)
|
||||
{
|
||||
$name = basename($file,".php");
|
||||
|
||||
if(substr($file,0,2) === 'e_')
|
||||
{
|
||||
|
||||
|
||||
$key = $name."_list";
|
||||
$status = !empty($corePref[$key][$plugin]) ? 'YES' : 'NO';
|
||||
|
||||
echo $file."\t\t".$status."\n";
|
||||
if($key === 'e_help_list')
|
||||
{
|
||||
$status = "DEPRECATED by Admin-UI renderHelp()";
|
||||
}
|
||||
else
|
||||
{
|
||||
$addonPref[$name] = ($status === 'YES') ? true : false;
|
||||
}
|
||||
|
||||
$text .= str_pad($file,20)."\t\t".$status."\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo "----------------------------------------\n\n\n";
|
||||
$text .= "-------------------------------------------------------------------\n";
|
||||
|
||||
if($debug === true)
|
||||
{
|
||||
echo $text;
|
||||
}
|
||||
|
||||
return array(
|
||||
'log' => $log,
|
||||
'installedPref' => $installedPref,
|
||||
'pluginPref' => $pluginPref,
|
||||
'pluginTable' => $pluginTable,
|
||||
'menuTable' => $menuTable,
|
||||
'linksTable' => $linksTable,
|
||||
'addonPref' => $addonPref
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function testBanner()
|
||||
public function testBanner()
|
||||
{
|
||||
|
||||
e107::getPlugin()->install('banner');
|
||||
$this->pluginInstall('banner');
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$result = $tp->parseTemplate("{BANNER=e107promo}",true);
|
||||
|
||||
$this->assertContains("<img class='e-banner img-responsive img-fluid'",$result);
|
||||
|
||||
|
||||
$this->pluginUninstall('banner');
|
||||
$result2 = $tp->parseTemplate("{BANNER=e107promo}",true); // should return null since plugin is uninstalled.
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testChatbox_Menu()
|
||||
{
|
||||
$this->pluginInstall('chatbox_menu');
|
||||
|
||||
$this->pluginUninstall('chatbox_menu');
|
||||
}
|
||||
|
||||
public function testDownload()
|
||||
{
|
||||
$this->pluginInstall('download');
|
||||
|
||||
$this->pluginUninstall('download');
|
||||
}
|
||||
|
||||
public function testFaqs()
|
||||
{
|
||||
$this->pluginInstall('faqs');
|
||||
$this->pluginUninstall('faqs');
|
||||
}
|
||||
|
||||
public function testFeaturebox()
|
||||
{
|
||||
$this->pluginInstall('featurebox');
|
||||
$this->pluginUninstall('featurebox');
|
||||
}
|
||||
|
||||
public function testForum()
|
||||
{
|
||||
$this->pluginInstall('forum');
|
||||
$this->pluginUninstall('forum');
|
||||
}
|
||||
|
||||
public function testGallery()
|
||||
{
|
||||
$this->pluginInstall('gallery');
|
||||
$this->pluginUninstall('gallery');
|
||||
}
|
||||
|
||||
public function testGsitemap()
|
||||
{
|
||||
$this->pluginInstall('gsitemap');
|
||||
$this->pluginUninstall('gsitemap');
|
||||
}
|
||||
|
||||
public function testImport()
|
||||
{
|
||||
$this->pluginInstall('import');
|
||||
$this->pluginUninstall('import');
|
||||
}
|
||||
|
||||
public function testLinkwords()
|
||||
{
|
||||
$this->pluginInstall('linkwords');
|
||||
$this->pluginUninstall('linkwords');
|
||||
}
|
||||
|
||||
public function testPm()
|
||||
{
|
||||
$this->pluginInstall('pm');
|
||||
$this->pluginUninstall('pm');
|
||||
}
|
||||
|
||||
public function testPoll()
|
||||
{
|
||||
$this->pluginInstall('poll');
|
||||
$this->pluginUninstall('poll');
|
||||
}
|
||||
|
||||
public function testRss_menu()
|
||||
{
|
||||
$this->pluginInstall('rss_menu');
|
||||
$this->pluginUninstall('rss_menu');
|
||||
}
|
||||
|
||||
public function testSocial()
|
||||
{
|
||||
$this->pluginUninstall('social');
|
||||
$this->pluginInstall('social');
|
||||
}
|
||||
|
||||
public function testTagcloud()
|
||||
{
|
||||
$this->pluginInstall('tagcloud');
|
||||
$this->pluginUninstall('tagcloud');
|
||||
}
|
||||
|
||||
private function pluginInstall($pluginDir)
|
||||
{
|
||||
|
||||
e107::getPlugin()->install($pluginDir);
|
||||
|
||||
$install = $this->checkPlugin($pluginDir, false); // set to true to see more info
|
||||
|
||||
// print_r($install);
|
||||
|
||||
//todo additional checks
|
||||
|
||||
foreach($install['addonPref'] as $key=>$val)
|
||||
{
|
||||
$this->assertTrue($val, $key." list pref is missing for ".$pluginDir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function pluginUninstall($pluginDir)
|
||||
{
|
||||
$opts = array(
|
||||
'delete_tables' => 1,
|
||||
'delete_files' => 0
|
||||
);
|
||||
|
||||
e107::getPlugin()->uninstall('banner', $opts);
|
||||
e107::getPlugin()->uninstall($pluginDir, $opts);
|
||||
|
||||
$uninstall = $this->checkPlugin($pluginDir, false); // set to true to see more info
|
||||
|
||||
// print_r($uninstall);
|
||||
|
||||
//todo additional checks
|
||||
|
||||
$this->assertEmpty($uninstall['linksTable'], $pluginDir." link still exists in the links table");
|
||||
|
||||
foreach($uninstall['addonPref'] as $key=>$val)
|
||||
{
|
||||
$message = $key." list pref still contains '".$pluginDir."' after uninstall of ".$pluginDir.". ";
|
||||
$this->assertEmpty($val, $message);
|
||||
}
|
||||
|
||||
|
||||
$result = $tp->parseTemplate("{BANNER=e107promo}",true); // should return null since plugin is uninstalled.
|
||||
|
||||
// $this->dumpInfo('banner'); // see more values to test
|
||||
|
||||
}
|
||||
|
||||
@ -120,6 +276,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user