PMCORE-1151
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user