PMCORE-2120

This commit is contained in:
Paula Quispe
2020-09-01 18:28:25 -04:00
parent d60dbe1e37
commit b0a0778f81
2 changed files with 29 additions and 0 deletions

View File

@@ -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' => '<?xml version="1.0" encoding="UTF-8"?><dynaForm type="xmlform" name="7256532885f4e6876cc8a50043688438/3953439805f4e689265e2b8072489041" width="500" enabletemplate="0" mode="" nextstepsave="prompt"></dynaForm>',
];
$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');
}
}

View File

@@ -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)) {