From b0a0778f81b9a8d3c645652d25f3de95800ab72f Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Tue, 1 Sep 2020 18:28:25 -0400 Subject: [PATCH] PMCORE-2120 --- .../src/ProcessMaker/Project/WorkflowTest.php | 21 +++++++++++++++++++ .../src/ProcessMaker/Project/Workflow.php | 8 +++++++ 2 files changed, 29 insertions(+) diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php index bf15a5c15..98ba3a1c4 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php @@ -125,4 +125,25 @@ class WorkflowTest extends TestCase $this->expectException(Exception::class); $actual = $this->workflow->getData($proUid); } + + /** + * Test if the target xml dynaform was created correctly + * + * @test + * @covers \ProcessMaker\Project\Workflow::createDataFileByArrayFile() + */ + public function it_review_creation_of_xml_dynaforms() + { + $dyna1 = [ + 'file_name' => $this->faker->sentence(2), + 'file_path' => '7256532885f4e6876cc8a50043688438\\3953439805f4e689265e2b8072489041.xml', + 'file_content' => '', + ]; + $formatFiles = []; + $formatFiles['dynaforms'][] = $dyna1; + $this->workflow->createDataFileByArrayFile($formatFiles); + $this->assertTrue(file_exists(PATH_DYNAFORM . '7256532885f4e6876cc8a50043688438/3953439805f4e689265e2b8072489041.xml')); + // Remove the xml created + G::rm_dir(PATH_DYNAFORM . '7256532885f4e6876cc8a50043688438/3953439805f4e689265e2b8072489041.xml'); + } } diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index 57bd927a7..06d136332 100644 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -1111,6 +1111,12 @@ class Workflow extends Handler } } + /** + * Create the workflow-files related to the process + * + * @param array $arrayFile + * @throws \Exception + */ public function createDataFileByArrayFile(array $arrayFile) { try { @@ -1135,6 +1141,8 @@ class Workflow extends Handler foreach ($files as $file) { $filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]); + // If the file was created in WINDOWS we need to replace the "\\" + $filename = str_replace("\\", "/", $filename); $path = dirname($filename); if (!is_dir($path)) {