PMCORE-1151

This commit is contained in:
paulis
2020-03-25 16:28:14 -04:00
committed by Paula Quispe
parent 1464e962ce
commit b13f54bee1
11 changed files with 137 additions and 61 deletions

View File

@@ -16,8 +16,8 @@ $app->make(Kernel::class)->bootstrap();
/**
* @todo Migrate to configuration parameters
*/
define('PATH_TRUNK', dirname(__DIR__));
define('PATH_CORE', PATH_TRUNK . '/workflow/engine/');
define('PATH_TRUNK', dirname(__DIR__) . '/');
define('PATH_CORE', PATH_TRUNK . 'workflow/engine/');
define('PATH_CONFIG', PATH_CORE . 'config/');
if (!defined("PATH_DATA")) {
define('PATH_DATA', dirname(__DIR__) . '/shared/');
@@ -33,12 +33,12 @@ define('DB_ADAPTER', 'mysql');
// Path related some specific directories
define('PATH_SEP', '/');
define("PATH_PLUGINS", PATH_CORE . "plugins" . PATH_SEP);
define('PATH_WORKSPACE', PATH_TRUNK . '/shared/sites/' . SYS_SYS . '/');
define('PATH_WORKSPACE', PATH_TRUNK . 'shared/sites/' . SYS_SYS . '/');
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . 'workflow/engine/data/mysql/');
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . 'rbac/engine/data/mysql/');
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
define('PATH_RBAC_HOME', PATH_TRUNK . 'rbac/');
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
define("PATH_CUSTOM_SKINS", PATH_DATA . "skins/");
define("PATH_TPL", PATH_CORE . "templates/");
@@ -49,11 +49,11 @@ define('DB_HOST', env('DB_HOST'));
define('DB_NAME', env('DB_DATABASE'));
define('DB_USER', env('DB_USERNAME'));
define('DB_PASS', env('DB_PASSWORD'));
define('PATH_HOME', PATH_TRUNK . '/workflow/');
define('PATH_HOME', PATH_TRUNK . 'workflow/');
define('PATH_HTML', PATH_HOME . 'public_html/');
define('PATH_SMARTY_C', PATH_TRUNK . '/shared/compiled/smarty/c');
define('PATH_SMARTY_CACHE', PATH_TRUNK . '/shared/compiled/smarty/cache');
define('PATH_THIRDPARTY', PATH_TRUNK . '/thirdparty/');
define('PATH_SMARTY_C', PATH_TRUNK . 'shared/compiled/smarty/c');
define('PATH_SMARTY_CACHE', PATH_TRUNK . 'shared/compiled/smarty/cache');
define('PATH_THIRDPARTY', PATH_TRUNK . 'thirdparty/');
define("URL_KEY", 'c0l0s40pt1mu59r1m3');
define("PATH_XMLFORM", PATH_CORE . "xmlform" . PATH_SEP);

Binary file not shown.

View File

