diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Plugins/PluginsRegistryTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Plugins/PluginsRegistryTest.php index a9f088433..73090068d 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Plugins/PluginsRegistryTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Plugins/PluginsRegistryTest.php @@ -9,6 +9,7 @@ use ProcessMaker\Plugins\Interfaces\PluginDetail; use ProcessMaker\Plugins\Interfaces\Plugins; use ProcessMaker\Plugins\Interfaces\RedirectDetail; use ProcessMaker\Plugins\Interfaces\StepDetail; +use ProcessMaker\Plugins\Interfaces\TriggerDetail; use ProcessMaker\Plugins\PluginsRegistry; use Tests\WorkflowTestCase; @@ -30,6 +31,27 @@ class PluginsRegistryTest extends WorkflowTestCase $this->oPluginRegistry->setupPlugins(); } + /** + * This is the default method to test, if the class still having + * the same number of methods. + */ + public function testNumberOfMethodsInThisClass() + { + $methods = get_class_methods('\ProcessMaker\Plugins\PluginsRegistry'); + $this->assertTrue(count($methods) == 82, count($methods)); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::__construct + */ + public function testConstruct() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('__construct', $methods), 'exists method __construct'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', '__construct'); + $r->getParameters(); + } + /** * Test get Plugins */ @@ -59,6 +81,24 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertInstanceOf(Plugins::class, $oPluginRegistry, ''); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerPlugin + */ + public function testRegisterPluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerPlugin', $methods), 'exists method registerPlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sFilename'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == true); + $this->assertTrue($params[1]->getDefaultValue() == ''); + } + /** * Test registry plugin */ @@ -74,6 +114,20 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertInstanceOf(PluginDetail::class, $oPluginRegistry->_aPluginDetails['enterprise'], ''); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getPluginDetails + */ + public function testGetPluginDetailsParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getPluginDetails', $methods), 'exists method getPluginDetails'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getPluginDetails'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sFilename'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test get plugin details */ @@ -90,6 +144,20 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertInstanceOf(PluginDetail::class, $details, ''); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::enablePlugin + */ + public function testEnablePluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('enablePlugin', $methods), 'exists method enablePlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'enablePlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test enable plugin */ @@ -106,6 +174,24 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertEquals(true, $result, 'Plugin is enable'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::disablePlugin + */ + public function testDisablePluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('disablePlugin', $methods), 'exists method disablePlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'disablePlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'eventPlugin'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == true); + $this->assertTrue($params[1]->getDefaultValue() == '1'); + } + /** * Test disable plugin */ @@ -124,6 +210,20 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertEquals(false, $details->enabled, 'Plugin is enable'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getStatusPlugin + */ + public function testGetStatusPluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getStatusPlugin', $methods), 'exists method getStatusPlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getStatusPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'name'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test get status plugin */ @@ -142,6 +242,85 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertEquals(true, $details->enabled, 'Plugin is disabled'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::installPluginArchive + */ + public function testInstallPluginArchiveParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('installPluginArchive', $methods), 'exists method installPluginArchive'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'installPluginArchive'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'filename'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'pluginName'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::uninstallPlugin + */ + public function testUninstallPluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('uninstallPlugin', $methods), 'exists method uninstallPlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'uninstallPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::uninstallPluginWorkspaces + */ + public function testUninstallPluginWorkspaces() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('uninstallPluginWorkspaces', $methods), 'exists method uninstallPluginWorkspaces'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'uninstallPluginWorkspaces'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'arrayPlugin'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::installPlugin + */ + public function testInstallPlugin() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('installPlugin', $methods), 'exists method installPlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'installPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerMenu + */ + public function testRegisterMenuParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerMenu', $methods), 'exists method registerMenu'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerMenu'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sMenuId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sFilename'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + /** * Test register menu */ @@ -168,6 +347,20 @@ class PluginsRegistryTest extends WorkflowTestCase ); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerDashlets + */ + public function testRegisterDashletsParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerDashlets', $methods), 'exists method registerDashlets'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerDashlets'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'namespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test register dashlets */ @@ -186,6 +379,23 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertTrue(is_array($oPluginRegistry->_aDashlets)); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerCss + */ + public function testRegisterCssParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerCss', $methods), 'exists method registerCss'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerCss'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sCssFile'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + } + /** * Test register Css */ @@ -230,6 +440,26 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertInstanceOf(CssFile::class, $css[0], ''); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerJavascript + */ + public function testRegisterJavascriptParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerJavascript', $methods), 'exists method registerJavascript'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerJavascript'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sCoreJsFile'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'pluginJsFile'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + /** * Test register javascript */ @@ -331,6 +561,24 @@ class PluginsRegistryTest extends WorkflowTestCase ); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getRegisteredJavascriptBy + */ + public function testGetRegisteredJavascriptByParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getRegisteredJavascriptBy', $methods), 'exists method getRegisteredJavascriptBy'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getRegisteredJavascriptBy'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sCoreJsFile'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sNamespace'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == true); + $this->assertTrue($params[1]->getDefaultValue() == ''); + } + /** * Test get registered javascript by path */ @@ -348,6 +596,24 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->getRegisteredJavascriptBy(PATH_CORE . 'js' . PATH_SEP . 'testCore.js', 'enterprise'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::unregisterJavascripts + */ + public function testUnregisterJavascriptsParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('unregisterJavascripts', $methods), 'exists method unregisterJavascripts'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'unregisterJavascripts'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sCoreJsFile'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == true); + $this->assertTrue($params[1]->getDefaultValue() == ''); + } + /** * Test get unregistered javascript */ @@ -370,6 +636,20 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->unregisterJavascripts('enterprise', PATH_CORE . 'js' . PATH_SEP . 'testCore.js'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerReport + */ + public function testRegisterReportParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerReport', $methods), 'exists method registerReport'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerReport'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test register report */ @@ -382,6 +662,20 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->registerReport('enterprise'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerPmFunction + */ + public function testRegisterPmFunctionParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerPmFunction', $methods), 'exists method registerPmFunction'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerPmFunction'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test register pmfunction */ @@ -394,6 +688,26 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->registerPmFunction('enterprise'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerRedirectLogin + */ + public function testRegisterRedirectLoginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerRedirectLogin', $methods), 'exists method registerRedirectLogin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerRedirectLogin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sRole'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sPathMethod'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + /** * Test registered redirect login */ @@ -407,6 +721,26 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->registerRedirectLogin('enterprise', 'TEST', PATH_CORE . 'js' . PATH_SEP . 'testCore.js'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerFolder + */ + public function testRegisterFolderParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerFolder', $methods), 'exists method registerFolder'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerFolder'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sFolderId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sFolderName'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + /** * Test registered folder */ @@ -420,6 +754,33 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->registerFolder('enterprise', '1234', 'TestCore'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerStep + */ + public function testRegisterStepParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerStep', $methods), 'exists method registerStep'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerStep'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sStepId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sStepName'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + $this->assertTrue($params[3]->getName() == 'sStepTitle'); + $this->assertTrue($params[3]->isArray() == false); + $this->assertTrue($params[3]->isOptional() == false); + $this->assertTrue($params[4]->getName() == 'setupStepPage'); + $this->assertTrue($params[4]->isArray() == false); + $this->assertTrue($params[4]->isOptional() == true); + $this->assertTrue($params[4]->getDefaultValue() == ''); + } + /** * Test register step */ @@ -433,6 +794,20 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->registerStep('enterprise', '1234', 'TestStep', 'StepTitle'); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::isRegisteredFolder + */ + public function testIsRegisteredFolderParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('isRegisteredFolder', $methods), 'exists method isRegisteredFolder'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'isRegisteredFolder'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sFolderName'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test is registered folder */ @@ -450,6 +825,20 @@ class PluginsRegistryTest extends WorkflowTestCase $this->assertFalse($step); } + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getMenus + */ + public function testGetMenusParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getMenus', $methods), 'exists method getMenus'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getMenus'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'menuId'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + /** * Test get menus */ @@ -515,4 +904,420 @@ class PluginsRegistryTest extends WorkflowTestCase $oPluginRegistry->enablePlugin('enterprise'); $this->assertTrue(is_array($oPluginRegistry->getRedirectLogins())); } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerTrigger + */ + public function testRegisterTriggerParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerTrigger', $methods), 'exists method registerTrigger'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerTrigger'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sTriggerId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sTriggerName'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + + public function testRegisterTrigger() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $oPluginRegistry->registerTrigger('enterprise', 'test1234', 'TestTrigger'); + $this->assertEquals( + 'TestTrigger', + $oPluginRegistry->_aTriggers[0]->sTriggerName, + 'sTriggerName attribute does not equals' + ); + $this->assertObjectHasAttribute( + 'sTriggerId', + $oPluginRegistry->_aTriggers[0], + 'sTriggerId attribute does not exist' + ); + $this->assertInstanceOf(TriggerDetail::class, $oPluginRegistry->_aTriggers[0], ''); + $oPluginRegistry->registerTrigger('enterprise', 'test1234', 'TestTrigger'); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getTriggerInfo + */ + public function testGetTriggerInfoParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getTriggerInfo', $methods), 'exists method getTriggerInfo'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getTriggerInfo'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'triggerId'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + public function testGetTriggerInfo() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin('charts'); + $oPluginRegistry->registerFolder('charts', '1234', 'charts'); + $oPluginRegistry->registerTrigger('charts', 'trigger1234', 'TestTrigger'); + $trigger = $oPluginRegistry->getTriggerInfo('trigger1234'); + $this->assertEquals( + 'TestTrigger', + $trigger->sTriggerName, + 'sTriggerName attribute does not equals' + ); + $this->assertObjectHasAttribute( + 'sTriggerId', + $trigger, + 'sTriggerId attribute does not exist' + ); + $this->assertInstanceOf(TriggerDetail::class, $trigger, ''); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::existsTrigger + */ + public function testExistsTriggerParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('existsTrigger', $methods), 'exists method existsTrigger'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'existsTrigger'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'triggerId'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + public function testExistsTrigger() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $oPluginRegistry->registerFolder('enterprise', '1234', 'charts'); + $oPluginRegistry->registerTrigger('enterprise', 'trigger1234', 'TestTrigger'); + $trigger = $oPluginRegistry->existsTrigger('trigger1234'); + $this->assertTrue($trigger, 'sTriggerName attribute does not equals'); + $trigger = $oPluginRegistry->existsTrigger('NoExist'); + $this->assertFalse($trigger, 'sTriggerId attribute does not exist'); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::executeTriggers + */ + public function testExecuteTriggersParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('executeTriggers', $methods), 'exists method executeTriggers'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'executeTriggers'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'triggerId'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'oData'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + } + + public function testExecuteTriggers() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $pluginFile = 'pmosCommunity.php'; + //add the plugin php file + require_once(PATH_PLUGINS . "pmosCommunity.php"); + //register mulitenant in the plugin registry singleton, because details are read from this instance + $oPluginRegistry->registerPlugin("pmosCommunity", $pluginFile); + $oPluginRegistry->registerFolder('pmosCommunity', 'Folder1234', 'pmosCommunity'); + $oPluginRegistry->registerTrigger('pmosCommunity', 'Trigger1234', 'getAvailableCharts'); + $trigger = $oPluginRegistry->executeTriggers('Trigger1234', []); + $this->assertTrue(is_array($trigger), ' attribute does not equals'); + $this->assertContains('ForumWeek', $trigger, 'ForumWeek element does not exist'); + $oPluginRegistry->registerTrigger('enterprise1', 'Trigger4321', 'notExist'); + $trigger = $oPluginRegistry->executeTriggers('Trigger4321', []); + $this->assertNull($trigger, 'sTriggerId attribute does not exist'); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getPlugin + */ + public function testGetPluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getPlugin', $methods), 'exists method getPlugin'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + public function testGetPlugin() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $plugin = $oPluginRegistry->getPlugin('enterprise'); + $this->assertEquals( + 'enterprise', + $plugin->sPluginFolder, + 'sPluginFolder attribute does not equals' + ); + $this->assertObjectHasAttribute('sNamespace', $plugin, 'sNamespace attribute does not exist'); + $this->assertInstanceOf(\enterprisePlugin::class, $plugin, ''); + $plugin = $oPluginRegistry->getPlugin('namespaceNoExist'); + $this->assertNull($plugin); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::setCompanyLogo + */ + public function testSetCompanyLogoParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('setCompanyLogo', $methods), 'exists method setCompanyLogo'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'setCompanyLogo'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'filename'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + } + + public function testSetCompanyLogo() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $oPluginRegistry->setCompanyLogo('enterprise', PATH_PLUGINS . 'testLogo.png'); + $this->assertEquals( + PATH_PLUGINS . 'testLogo.png', + $oPluginRegistry->_aPluginDetails['enterprise']->sCompanyLogo, + 'sPluginFolder attribute does not equals' + ); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getCompanyLogo + */ + public function testGetCompanyLogoParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getCompanyLogo', $methods), 'exists method getCompanyLogo'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getCompanyLogo'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'default'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + public function testGetCompanyLogo() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $oPluginRegistry->setCompanyLogo('enterprise', PATH_PLUGINS . 'Logo.png'); + $logo = $oPluginRegistry->getCompanyLogo(PATH_PLUGINS . 'testLogo.png'); + $this->assertEquals( + PATH_PLUGINS . 'Logo.png', + $logo, + 'sPluginFolder attribute does not equals' + ); + } + + public function testGetCompanyLogoDefault() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $oPluginRegistry->enablePlugin("enterprise"); + $logo = $oPluginRegistry->getCompanyLogo(PATH_PLUGINS . 'Logo.png'); + $this->assertEquals( + PATH_PLUGINS . 'Logo.png', + $logo, + 'sPluginFolder attribute does not equals' + ); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::executeMethod + */ + public function testExecuteMethodParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('executeMethod', $methods), 'exists method executeMethod'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'executeMethod'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'methodName'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'oData'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + + public function testExecuteMethod() + { + $oPluginRegistry = PluginsRegistry::loadSingleton(); + $pluginFile = 'pmosCommunity.php'; + //add the plugin php file + require_once(PATH_PLUGINS . "pmosCommunity.php"); + //register mulitenant in the plugin registry singleton, because details are read from this instance + $oPluginRegistry->registerPlugin("pmosCommunity", $pluginFile); + $oPluginRegistry->registerFolder('pmosCommunity', 'Folder1234', 'pmosCommunity'); + $oPluginRegistry->registerTrigger('pmosCommunity', 'Trigger1234', 'getAvailableCharts'); + $trigger = $oPluginRegistry->executeMethod('Trigger1234', []); + $this->assertTrue(is_array($trigger), ' attribute does not equals'); + $this->assertContains('ForumWeek', $trigger, 'ForumWeek element does not exist'); + $oPluginRegistry->registerTrigger('enterprise1', 'Trigger4321', 'notExist'); + $trigger = $oPluginRegistry->executeMethod('Trigger4321', []); + $this->assertNull($trigger, 'sTriggerId attribute does not exist'); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getFieldsForPageSetup + */ + public function testGetFieldsForPageSetupParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getFieldsForPageSetup', $methods), 'exists method getFieldsForPageSetup'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getFieldsForPageSetup'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::updateFieldsForPageSetup + */ + public function testUpdateFieldsForPageSetupParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('updateFieldsForPageSetup', $methods), 'exists method updateFieldsForPageSetup'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'updateFieldsForPageSetup'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'oData'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerToolbarFile + */ + public function testRegisterToolbarFileParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerToolbarFile', $methods), 'exists method registerToolbarFile'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerToolbarFile'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sToolbarId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sFilename'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::getToolbarOptions + */ + public function testGetToolbarOptionsParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('getToolbarOptions', $methods), 'exists method getToolbarOptions'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'getToolbarOptions'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sToolbarId'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerCaseSchedulerPlugin + */ + public function testRegisterCaseSchedulerPluginParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue( + in_array('registerCaseSchedulerPlugin', $methods), + 'exists method registerCaseSchedulerPlugin' + ); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerCaseSchedulerPlugin'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sActionId'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sActionForm'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + $this->assertTrue($params[3]->getName() == 'sActionSave'); + $this->assertTrue($params[3]->isArray() == false); + $this->assertTrue($params[3]->isOptional() == false); + $this->assertTrue($params[4]->getName() == 'sActionExecute'); + $this->assertTrue($params[4]->isArray() == false); + $this->assertTrue($params[4]->isOptional() == false); + $this->assertTrue($params[5]->getName() == 'sActionGetFields'); + $this->assertTrue($params[5]->isArray() == false); + $this->assertTrue($params[5]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerTaskExtendedProperty + */ + public function testRegisterTaskExtendedPropertyParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue( + in_array('registerTaskExtendedProperty', $methods), + 'exists method registerTaskExtendedProperty' + ); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerTaskExtendedProperty'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sPage'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sName'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + $this->assertTrue($params[3]->getName() == 'sIcon'); + $this->assertTrue($params[3]->isArray() == false); + $this->assertTrue($params[3]->isOptional() == false); + } + + /** + * @covers \ProcessMaker\Plugins\PluginsRegistry::registerDashboardPage + */ + public function testRegisterDashboardPageParams() + { + $methods = get_class_methods($this->oPluginRegistry); + $this->assertTrue(in_array('registerDashboardPage', $methods), 'exists method registerDashboardPage'); + $r = new \ReflectionMethod('\ProcessMaker\Plugins\PluginsRegistry', 'registerDashboardPage'); + $params = $r->getParameters(); + $this->assertTrue($params[0]->getName() == 'sNamespace'); + $this->assertTrue($params[0]->isArray() == false); + $this->assertTrue($params[0]->isOptional() == false); + $this->assertTrue($params[1]->getName() == 'sPage'); + $this->assertTrue($params[1]->isArray() == false); + $this->assertTrue($params[1]->isOptional() == false); + $this->assertTrue($params[2]->getName() == 'sName'); + $this->assertTrue($params[2]->isArray() == false); + $this->assertTrue($params[2]->isOptional() == false); + $this->assertTrue($params[3]->getName() == 'sIcon'); + $this->assertTrue($params[3]->isArray() == false); + $this->assertTrue($params[3]->isOptional() == false); + } }