diff --git a/tests/resources/dynaform3.json b/tests/resources/dynaform3.json new file mode 100644 index 000000000..1110c4b8c --- /dev/null +++ b/tests/resources/dynaform3.json @@ -0,0 +1,553 @@ +{ + "name": "ABE-1", + "description": "", + "items": [{ + "type": "form", + "variable": "", + "var_uid": "", + "dataType": "", + "id": "1343723465efa2f79704dc4074804880", + "name": "ABE-1", + "description": "", + "mode": "edit", + "script": "", + "language": "en", + "externalLibs": "", + "printable": false, + "items": [[{ + "type": "dropdown", + "variable": "option", + "var_uid": "4882127935efa3853e6ef65004825919", + "dataType": "string", + "protectedValue": true, + "id": "option", + "name": "option", + "label": "Option", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "dataVariable": "", + "options": [{ + "value": "1", + "label": "Ok" + }, { + "value": "2", + "label": "Wrong" + }], + "var_name": "option", + "colSpan": 12 + }], [{ + "type": "text", + "variable": "textVar001", + "var_uid": "8024926815efa2f918c24d9048946760", + "dataType": "string", + "protectedValue": false, + "id": "textVar001", + "name": "textVar001", + "label": "Text Var 001", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "textTransform": "none", + "validate": "", + "validateMessage": "", + "maxLength": 1000, + "formula": "", + "mode": "parent", + "operation": "", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "var_name": "textVar001", + "colSpan": 12 + }], [{ + "type": "textarea", + "variable": "textareaVar001", + "var_uid": "3801812565efa2f938ffb27097904674", + "dataType": "string", + "protectedValue": false, + "id": "textareaVar001", + "name": "textareaVar001", + "label": "Textarea Var 001", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "validate": "", + "validateMessage": "", + "mode": "parent", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "rows": "5", + "var_name": "textareaVar001", + "colSpan": 12 + }], [{ + "type": "dropdown", + "variable": "dropdownVar001", + "var_uid": "4874759895efa2f95d73918073729404", + "dataType": "string", + "protectedValue": false, + "id": "dropdownVar001", + "name": "dropdownVar001", + "label": "Dropdown Var 001", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "SELECT IS_UID, IS_NAME FROM ISO_SUBDIVISION\nWHERE IC_UID = @@COUNTRIES ORDER BY IS_NAME", + "memoryCache": false, + "dataVariable": "", + "options": [], + "var_name": "dropdownVar001", + "colSpan": 12 + }], [{ + "type": "submit", + "id": "submit0000000001", + "name": "submit0000000001", + "label": "submit_1", + "tabIndex": "", + "ariaLabel": "", + "colSpan": 12 + }], [{ + "type": "checkbox", + "variable": "checkboxVar001", + "var_uid": "9875983355efa33fc428854020429594", + "dataType": "boolean", + "protectedValue": false, + "id": "checkboxVar001", + "name": "checkboxVar001", + "label": "Checkbox Var 001", + "tabIndex": "", + "defaultValue": "", + "hint": "", + "ariaLabel": "", + "ariaLabelVisible": true, + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "options": [{ + "value": "1", + "label": "true" + }, { + "value": "0", + "label": "false" + }], + "var_name": "checkboxVar001", + "colSpan": 12 + }], [{ + "type": "checkgroup", + "variable": "checkgroupVar001", + "var_uid": "7653533805efa34036b7696022819944", + "dataType": "array", + "protectedValue": false, + "id": "checkgroupVar001", + "name": "checkgroupVar001", + "label": "Checkgroup Var 001", + "tabIndex": "", + "defaultValue": "", + "hint": "", + "ariaLabel": "", + "ariaLabelVisible": true, + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "dataVariable": "", + "options": [], + "var_name": "checkgroupVar001", + "colSpan": 12 + }], [{ + "type": "yesno", + "variable": "radioVar001", + "var_uid": "5993816415efa340a234248023937839", + "dataType": "string", + "protectedValue": false, + "id": "radioVar001", + "name": "radioVar001", + "label": "Radio Var 001", + "tabIndex": "", + "defaultValue": "", + "hint": "", + "ariaLabel": "", + "ariaLabelVisible": true, + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "dataVariable": "", + "options": [{ + "value": "1", + "label": "true" + }, { + "value": "0", + "label": "false" + }], + "var_name": "radioVar001", + "colSpan": 12 + }], [{ + "type": "datetime", + "variable": "datetimeVar001", + "var_uid": "3905353965efa341314e278010404418", + "dataType": "datetime", + "protectedValue": false, + "id": "datetimeVar001", + "name": "datetimeVar001", + "label": "Datetime Var 001", + "tabIndex": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "format": "YYYY-MM-DD", + "dayViewHeaderFormat": "MMMM YYYY", + "extraFormats": false, + "stepping": 1, + "minDate": "", + "maxDate": "", + "useCurrent": "false", + "collapse": true, + "locale": "", + "defaultDate": "", + "disabledDates": false, + "enabledDates": false, + "icons": { + "time": "glyphicon glyphicon-time", + "date": "glyphicon glyphicon-calendar", + "up": "glyphicon glyphicon-chevron-up", + "down": "glyphicon glyphicon-chevron-down", + "previous": "glyphicon glyphicon-chevron-left", + "next": "glyphicon glyphicon-chevron-right", + "today": "glyphicon glyphicon-screenshot", + "clear": "glyphicon glyphicon-trash" + }, + "useStrict": false, + "sideBySide": false, + "daysOfWeekDisabled": false, + "calendarWeeks": false, + "viewMode": "days", + "toolbarPlacement": "default", + "showTodayButton": false, + "showClear": "false", + "widgetPositioning": { + "horizontal": "auto", + "vertical": "auto" + }, + "widgetParent": null, + "keepOpen": false, + "var_name": "datetimeVar001", + "colSpan": 12 + }], [{ + "type": "suggest", + "variable": "suggestVar001", + "var_uid": "3411734965efa341a7fbf93067272299", + "dataType": "string", + "protectedValue": false, + "id": "suggestVar001", + "name": "suggestVar001", + "label": "Suggest Var 001", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "dataVariable": "", + "options": [], + "delay": 0, + "resultsLimit": 10, + "forceSelection": false, + "var_name": "suggestVar001", + "colSpan": 12 + }], [{ + "type": "hidden", + "variable": "hiddenVar001", + "var_uid": "8671702965efa343d2cd636026494394", + "dataType": "string", + "protectedValue": false, + "id": "hiddenVar001", + "name": "hiddenVar001", + "defaultValue": "", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "var_name": "hiddenVar001", + "colSpan": 12 + }], [{ + "type": "grid", + "variable": "gridVar001", + "var_uid": "5728723745efa3449d8e314091553134", + "dataType": "grid", + "protectedValue": false, + "id": "gridVar001", + "name": "gridVar001", + "label": "grid_1", + "hint": "", + "required": false, + "requiredFieldErrorMessage": "", + "columns": [{ + "type": "suggest", + "variable": "", + "var_uid": "", + "dataType": "", + "protectedValue": false, + "id": "suggest0000000002", + "name": "suggest0000000002", + "label": "suggest_2", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "mode": "parent", + "datasource": "database", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "dataVariable": "", + "options": [], + "delay": 0, + "resultsLimit": 10, + "forceSelection": false, + "columnWidth": "10", + "width": 100, + "title": "suggest_2", + "var_name": "gridVar001" + }], + "data": [], + "mode": "parent", + "layout": "responsive", + "pageSize": "0", + "addRow": true, + "deleteRow": true, + "title": "grid_1", + "colSpan": 12 + }], [{ + "type": "textarea", + "variable": "", + "var_uid": "", + "dataType": "", + "protectedValue": false, + "id": "textarea0000000002", + "name": "textarea0000000002", + "label": "textarea_2", + "tabIndex": "", + "defaultValue": "", + "placeholder": "", + "hint": "", + "ariaLabel": "", + "required": false, + "requiredFieldErrorMessage": "", + "validate": "", + "validateMessage": "", + "mode": "parent", + "dbConnection": "workflow", + "dbConnectionLabel": "PM Database", + "sql": "", + "memoryCache": false, + "rows": "5", + "colSpan": 12 + }]], + "variables": [{ + "var_uid": "4882127935efa3853e6ef65004825919", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "option", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "8024926815efa2f918c24d9048946760", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "textVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "3801812565efa2f938ffb27097904674", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "textareaVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "4874759895efa2f95d73918073729404", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "dropdownVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "9875983355efa33fc428854020429594", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "checkboxVar001", + "var_field_type": "boolean", + "var_field_size": 10, + "var_label": "boolean", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[{\"value\":\"1\",\"label\":\"true\"},{\"value\":\"0\",\"label\":\"false\"}]", + "inp_doc_uid": "" + }, { + "var_uid": "7653533805efa34036b7696022819944", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "checkgroupVar001", + "var_field_type": "array", + "var_field_size": 10, + "var_label": "array", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "5993816415efa340a234248023937839", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "radioVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "3905353965efa341314e278010404418", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "datetimeVar001", + "var_field_type": "datetime", + "var_field_size": 10, + "var_label": "datetime", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "3411734965efa341a7fbf93067272299", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "suggestVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "8671702965efa343d2cd636026494394", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "hiddenVar001", + "var_field_type": "string", + "var_field_size": 10, + "var_label": "string", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }, { + "var_uid": "5728723745efa3449d8e314091553134", + "prj_uid": "4599678715ef9e601cb8413049734226", + "var_name": "gridVar001", + "var_field_type": "grid", + "var_field_size": 10, + "var_label": "grid", + "var_dbconnection": "workflow", + "var_dbconnection_label": "PM Database", + "var_sql": "", + "var_null": 0, + "var_default": "", + "var_accepted_values": "[]", + "inp_doc_uid": "" + }] + }] +} \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php index f3ff0dd3a..2a66c92e3 100644 --- a/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php +++ b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php @@ -37,7 +37,8 @@ class ActionsByEmailCoreClassTest extends TestCase } $path = $path . PATH_SEP . 'pmdynaform.html'; if (!file_exists($path)) { - file_put_contents($path, ''); + $template = file_get_contents(PATH_TPL . 'cases/pmdynaform.html'); + file_put_contents($path, $template); } } @@ -46,7 +47,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_with_exception() + public function it_should_test_sendActionsByEmail_method_with_exception() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -85,7 +86,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_if_abe_configuration_is_undefined() + public function it_should_test_sendActionsByEmail_method_if_abe_configuration_is_undefined() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -127,7 +128,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_with_exception_if_task_property_is_undefined() + public function it_should_test_sendActionsByEmail_method_with_exception_if_task_property_is_undefined() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -183,7 +184,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_with_exception_if_email_to_is_empty() + public function it_should_test_sendActionsByEmail_method_with_exception_if_email_to_is_empty() { $user = factory(User::class)->create([ 'USR_EMAIL' => '' @@ -242,7 +243,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_with_exception_if_email_type_is_empty() + public function it_should_test_sendActionsByEmail_method_with_exception_if_email_type_is_empty() { $user = factory(User::class)->create(); @@ -298,7 +299,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_custom() + public function it_should_test_sendActionsByEmail_method_custom() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -357,7 +358,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_response() + public function it_should_test_sendActionsByEmail_method_response() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -413,11 +414,11 @@ class ActionsByEmailCoreClassTest extends TestCase } /** - * This test verifies if the sendActionsByEmail method supports the 'FIELD' setting. + * This test verifies if the sendActionsByEmail method supports the 'LINK' setting. * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_link() + public function it_should_test_sendActionsByEmail_method_link() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -477,7 +478,7 @@ class ActionsByEmailCoreClassTest extends TestCase * @test * @covers \ActionsByEmailCoreClass::sendActionsByEmail */ - public function it_should_test_send_actions_by_email_field() + public function it_should_test_sendActionsByEmail_method_field() { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() @@ -487,7 +488,8 @@ class ActionsByEmailCoreClassTest extends TestCase 'PRO_UID' => $process->PRO_UID ]); $dynaform = factory(Dynaform::class)->create([ - 'PRO_UID' => $process->PRO_UID + 'PRO_UID' => $process->PRO_UID, + 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform2.json") ]); $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); $abeConfiguration = factory(AbeConfiguration::class)->create([ @@ -531,4 +533,218 @@ class ActionsByEmailCoreClassTest extends TestCase $this->assertArrayHasKey('ABE_REQ_UID', $result); } + + /** + * This test verifies if the getFieldTemplate method supports the 'dropdown' control. + * @test + * @covers \ActionsByEmailCoreClass::getFieldTemplate + */ + public function it_should_test_getFieldTemplate_method_dropdown_control() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'LINK', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID, + 'ABE_ACTION_FIELD' => '@@option' + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $reflection = new ReflectionClass($this->actionsByEmailCoreClass); + $reflectionMethod = $reflection->getMethod('getFieldTemplate'); + $reflectionMethod->setAccessible(true); + + $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); + + $this->assertContains('jsondata', $result); + $this->assertContains('httpServerHostname', $result); + $this->assertContains('pm_run_outside_main_app', $result); + $this->assertContains('pathRTLCss', $result); + $this->assertContains('fieldsRequired', $result); + } + + /** + * This test verifies if the getFieldTemplate method supports the 'checkbox' control. + * @test + * @covers \ActionsByEmailCoreClass::getFieldTemplate + */ + public function it_should_test_getFieldTemplate_method_checkbox_control() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'LINK', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID, + 'ABE_ACTION_FIELD' => '@@checkboxVar001' + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $reflection = new ReflectionClass($this->actionsByEmailCoreClass); + $reflectionMethod = $reflection->getMethod('getFieldTemplate'); + $reflectionMethod->setAccessible(true); + + $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); + + $this->assertContains('jsondata', $result); + $this->assertContains('httpServerHostname', $result); + $this->assertContains('pm_run_outside_main_app', $result); + $this->assertContains('pathRTLCss', $result); + $this->assertContains('fieldsRequired', $result); + } + + /** + * This test verifies if the getFieldTemplate method supports the 'yesno' control. + * The 'yesno' control is obsolete and not used in pmdynaform. + * @test + * @covers \ActionsByEmailCoreClass::getFieldTemplate + */ + public function it_should_test_getFieldTemplate_method_yesno_control() + { + $user = User::where('USR_UID', '=', '00000000000000000000000000000001') + ->get() + ->first(); + $process = factory(Process::class)->create(); + $task = factory(Task::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $dynaform = factory(Dynaform::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") + ]); + $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); + $abeConfiguration = factory(AbeConfiguration::class)->create([ + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_TYPE' => 'LINK', + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_RECEIVER_UID' => $emailServer->MESS_UID, + 'ABE_ACTION_FIELD' => '@@radioVar001' + ]); + $abeConfiguration = $abeConfiguration->toArray(); + + $application = factory(Application::class)->create([ + 'PRO_UID' => $process->PRO_UID + ]); + + $delegation = factory(Delegation::class)->create([ + 'APP_UID' => $application->APP_UID, + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID + ]); + + $data = [ + 'TAS_UID' => $task->TAS_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => $delegation->DEL_INDEX, + 'USR_UID' => $user->USR_UID, + 'PREVIOUS_USR_UID' => $user->USR_UID + ]; + $data = (object) $data; + + $_SERVER["REQUEST_URI"] = ''; + + $this->actionsByEmailCoreClass = new ActionsByEmailCoreClass(); + $this->actionsByEmailCoreClass->setUser($user->USR_UID); + $this->actionsByEmailCoreClass->setIndex($delegation->DEL_INDEX); + $this->actionsByEmailCoreClass->sendActionsByEmail($data, $abeConfiguration); + + $reflection = new ReflectionClass($this->actionsByEmailCoreClass); + $reflectionMethod = $reflection->getMethod('getFieldTemplate'); + $reflectionMethod->setAccessible(true); + + $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); + + $this->assertContains('jsondata', $result); + $this->assertContains('httpServerHostname', $result); + $this->assertContains('pm_run_outside_main_app', $result); + $this->assertContains('pathRTLCss', $result); + $this->assertContains('fieldsRequired', $result); + } } diff --git a/workflow/engine/classes/ActionsByEmailCoreClass.php b/workflow/engine/classes/ActionsByEmailCoreClass.php index 6c17e0266..3aadddeff 100644 --- a/workflow/engine/classes/ActionsByEmailCoreClass.php +++ b/workflow/engine/classes/ActionsByEmailCoreClass.php @@ -882,7 +882,7 @@ class ActionsByEmailCoreClass extends PMPlugin } } - $obj = new PmDynaform($dynUid); + $obj = new PmDynaform(["CURRENT_DYNAFORM" => $dynUid]); $this->addItemAbeProperties(['CURRENT_DYNAFORM' => $dynUid]); $file = $obj->printPmDynaformAbe($this->getTaskAbeProperties()); $html = $file;