@@ -14,7 +14,7 @@ class DefaultAjaxTest extends TestCase
*/
private function getDataFromFile(string $pathData): array
{
$pathData = PATH_TRUNK . "/tests/resources/{$pathData}";
$pathData = PATH_TRUNK . "tests/resources/{$pathData}";
$data = file_get_contents($pathData);
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
return $result;
@@ -35,10 +35,10 @@ class DefaultAjaxTest extends TestCase
if (!is_dir($pathName)) {
mkdir($pathName);
}
$data = file_get_contents(PATH_TRUNK . "/tests/resources/simpleClassicXmlFormData.xml");
$data = file_get_contents(PATH_TRUNK . "tests/resources/simpleClassicXmlFormData.xml");
file_put_contents($pathFileName, $data);
require_once PATH_TRUNK . '/gulliver/methods/defaultAjax.php';
require_once PATH_TRUNK . 'gulliver/methods/defaultAjax.php';
$this->expectOutputString('[]');
unlink($pathFileName);

View File

@@ -26,25 +26,25 @@ class CliWorkspacesTest extends TestCase
*/
public function it_should_delete_the_deprecated_files()
{
include(PATH_TRUNK . PATH_SEP . 'workflow/engine/bin/tasks/cliWorkspaces.php');
if (!file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php')) {
$filename = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php';
include(PATH_TRUNK . 'workflow/engine/bin/tasks/cliWorkspaces.php');
if (!file_exists(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php')) {
$filename = PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php';
$handle = fopen($filename, 'w');
fclose($handle);
}
// This assert the data_usersList.php file do exists before being deleted
$this->assertTrue(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
$this->assertTrue(file_exists(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'));
$path = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/';
$path = PATH_TRUNK . 'workflow/engine/methods/users/';
if (getmyuid() == fileowner($path)) {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
if (substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'),
1, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 2, 1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 3, 1) == 'x'
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/'), 2, 1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/'), 3, 1) == 'x'
) {
remove_deprecated_files();
} else {
@@ -53,13 +53,13 @@ class CliWorkspacesTest extends TestCase
}
} else {
if (getmygid() == filegroup($path)) {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
if (substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'),
4, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 5,
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/'), 5,
1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 6, 1) == 'x'
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/'), 6, 1) == 'x'
) {
remove_deprecated_files();
} else {
@@ -68,13 +68,13 @@ class CliWorkspacesTest extends TestCase
}
} else {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
if (substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'),
7, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 8,
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/users/'), 8,
1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 9, 1) == 'x'
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/methods/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/engine/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . 'workflow/'), 9, 1) == 'x'
) {
remove_deprecated_files();
} else {
@@ -85,7 +85,7 @@ class CliWorkspacesTest extends TestCase
}
// This assert the data_usersList.php does not exist anymore
$this->assertFalse(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
$this->assertFalse(file_exists(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'));
}
/**

View File

@@ -0,0 +1,74 @@
<?php
namespace Tests\unit\workflow\engine\classes\model;
use G;
use OutputDocument;
use ProcessMaker\Model\OutputDocument as OutputDocumentModel;
use Tests\TestCase;
/**
* Class OutputDocumentTest
*
* @coversDefaultClass \OutputDocument
*/
class OutputDocumentTest extends TestCase
{
/**
* Review the generate pdf using TCPDF
* @test
* @covers \OutputDocument::generateTcpdf()
*/
public function it_should_generate_tcpdf()
{
// Create a register in the output document
$output = factory(OutputDocumentModel::class)->create([
'OUT_DOC_TEMPLATE' => '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<p>TEST OUTPUT DOCUMENT 内 </p>
<p><font size="2" color="blue" face="verdana" style="text-align:center">this is some font</font></p>
</body>
</html>',
]);
// Prepare the font arialuni.ttf
$arialBkp = PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'fonts' . PATH_SEP;
$fonts = PATH_DATA . 'fonts' . PATH_SEP;
if (!file_exists($fonts)) {
G::mk_dir($fonts);
}
G::recursive_copy($arialBkp, $fonts);
// Define the path for generate the pdf
$appUid = G::generateUniqueID();
$pathOutput = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . G::getPathFromUID($appUid) . PATH_SEP . 'outdocs' . PATH_SEP;
G::mk_dir($pathOutput);
// Define some parameters
$fields = [];
$fields['USR_USERNAME'] = G::generateUniqueID();
// Define some atributes for the pdf
$properties = [];
$properties['margins'] = [];
$properties['margins']['left'] = 15;
$properties['margins']['right'] = 15;
$properties['margins']['top'] = 15;
$properties['margins']['bottom'] = 15;
$properties['pdfSecurity'] = true;
// Call output document
$outputDocument = new OutputDocument();
$outputDocument->generateTcpdf(
$output->OUT_DOC_UID,
$fields,
$pathOutput,
$output->OUT_DOC_FILENAME,
$output->OUT_DOC_TEMPLATE,
false,
$properties
);
$this->assertFileExists($pathOutput . $output->OUT_DOC_FILENAME . '.pdf');
// Remove the shared folder
G::rm_dir($fonts);
}
}

View File

@@ -51,7 +51,7 @@ class UsersAjaxTest extends TestCase
ob_start();
//Call the tested file
require_once PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/usersAjax.php';
require_once PATH_TRUNK . 'workflow/engine/methods/users/usersAjax.php';
//Return the contents of the output buffer
$outputBuffer = ob_get_contents();

View File

@@ -13,7 +13,7 @@ class GranularImporterTest extends TestCase
*/
public function importDataObject()
{
$filename = PATH_TRUNK . "/tests/resources/GranularImporterTest.json";
$filename = PATH_TRUNK . "tests/resources/GranularImporterTest.json";
$json = file_get_contents($filename);
$data = json_decode($json, true);
return $data;

View File

@@ -37,7 +37,7 @@ class XmlImporterTest extends TestCase
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new()
{
$filename = PATH_TRUNK . "/tests/resources/p1normal-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -59,7 +59,7 @@ class XmlImporterTest extends TestCase
'GRP_TITLE' => 'group2'
]);
$regenerateUids = false;
$filename = PATH_TRUNK . "/tests/resources/p1normal-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -80,7 +80,7 @@ class XmlImporterTest extends TestCase
factory(\ProcessMaker\Model\Groupwf::class)->create([
'GRP_TITLE' => 'group2'
]);
$filename = PATH_TRUNK . "/tests/resources/p1normal-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -96,9 +96,9 @@ class XmlImporterTest extends TestCase
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_and_objects_import()
{
$filename = PATH_TRUNK . "/tests/resources/p2custom-1.pmx2";
$filename = PATH_TRUNK . "tests/resources/p2custom-1.pmx2";
$objectsToImportFilename = PATH_TRUNK . "/tests/resources/p2custom-1-ObjectsToImport.json";
$objectsToImportFilename = PATH_TRUNK . "tests/resources/p2custom-1-ObjectsToImport.json";
$json = file_get_contents($objectsToImportFilename);
$objectsToImport = json_decode($json);
@@ -117,9 +117,9 @@ class XmlImporterTest extends TestCase
public function it_should_matter_with_import_option_keep_without_changing_and_create_new_and_group_import_option_create_new()
{
$regenerateUids = false;
$filename = PATH_TRUNK . "/tests/resources/p2custom-1.pmx2";
$filename = PATH_TRUNK . "tests/resources/p2custom-1.pmx2";
$objectsToImportFilename = PATH_TRUNK . "/tests/resources/p2custom-1-ObjectsToImport.json";
$objectsToImportFilename = PATH_TRUNK . "tests/resources/p2custom-1-ObjectsToImport.json";
$json = file_get_contents($objectsToImportFilename);
$objectsToImport = json_decode($json);
@@ -137,9 +137,9 @@ class XmlImporterTest extends TestCase
*/
public function it_should_matter_with_import_option_overwrite_and_group_import_option_create_new()
{
$filename = PATH_TRUNK . "/tests/resources/p2custom-1.pmx2";
$filename = PATH_TRUNK . "tests/resources/p2custom-1.pmx2";
$objectsToImportFilename = PATH_TRUNK . "/tests/resources/p2custom-1-ObjectsToImport.json";
$objectsToImportFilename = PATH_TRUNK . "tests/resources/p2custom-1-ObjectsToImport.json";
$json = file_get_contents($objectsToImportFilename);
$objectsToImport = json_decode($json);
@@ -158,9 +158,9 @@ class XmlImporterTest extends TestCase
public function it_should_matter_with_import_option_disable_and_create_new_and_group_import_option_create_new()
{
$regenerateUids = false;
$filename = PATH_TRUNK . "/tests/resources/p2custom-1.pmx2";
$filename = PATH_TRUNK . "tests/resources/p2custom-1.pmx2";
$objectsToImportFilename = PATH_TRUNK . "/tests/resources/p2custom-1-ObjectsToImport.json";
$objectsToImportFilename = PATH_TRUNK . "tests/resources/p2custom-1-ObjectsToImport.json";
$json = file_get_contents($objectsToImportFilename);
$objectsToImport = json_decode($json);
@@ -178,7 +178,7 @@ class XmlImporterTest extends TestCase
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_with_exception()
{
$filename = PATH_TRUNK . "/tests/resources/p1normal-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -202,7 +202,7 @@ class XmlImporterTest extends TestCase
factory(\ProcessMaker\Model\Groupwf::class)->create([
'GRP_TITLE' => 'group2'
]);
$filename = PATH_TRUNK . "/tests/resources/p1normal-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -219,7 +219,7 @@ class XmlImporterTest extends TestCase
*/
public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_exception()
{
$filename = PATH_TRUNK . "/tests/resources/p1normalWithException-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normalWithException-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -241,7 +241,7 @@ class XmlImporterTest extends TestCase
'PRO_TITLE' => 'p1normalWithoutTitle'
]);
$filename = PATH_TRUNK . "/tests/resources/p1normalWithoutTitle-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normalWithoutTitle-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);
@@ -253,7 +253,7 @@ class XmlImporterTest extends TestCase
'PRO_TITLE' => 'p1normalWithoutTitle2'
]);
$filename = PATH_TRUNK . "/tests/resources/p1normalWithoutTitle2-1.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normalWithoutTitle2-1.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);

View File

@@ -108,7 +108,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();
@@ -127,7 +127,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();
@@ -150,7 +150,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();
@@ -179,7 +179,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();
@@ -203,7 +203,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();
@@ -227,7 +227,7 @@ class BpmnWorkflowTest extends TestCase
{
$faker = Factory::create();
$projectDataFilename = PATH_TRUNK . "/tests/resources/projectData.json";
$projectDataFilename = PATH_TRUNK . "tests/resources/projectData.json";
$json = file_get_contents($projectDataFilename);
$projectData = json_decode($json, JSON_OBJECT_AS_ARRAY);
$projectData['prj_uid'] = G::generateUniqueID();

View File

@@ -27,7 +27,7 @@ class ProjectTest extends TestCase
*/
public function it_should_set_the_process_owner_with_invalid_value()
{
$filename = PATH_TRUNK . "/tests/resources/p1normal-2.pmx";
$filename = PATH_TRUNK . "tests/resources/p1normal-2.pmx";
$importer = new XmlImporter();
$importer->setData("usr_uid", $this->user->USR_UID);
$importer->setSourceFile($filename);