When e_plugin::buildAddonPrefsList() executes, it wipes out what is considered the currently loaded plugin (e_plugin::$_plugdir) and replaces it with the last plugin found by e_plugin::getDetected().
Execution
$ ~/PhpstormProjects/e107-test/vendor/bin/codecept run unit pluginsTest::testPlugInstalledStatus
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
Running with seed:
Unit Tests (1) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
✖ pluginsTest: Testplug installed status (0.10s)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 1.35 seconds, Memory: 22.00MB
There was 1 failure:
---------
1) pluginsTest: Testplug installed status
Test tests/unit/pluginsTest.php:testplugInstalledStatus
e_plugin:isInstalled() = 1 but plugin_installflag = 0 after uninstall.
Failed asserting that 0 matches expected 1.
#1 /home/deltik/PhpstormProjects/e107-test/tests/unit/pluginsTest.php:265
FAILURES!
Tests: 1, Assertions: 5, Failures: 1.
public function testplugInstalledStatus()
{
$sql = e107::getDb();
$plg = e107::getPlug()->clearCache();
$plg->load('tagcloud');
// check it's NOT installed.
$status = $plg->isInstalled();
$dbStatus = (bool) $sql->retrieve('plugin', "plugin_installflag", "plugin_path='tagcloud'");
$this->assertEquals($status,$dbStatus,"e_plugin:isInstalled() doesn't match plugin_installflag in db table.");
$this->assertFalse($status, "Status for tagcloud being installed should be false");
e107::getPlugin()->install('tagcloud');
// check it's installed.
$status = (int) $plg->isInstalled();
$actual = (bool) $status;
$dbStatus = (int) $sql->retrieve('plugin', "plugin_installflag", "plugin_path='tagcloud'");
$this->assertEquals($status,$dbStatus,"e_plugin:isInstalled() = ".$status." but plugin_installflag = ".$dbStatus." after install.");
$this->assertTrue($actual, "Status for tagcloud being installed should be true after being installed.");
e107::getPlugin()->uninstall('tagcloud');
// check it's NOT installed.
$status = (int) $plg->isInstalled();
$actual = (bool) $status;
$dbStatus = (int) $sql->retrieve('plugin', "plugin_installflag", "plugin_path='tagcloud'");
$this->assertEquals($status,$dbStatus,"e_plugin:isInstalled() = ".$status." but plugin_installflag = ".$dbStatus." after uninstall.");
$this->assertFalse($actual, "Status for tagcloud being installed should be false after being uninstalled.");
}
When
e_plugin::buildAddonPrefsList()
executes, it wipes out what is considered the currently loaded plugin (e_plugin::$_plugdir
) and replaces it with the last plugin found bye_plugin::getDetected()
.Execution
Test code