PMC-931 Add unit tests for the feature PMC-852
This commit is contained in:
23
database/factories/EmailServerFactory.php
Normal file
23
database/factories/EmailServerFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\EmailServer::class, function(Faker $faker) {
|
||||||
|
return [
|
||||||
|
'MESS_UID' => G::generateUniqueID(),
|
||||||
|
'MESS_ENGINE' => '',
|
||||||
|
'MESS_SERVER' => '',
|
||||||
|
'MESS_PORT' => 0,
|
||||||
|
'MESS_INCOMING_SERVER' => '',
|
||||||
|
'MESS_INCOMING_PORT' => 0,
|
||||||
|
'MESS_RAUTH' => 0,
|
||||||
|
'MESS_ACCOUNT' => '',
|
||||||
|
'MESS_PASSWORD' => '',
|
||||||
|
'MESS_FROM_MAIL' => '',
|
||||||
|
'MESS_FROM_NAME' => '',
|
||||||
|
'SMTPSECURE' => 'No',
|
||||||
|
'MESS_TRY_SEND_INMEDIATLY' => 0,
|
||||||
|
'MAIL_TO' => '',
|
||||||
|
'MESS_DEFAULT' => 0,
|
||||||
|
];
|
||||||
|
});
|
||||||
17
database/factories/ProcessFilesFactory.php
Normal file
17
database/factories/ProcessFilesFactory.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\ProcessFiles::class, function(Faker $faker) {
|
||||||
|
return [
|
||||||
|
'PRF_UID' => G::generateUniqueID(),
|
||||||
|
'PRO_UID' => '',
|
||||||
|
'USR_UID' => '',
|
||||||
|
'PRF_UPDATE_USR_UID' => '',
|
||||||
|
'PRF_PATH' => '',
|
||||||
|
'PRF_TYPE' => '',
|
||||||
|
'PRF_EDITABLE' => 1,
|
||||||
|
'PRF_CREATE_DATE' => $faker->dateTime(),
|
||||||
|
'PRF_UPDATE_DATE' => $faker->dateTime(),
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -59,6 +59,13 @@
|
|||||||
<env name="POPULATE_DATABASE" value="false" />
|
<env name="POPULATE_DATABASE" value="false" />
|
||||||
<!--Performance Mysql test-->
|
<!--Performance Mysql test-->
|
||||||
<env name="RUN_MYSQL_PERFORMANCE_TESTS" value="false" />
|
<env name="RUN_MYSQL_PERFORMANCE_TESTS" value="false" />
|
||||||
|
<!--email account-->
|
||||||
|
<env name="emailEngine" value="PHPMAILER" />
|
||||||
|
<env name="emailServer" value="smtp.gmail.com" />
|
||||||
|
<env name="emailPort" value="465" />
|
||||||
|
<env name="emailAccount" value="admin@processmaker.com" />
|
||||||
|
<env name="emailAccountPassword" value="" />
|
||||||
|
<env name="emailSecure" value="ssl" />
|
||||||
<!--Php variables-->
|
<!--Php variables-->
|
||||||
<var name="APP_ENV" value="testing" />
|
<var name="APP_ENV" value="testing" />
|
||||||
<var name="SYS_SYS" value="test" />
|
<var name="SYS_SYS" value="test" />
|
||||||
|
|||||||
106
tests/CreateTestSite.php
Normal file
106
tests/CreateTestSite.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use G;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use ProcessMaker\Core\Installer;
|
||||||
|
use ProcessMaker\Core\System;
|
||||||
|
|
||||||
|
trait CreateTestSite
|
||||||
|
{
|
||||||
|
private $timezone;
|
||||||
|
private $baseUri;
|
||||||
|
private $user;
|
||||||
|
private $password;
|
||||||
|
private $workspace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get base uri for rest applications.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getBaseUri()
|
||||||
|
{
|
||||||
|
$_SERVER = $this->getServerInformation();
|
||||||
|
$baseUri = System::getServerProtocolHost();
|
||||||
|
|
||||||
|
return $baseUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get server information.
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
private function getServerInformation()
|
||||||
|
{
|
||||||
|
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
||||||
|
if (!file_exists($pathData) && method_exists($this, 'markTestSkipped')) {
|
||||||
|
$this->markTestSkipped('Please define an active workspace.');
|
||||||
|
}
|
||||||
|
$content = file_get_contents($pathData);
|
||||||
|
$serverInfo = unserialize($content);
|
||||||
|
|
||||||
|
return $serverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates a test workspace so that the endpoints can be functional,
|
||||||
|
* it is necessary to change the permissions of the directory so that other
|
||||||
|
* users can access and write to the directory, these users can be for
|
||||||
|
* example: apache2, www-data, httpd, etc...
|
||||||
|
* This method finds the license file of the active site and uses it to register
|
||||||
|
* this license in the LICENSE_MANAGER table. If there is no license file in
|
||||||
|
* the active workspace, an asersion failure will be notified.
|
||||||
|
*/
|
||||||
|
private function createTestSite()
|
||||||
|
{
|
||||||
|
//We copy the license, otherwise you will not be able to lift the site
|
||||||
|
$pathTest = PATH_DATA . "sites" . PATH_SEP . $this->workspace;
|
||||||
|
File::copyDirectory(PATH_DATA . "sites" . PATH_SEP . config("system.workspace"), $pathTest);
|
||||||
|
|
||||||
|
//Write permission for other users for example: apache2, www-data, httpd.
|
||||||
|
passthru('chmod 775 -R ' . $pathTest . ' >> .log 2>&1');
|
||||||
|
|
||||||
|
$installer = new Installer();
|
||||||
|
$options = [
|
||||||
|
'isset' => true,
|
||||||
|
'name' => $this->workspace,
|
||||||
|
'admin' => [
|
||||||
|
'username' => $this->user,
|
||||||
|
'password' => $this->password
|
||||||
|
],
|
||||||
|
'advanced' => [
|
||||||
|
'ao_db_drop' => true,
|
||||||
|
'ao_db_wf' => $this->workspace,
|
||||||
|
'ao_db_rb' => $this->workspace,
|
||||||
|
'ao_db_rp' => $this->workspace
|
||||||
|
]
|
||||||
|
];
|
||||||
|
//The false option creates a connection to the database, necessary to create a site.
|
||||||
|
$installer->create_site($options, false);
|
||||||
|
//Now create site
|
||||||
|
$installer->create_site($options, true);
|
||||||
|
|
||||||
|
//Important so that the dates are stored in the same timezone
|
||||||
|
file_put_contents($pathTest . "/env.ini", "time_zone ='{$this->timezone}'", FILE_APPEND);
|
||||||
|
|
||||||
|
$matchingFiles = File::glob("{$pathTest}/*.dat");
|
||||||
|
$this->assertNotEmpty($matchingFiles);
|
||||||
|
|
||||||
|
//set license
|
||||||
|
$licensePath = array_pop($matchingFiles);
|
||||||
|
DB::Table("LICENSE_MANAGER")->insert([
|
||||||
|
"LICENSE_UID" => G::generateUniqueID(),
|
||||||
|
"LICENSE_USER" => "ProcessMaker Inc",
|
||||||
|
"LICENSE_START" => "1490932800",
|
||||||
|
"LICENSE_END" => 0,
|
||||||
|
"LICENSE_SPAN" => 0,
|
||||||
|
"LICENSE_STATUS" => "ACTIVE",
|
||||||
|
"LICENSE_DATA" => file_get_contents($licensePath),
|
||||||
|
"LICENSE_PATH" => $licensePath,
|
||||||
|
"LICENSE_WORKSPACE" => $this->workspace,
|
||||||
|
"LICENSE_TYPE" => ""
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace tests;
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class DBQueryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
@@ -7,6 +8,67 @@ use Propel;
|
|||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $currentConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $currentArgv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create application
|
||||||
|
*/
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a test case with the given name.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $data
|
||||||
|
* @param string $dataName
|
||||||
|
*/
|
||||||
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Method Tests\CreatesApplication::createApplication() restarts the application
|
||||||
|
* and the values loaded in bootstrap.php have been lost, for this reason
|
||||||
|
* it is necessary to save the following values.
|
||||||
|
*/
|
||||||
|
$this->currentConfig = app('config');
|
||||||
|
$this->currentArgv = $_SERVER['argv'];
|
||||||
|
parent::__construct($name, $data, $dataName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Lost argv are restored.
|
||||||
|
*/
|
||||||
|
if (empty($_SERVER['argv'])) {
|
||||||
|
$_SERVER['argv'] = $this->currentArgv;
|
||||||
|
}
|
||||||
|
parent::setUp();
|
||||||
|
/**
|
||||||
|
* Lost config are restored.
|
||||||
|
*/
|
||||||
|
app()->instance('config', $this->currentConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ if (file_exists($pathData)) {
|
|||||||
define('PATH_DATA', dirname(__DIR__) . '/shared/rbac/');
|
define('PATH_DATA', dirname(__DIR__) . '/shared/rbac/');
|
||||||
}
|
}
|
||||||
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
|
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
|
||||||
define('PATH_DB', dirname(__DIR__) . '/shared/sites/');
|
if (file_exists($pathData)) {
|
||||||
|
define('PATH_DB', PATH_DATA . 'sites/');
|
||||||
|
} else {
|
||||||
|
define('PATH_DB', dirname(__DIR__) . '/shared/sites/');
|
||||||
|
}
|
||||||
define('PATH_SEP', '/');
|
define('PATH_SEP', '/');
|
||||||
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
|
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
|
||||||
define('SYS_LANG', 'en');
|
define('SYS_LANG', 'en');
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class CustomizeFormatterTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
self::$directory = PATH_TRUNK . '/storage/logs/';
|
self::$directory = PATH_TRUNK . '/storage/logs/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,34 @@ class PmDynaformTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Constructor of the class.
|
* Constructor of the class.
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
{
|
{
|
||||||
|
parent::__construct($name, $data, $dataName);
|
||||||
$_SERVER["REQUEST_URI"] = "";
|
$_SERVER["REQUEST_URI"] = "";
|
||||||
|
if (!defined("DB_ADAPTER")) {
|
||||||
|
define("DB_ADAPTER", "mysql");
|
||||||
|
}
|
||||||
|
if (!defined("DB_HOST")) {
|
||||||
|
define("DB_HOST", env('DB_HOST'));
|
||||||
|
}
|
||||||
|
if (!defined("DB_NAME")) {
|
||||||
|
define("DB_NAME", env('DB_DATABASE'));
|
||||||
|
}
|
||||||
|
if (!defined("DB_USER")) {
|
||||||
|
define("DB_USER", env('DB_USERNAME'));
|
||||||
|
}
|
||||||
|
if (!defined("DB_PASS")) {
|
||||||
|
define("DB_PASS", env('DB_PASSWORD'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ class SpoolRunTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Constructor of the class.
|
* Constructor of the class.
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
{
|
{
|
||||||
|
parent::__construct($name, $data, $dataName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
484
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file
484
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file
@@ -0,0 +1,484 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Jobs\EmailEvent;
|
||||||
|
use Faker\Factory;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
|
use ProcessMaker\Model\EmailServer;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
use Tests\CreateTestSite;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class WsBaseTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This trait allows obtaining a test site that makes use of the database
|
||||||
|
* mentioned for the test.
|
||||||
|
*/
|
||||||
|
use CreateTestSite;
|
||||||
|
|
||||||
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
|
{
|
||||||
|
parent::__construct($name, $data, $dataName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->timezone = config('app.timezone');
|
||||||
|
$_SESSION['USR_TIME_ZONE'] = $this->timezone;
|
||||||
|
$this->baseUri = $this->getBaseUri();
|
||||||
|
$this->user = 'admin';
|
||||||
|
$this->password = 'admin';
|
||||||
|
$this->workspace = env("DB_DATABASE", "test");
|
||||||
|
$this->createTestSite();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an application.
|
||||||
|
*
|
||||||
|
* @param int $applicationNumber
|
||||||
|
* @return \stdClass
|
||||||
|
*/
|
||||||
|
private function createNewCase($applicationNumber = null)
|
||||||
|
{
|
||||||
|
if (empty($applicationNumber)) {
|
||||||
|
$faker = Factory::create();
|
||||||
|
$applicationNumber = $faker->unique()->numberBetween(1, 10000000);
|
||||||
|
}
|
||||||
|
$userUid = G::generateUniqueID();
|
||||||
|
$processUid = G::generateUniqueID();
|
||||||
|
$taskUid = G::generateUniqueID();
|
||||||
|
$applicationUid = G::generateUniqueID();
|
||||||
|
|
||||||
|
$appData = [
|
||||||
|
'SYS_LANG' => 'en',
|
||||||
|
'SYS_SKIN' => 'neoclassic',
|
||||||
|
'SYS_SYS' => 'workflow',
|
||||||
|
'APPLICATION' => G::generateUniqueID(),
|
||||||
|
'PROCESS' => G::generateUniqueID(),
|
||||||
|
'TASK' => '',
|
||||||
|
'INDEX' => 2,
|
||||||
|
'USER_LOGGED' => $userUid,
|
||||||
|
'USR_USERNAME' => 'admin',
|
||||||
|
'APP_NUMBER' => $applicationNumber,
|
||||||
|
'PIN' => '97ZN'
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = factory(User::class)->create([
|
||||||
|
'USR_UID' => $userUid
|
||||||
|
]);
|
||||||
|
|
||||||
|
$process = factory(Process::class)->create([
|
||||||
|
'PRO_UID' => $processUid
|
||||||
|
]);
|
||||||
|
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID
|
||||||
|
]);
|
||||||
|
|
||||||
|
$application = factory(Application::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_UID' => $applicationUid,
|
||||||
|
'APP_NUMBER' => $applicationNumber,
|
||||||
|
'APP_DATA' => serialize($appData)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$result = new stdClass();
|
||||||
|
$result->userUid = $userUid;
|
||||||
|
$result->processUid = $processUid;
|
||||||
|
$result->taskUid = $taskUid;
|
||||||
|
$result->applicationUid = $applicationUid;
|
||||||
|
$result->applicationNumber = $applicationNumber;
|
||||||
|
$result->appData = $appData;
|
||||||
|
$result->user = $user;
|
||||||
|
$result->process = $process;
|
||||||
|
$result->task = $task;
|
||||||
|
$result->application = $application;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a email server configuration.
|
||||||
|
*
|
||||||
|
* @return ProcessMaker\Model\EmailServer;
|
||||||
|
*/
|
||||||
|
private function createEmailServer()
|
||||||
|
{
|
||||||
|
$passwordEnv = env('emailAccountPassword');
|
||||||
|
$password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT');
|
||||||
|
$emailServer = factory(EmailServer::class)->create([
|
||||||
|
'MESS_ENGINE' => env('emailEngine'),
|
||||||
|
'MESS_SERVER' => env('emailServer'),
|
||||||
|
'MESS_PORT' => env('emailPort'),
|
||||||
|
'MESS_INCOMING_SERVER' => '',
|
||||||
|
'MESS_INCOMING_PORT' => 0,
|
||||||
|
'MESS_RAUTH' => 1,
|
||||||
|
'MESS_ACCOUNT' => env('emailAccount'),
|
||||||
|
'MESS_PASSWORD' => $password,
|
||||||
|
'MESS_FROM_MAIL' => env('emailAccount'),
|
||||||
|
'MESS_FROM_NAME' => '',
|
||||||
|
'SMTPSECURE' => 'ssl',
|
||||||
|
'MESS_TRY_SEND_INMEDIATLY' => 1,
|
||||||
|
'MAIL_TO' => $password,
|
||||||
|
'MESS_DEFAULT' => 1,
|
||||||
|
]);
|
||||||
|
return $emailServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new template for send email.
|
||||||
|
*
|
||||||
|
* @param string $proUid
|
||||||
|
* @param string $usrUid
|
||||||
|
* @return \ProcessMaker\Model\ProcessFiles
|
||||||
|
*/
|
||||||
|
private function createTemplate($proUid, $usrUid)
|
||||||
|
{
|
||||||
|
$path1 = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . "mailTemplates" . PATH_SEP . "{$proUid}";
|
||||||
|
mkdir($path1);
|
||||||
|
$path2 = $path1 . PATH_SEP . "emailEvent_" . G::generateUniqueID() . ".html";
|
||||||
|
|
||||||
|
$htmlContent = $this->createDefaultHtmlContent('Test');
|
||||||
|
file_put_contents($path2, $htmlContent);
|
||||||
|
|
||||||
|
$template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([
|
||||||
|
'PRO_UID' => $proUid,
|
||||||
|
'USR_UID' => $usrUid,
|
||||||
|
'PRF_PATH' => $path2
|
||||||
|
]);
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create empty html.
|
||||||
|
*
|
||||||
|
* @param string $content
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function createDefaultHtmlContent($content = '')
|
||||||
|
{
|
||||||
|
$string = ''
|
||||||
|
. '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
||||||
|
. '<html>'
|
||||||
|
. '<head>'
|
||||||
|
. '</head>'
|
||||||
|
. '<body>'
|
||||||
|
. $content
|
||||||
|
. '</body>'
|
||||||
|
. '</html>';
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents a collection of "messageType" for queue elements.
|
||||||
|
*/
|
||||||
|
public function messageTypesWithQueue()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[WsBase::MESSAGE_TYPE_EMAIL_EVENT],
|
||||||
|
[WsBase::MESSAGE_TYPE_PM_FUNCTION],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents a collection of "messageType" for no queueable elements.
|
||||||
|
*/
|
||||||
|
public function messageTypesWithoutQueue()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL],
|
||||||
|
[WsBase::MESSAGE_TYPE_CASE_NOTE],
|
||||||
|
[WsBase::MESSAGE_TYPE_EXTERNAL_REGISTRATION],
|
||||||
|
[WsBase::MESSAGE_TYPE_RETRIEVE_PASSWORD],
|
||||||
|
[WsBase::MESSAGE_TYPE_SOAP],
|
||||||
|
[WsBase::MESSAGE_TYPE_TASK_NOTIFICATION],
|
||||||
|
[WsBase::MESSAGE_TYPE_TEST_EMAIL],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should send an email of types elements to the work queue jobs.
|
||||||
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = $emailServer->MESS_ACCOUNT;
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = $emailServer->toArray();
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageType;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should send an email of types elements without work queue jobs.
|
||||||
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithoutQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = "";
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = $emailServer->toArray();
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertNotPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should send an sendMessage with queue jobs and empty config parameter.
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = $emailServer->MESS_ACCOUNT;
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = []; //with empty configuration
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should send an sendMessage without queue jobs and empty config parameter.
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithoutQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = "";
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = []; //with empty configuration
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertNotPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should send an sendMessage with queue jobs and config parameter like id.
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = $emailServer->MESS_ACCOUNT;
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should send an sendMessage without queue jobs and config parameter like id.
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithoutQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = "";
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
||||||
|
$gmail = 0;
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertNotPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
||||||
|
* @test
|
||||||
|
* @dataProvider messageTypesWithoutQueue
|
||||||
|
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||||
|
*/
|
||||||
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
||||||
|
{
|
||||||
|
//data
|
||||||
|
$emailServer = $this->createEmailServer();
|
||||||
|
$case = $this->createNewCase();
|
||||||
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
$appUid = $case->applicationUid;
|
||||||
|
$from = $emailServer->MESS_ACCOUNT;
|
||||||
|
$to = "";
|
||||||
|
$cc = "";
|
||||||
|
$bcc = "";
|
||||||
|
$subject = "test";
|
||||||
|
$templateName = basename($template->PRF_PATH);
|
||||||
|
$appFields = [];
|
||||||
|
$attachment = [];
|
||||||
|
$showMessage = true;
|
||||||
|
$delIndex = 0;
|
||||||
|
$config = $emailServer->MESS_UID;
|
||||||
|
$gmail = 1; //GMail flag enabled
|
||||||
|
$appMsgType = $messageTypes;
|
||||||
|
|
||||||
|
//assertions
|
||||||
|
Queue::fake();
|
||||||
|
Queue::assertNothingPushed();
|
||||||
|
|
||||||
|
$wsBase = new WsBase();
|
||||||
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||||
|
Queue::assertNotPushed(EmailEvent::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ class GroupTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
$this->setInstanceGroup(new Group());
|
$this->setInstanceGroup(new Group());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +93,16 @@ class GroupTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetUsersAvailable($groupUid)
|
public function testGetUsersAvailable($groupUid)
|
||||||
{
|
{
|
||||||
|
$result = \ProcessMaker\Model\User::where('USERS.USR_STATUS', '<>', 'CLOSED')
|
||||||
|
->whereNotIn('USERS.USR_UID', function($query) {
|
||||||
|
$query->select('GROUP_USER.USR_UID')
|
||||||
|
->from('GROUP_USER');
|
||||||
|
})
|
||||||
|
->whereNotIn('USERS.USR_UID', ['00000000000000000000000000000002'])
|
||||||
|
->get()
|
||||||
|
->toArray();
|
||||||
$response = $this->getInstanceGroup()->getUsers('AVAILABLE-USERS', $groupUid);
|
$response = $this->getInstanceGroup()->getUsers('AVAILABLE-USERS', $groupUid);
|
||||||
$this->assertCount(1, $response);
|
$this->assertCount(count($result), $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class SkinsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
$this->object = new Skins();
|
$this->object = new Skins();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ class SkinsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
|
parent::tearDown();
|
||||||
G::rm_dir(PATH_DATA . 'skins');
|
G::rm_dir(PATH_DATA . 'skins');
|
||||||
mkdir(PATH_DATA . 'skins');
|
mkdir(PATH_DATA . 'skins');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Core;
|
||||||
|
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class JobsManagerTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var JobsManager
|
||||||
|
*/
|
||||||
|
protected $object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up the fixture, for example, opens a network connection.
|
||||||
|
* This method is called before a test is executed.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->object = new JobsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tears down the fixture, for example, closes a network connection.
|
||||||
|
* This method is called after a test is executed.
|
||||||
|
*/
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should return the configured value of delay in env.ini
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::getDelay
|
||||||
|
*/
|
||||||
|
public function testGetDelay()
|
||||||
|
{
|
||||||
|
$this->object->init();
|
||||||
|
$actual = $this->object->getDelay();
|
||||||
|
|
||||||
|
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||||
|
|
||||||
|
$this->assertEquals($envs['delay'], $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should return the configured value of tries in env.ini
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::getTries
|
||||||
|
*/
|
||||||
|
public function testGetTries()
|
||||||
|
{
|
||||||
|
$this->object->init();
|
||||||
|
$actual = $this->object->getTries();
|
||||||
|
|
||||||
|
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||||
|
|
||||||
|
$this->assertEquals($envs['tries'], $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should return the configured value of retry_after in env.ini
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::getRetryAfter
|
||||||
|
*/
|
||||||
|
public function testGetRetryAfter()
|
||||||
|
{
|
||||||
|
$this->object->init();
|
||||||
|
$actual = $this->object->getRetryAfter();
|
||||||
|
|
||||||
|
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||||
|
|
||||||
|
$this->assertEquals($envs['retry_after'], $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns a single instance of the object (this is a singleton).
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::getSingleton
|
||||||
|
*/
|
||||||
|
public function testGetSingleton()
|
||||||
|
{
|
||||||
|
$object1 = $this->object->getSingleton();
|
||||||
|
$this->assertEquals($this->object, $object1);
|
||||||
|
|
||||||
|
$object2 = $this->object->getSingleton();
|
||||||
|
$this->assertEquals($this->object, $object2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the object was started correctly returns the instance of this object.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::init
|
||||||
|
*/
|
||||||
|
public function testInit()
|
||||||
|
{
|
||||||
|
$actual = $this->object->init();
|
||||||
|
|
||||||
|
$this->assertEquals($this->object, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This must return the instance of the object that prepares the work for dispatch.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::dispatch
|
||||||
|
*/
|
||||||
|
public function testDispatch()
|
||||||
|
{
|
||||||
|
$callback = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
$actual = $this->object->dispatch('Email', $callback);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(\Illuminate\Foundation\Bus\PendingDispatch::class, $actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the value of the option specified in the second parameter from an
|
||||||
|
* array that represents the arguments.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @covers ProcessMaker\Core\JobsManager::getOptionValueFromArguments
|
||||||
|
*/
|
||||||
|
public function testGetOptionValueFromArguments()
|
||||||
|
{
|
||||||
|
$optionName = "--workspace";
|
||||||
|
$valueOption = "workflow";
|
||||||
|
$allocationSeparator = "=";
|
||||||
|
|
||||||
|
$parameter0 = "queue:work";
|
||||||
|
$parameter1 = $optionName . $allocationSeparator . $valueOption;
|
||||||
|
|
||||||
|
$arguments = [$parameter0, $parameter1];
|
||||||
|
|
||||||
|
$actual = $this->object->getOptionValueFromArguments($arguments, $optionName);
|
||||||
|
$this->assertEquals($valueOption, $actual);
|
||||||
|
|
||||||
|
$actual = $this->object->getOptionValueFromArguments($arguments, $optionName, $allocationSeparator);
|
||||||
|
$this->assertEquals($valueOption, $actual);
|
||||||
|
|
||||||
|
$actual = $this->object->getOptionValueFromArguments($arguments, "missing");
|
||||||
|
$this->assertEquals(false, $actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Tests\unit\workflow\src\ProcessMaker\Model;
|
namespace Tests\unit\workflow\src\ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Faker\Factory;
|
||||||
use G;
|
use G;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -580,23 +581,24 @@ class DelegationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function it_should_sort_by_process()
|
public function it_should_sort_by_process()
|
||||||
{
|
{
|
||||||
|
$faker = Factory::create();
|
||||||
factory(User::class, 100)->create();
|
factory(User::class, 100)->create();
|
||||||
$process = factory(Process::class)->create([
|
$process = factory(Process::class)->create([
|
||||||
'PRO_ID' => 2,
|
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||||
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class)->create([
|
factory(Delegation::class)->create([
|
||||||
'PRO_ID' => $process->id
|
'PRO_ID' => $process->id
|
||||||
]);
|
]);
|
||||||
$process = factory(Process::class)->create([
|
$process = factory(Process::class)->create([
|
||||||
'PRO_ID' => 1,
|
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||||
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class)->create([
|
factory(Delegation::class)->create([
|
||||||
'PRO_ID' => $process->id
|
'PRO_ID' => $process->id
|
||||||
]);
|
]);
|
||||||
$process = factory(Process::class)->create([
|
$process = factory(Process::class)->create([
|
||||||
'PRO_ID' => 3,
|
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||||
'PRO_TITLE' => 'Russia Supplier Payment Proposal'
|
'PRO_TITLE' => 'Russia Supplier Payment Proposal'
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class)->create([
|
factory(Delegation::class)->create([
|
||||||
@@ -1134,12 +1136,15 @@ class DelegationTest extends TestCase
|
|||||||
factory(User::class, 100)->create();
|
factory(User::class, 100)->create();
|
||||||
$process = factory(Process::class)->create();
|
$process = factory(Process::class)->create();
|
||||||
$application = factory(Application::class)->create([
|
$application = factory(Application::class)->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_UID' => G::generateUniqueID()
|
'APP_UID' => G::generateUniqueID()
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class)->states('closed')->create([
|
factory(Delegation::class)->states('closed')->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_UID' => $application->APP_UID
|
'APP_UID' => $application->APP_UID
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class)->states('open')->create([
|
factory(Delegation::class)->states('open')->create([
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_UID' => $application->APP_UID,
|
'APP_UID' => $application->APP_UID,
|
||||||
'DEL_INDEX' => 2
|
'DEL_INDEX' => 2
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class Padl
|
|||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* */
|
* */
|
||||||
public function padl()
|
public function __construct()
|
||||||
{
|
{
|
||||||
# check to see if the class has been secured
|
# check to see if the class has been secured
|
||||||
$this->_check_secure();
|
$this->_check_secure();
|
||||||
@@ -531,21 +531,21 @@ class Padl
|
|||||||
# check to see if mycrypt exists
|
# check to see if mycrypt exists
|
||||||
if ($this->USE_MCRYPT) {
|
if ($this->USE_MCRYPT) {
|
||||||
# openup mcrypt
|
# openup mcrypt
|
||||||
$td = mcrypt_module_open($this->ALGORITHM, '', 'ecb', '');
|
$td = @mcrypt_module_open($this->ALGORITHM, '', 'ecb', '');
|
||||||
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
$iv = @mcrypt_create_iv(@mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
||||||
# process the key
|
# process the key
|
||||||
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
|
$key = substr($key, 0, @mcrypt_enc_get_key_size($td));
|
||||||
# init mcrypt
|
# init mcrypt
|
||||||
mcrypt_generic_init($td, $key, $iv);
|
@mcrypt_generic_init($td, $key, $iv);
|
||||||
|
|
||||||
# encrypt data
|
# encrypt data
|
||||||
# double base64 gets makes all the characters alpha numeric
|
# double base64 gets makes all the characters alpha numeric
|
||||||
# and gets rig of the special characters
|
# and gets rig of the special characters
|
||||||
$crypt = mcrypt_generic($td, serialize($src_array));
|
$crypt = @mcrypt_generic($td, serialize($src_array));
|
||||||
|
|
||||||
# shutdown mcrypt
|
# shutdown mcrypt
|
||||||
mcrypt_generic_deinit($td);
|
@mcrypt_generic_deinit($td);
|
||||||
mcrypt_module_close($td);
|
@mcrypt_module_close($td);
|
||||||
} else {
|
} else {
|
||||||
# if mcrypt doesn't exist use regular encryption method
|
# if mcrypt doesn't exist use regular encryption method
|
||||||
# init the vars
|
# init the vars
|
||||||
@@ -586,19 +586,19 @@ class Padl
|
|||||||
# check to see if mycrypt exists
|
# check to see if mycrypt exists
|
||||||
if ($this->USE_MCRYPT) {
|
if ($this->USE_MCRYPT) {
|
||||||
# openup mcrypt
|
# openup mcrypt
|
||||||
$td = mcrypt_module_open($this->ALGORITHM, '', 'ecb', '');
|
$td = @mcrypt_module_open($this->ALGORITHM, '', 'ecb', '');
|
||||||
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
$iv = @mcrypt_create_iv(@mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
|
||||||
# process the key
|
# process the key
|
||||||
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
|
$key = substr($key, 0, @mcrypt_enc_get_key_size($td));
|
||||||
# init mcrypt
|
# init mcrypt
|
||||||
mcrypt_generic_init($td, $key, $iv);
|
@mcrypt_generic_init($td, $key, $iv);
|
||||||
|
|
||||||
# decrypt the data and return
|
# decrypt the data and return
|
||||||
$decrypt = mdecrypt_generic($td, $str);
|
$decrypt = @mdecrypt_generic($td, $str);
|
||||||
|
|
||||||
# shutdown mcrypt
|
# shutdown mcrypt
|
||||||
mcrypt_generic_deinit($td);
|
@mcrypt_generic_deinit($td);
|
||||||
mcrypt_module_close($td);
|
@mcrypt_module_close($td);
|
||||||
} else {
|
} else {
|
||||||
# if mcrypt doesn't exist use regular decryption method
|
# if mcrypt doesn't exist use regular decryption method
|
||||||
# init the decrypt vars
|
# init the decrypt vars
|
||||||
|
|||||||
13
workflow/engine/src/ProcessMaker/Model/EmailServer.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/EmailServer.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class EmailServer extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'EMAIL_SERVER';
|
||||||
|
protected $primaryKey = 'MESS_UID';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
||||||
13
workflow/engine/src/ProcessMaker/Model/ProcessFiles.php
Normal file
13
workflow/engine/src/ProcessMaker/Model/ProcessFiles.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ProcessFiles extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'PROCESS_FILES';
|
||||||
|
protected $primaryKey = 'PRF_UID';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user