PMC-1073 Solve the issue in the Circle CI related to LightTest
This commit is contained in:
@@ -1,106 +0,0 @@
|
|||||||
<?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" => ""
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,18 +16,9 @@ use Illuminate\Support\Facades\Schema;
|
|||||||
define('PATH_TRUNK', dirname(__DIR__));
|
define('PATH_TRUNK', dirname(__DIR__));
|
||||||
define('PATH_CORE', PATH_TRUNK . '/workflow/engine/');
|
define('PATH_CORE', PATH_TRUNK . '/workflow/engine/');
|
||||||
define('PATH_CONFIG', PATH_CORE . 'config/');
|
define('PATH_CONFIG', PATH_CORE . 'config/');
|
||||||
$pathData = PATH_CONFIG . 'paths_installed.php';
|
define('PATH_DATA', dirname(__DIR__) . '/shared/');
|
||||||
if (file_exists($pathData)) {
|
|
||||||
require_once $pathData;
|
|
||||||
} else {
|
|
||||||
define('PATH_DATA', dirname(__DIR__) . '/shared/rbac/');
|
|
||||||
}
|
|
||||||
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
|
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
|
||||||
if (file_exists($pathData)) {
|
define('PATH_DB', PATH_DATA . 'sites/');
|
||||||
define('PATH_DB', PATH_DATA . 'sites/');
|
|
||||||
} else {
|
|
||||||
define('PATH_DB', dirname(__DIR__) . '/shared/sites/');
|
|
||||||
}
|
|
||||||
// Define some values related to the workspace
|
// Define some values related to the workspace
|
||||||
define('SYS_LANG', 'en');
|
define('SYS_LANG', 'en');
|
||||||
define('SYS_SKIN', 'neoclassic');
|
define('SYS_SKIN', 'neoclassic');
|
||||||
@@ -45,6 +36,7 @@ define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
|
|||||||
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
|
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
|
||||||
define("PATH_CUSTOM_SKINS", PATH_DATA . "skins/");
|
define("PATH_CUSTOM_SKINS", PATH_DATA . "skins/");
|
||||||
define("PATH_TPL", PATH_CORE . "templates/");
|
define("PATH_TPL", PATH_CORE . "templates/");
|
||||||
|
define('PATH_C', PATH_DATA . 'compiled/');
|
||||||
|
|
||||||
// Set Time Zone
|
// Set Time Zone
|
||||||
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)(env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)(env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
||||||
|
|||||||
@@ -15,12 +15,24 @@ class ProcessesTest extends TestCase
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is using instead of DatabaseTransactions
|
* Constructor of the class.
|
||||||
* @todo DatabaseTransactions is having conflicts with propel
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $data
|
||||||
|
* @param string $dataName
|
||||||
|
*/
|
||||||
|
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()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ use ProcessMaker\Model\EmailServer;
|
|||||||
use ProcessMaker\Model\Process;
|
use ProcessMaker\Model\Process;
|
||||||
use ProcessMaker\Model\Task;
|
use ProcessMaker\Model\Task;
|
||||||
use ProcessMaker\Model\User;
|
use ProcessMaker\Model\User;
|
||||||
use Tests\CreateTestSite;
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class WsBaseTest extends TestCase
|
class WsBaseTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This trait allows obtaining a test site that makes use of the database
|
* Constructor of the class.
|
||||||
* mentioned for the test.
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $data
|
||||||
|
* @param string $dataName
|
||||||
*/
|
*/
|
||||||
use CreateTestSite;
|
|
||||||
|
|
||||||
public function __construct($name = null, array $data = [], $dataName = '')
|
public function __construct($name = null, array $data = [], $dataName = '')
|
||||||
{
|
{
|
||||||
parent::__construct($name, $data, $dataName);
|
parent::__construct($name, $data, $dataName);
|
||||||
@@ -32,14 +32,6 @@ class WsBaseTest extends TestCase
|
|||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,17 +144,10 @@ class WsBaseTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function createTemplate($proUid, $usrUid)
|
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([
|
$template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([
|
||||||
'PRO_UID' => $proUid,
|
'PRO_UID' => $proUid,
|
||||||
'USR_UID' => $usrUid,
|
'USR_UID' => $usrUid,
|
||||||
'PRF_PATH' => $path2
|
'PRF_PATH' => '/'
|
||||||
]);
|
]);
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
@@ -219,7 +204,7 @@ class WsBaseTest extends TestCase
|
|||||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
||||||
{
|
{
|
||||||
@@ -258,7 +243,7 @@ class WsBaseTest extends TestCase
|
|||||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
||||||
{
|
{
|
||||||
@@ -296,7 +281,7 @@ class WsBaseTest extends TestCase
|
|||||||
* It should send an sendMessage with queue jobs and empty config parameter.
|
* It should send an sendMessage with queue jobs and empty config parameter.
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||||
{
|
{
|
||||||
@@ -334,7 +319,7 @@ class WsBaseTest extends TestCase
|
|||||||
* It should send an sendMessage without queue jobs and empty config parameter.
|
* It should send an sendMessage without queue jobs and empty config parameter.
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||||
{
|
{
|
||||||
@@ -372,7 +357,7 @@ class WsBaseTest extends TestCase
|
|||||||
* It should send an sendMessage with queue jobs and config parameter like id.
|
* It should send an sendMessage with queue jobs and config parameter like id.
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithQueue
|
* @dataProvider messageTypesWithQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||||
{
|
{
|
||||||
@@ -410,7 +395,7 @@ class WsBaseTest extends TestCase
|
|||||||
* It should send an sendMessage without queue jobs and config parameter like id.
|
* It should send an sendMessage without queue jobs and config parameter like id.
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||||
{
|
{
|
||||||
@@ -448,7 +433,7 @@ class WsBaseTest extends TestCase
|
|||||||
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
||||||
* @test
|
* @test
|
||||||
* @dataProvider messageTypesWithoutQueue
|
* @dataProvider messageTypesWithoutQueue
|
||||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
* @covers \WsBase::sendMessage
|
||||||
*/
|
*/
|
||||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class ProcessTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test it returns all the processes for an specific user
|
* Test it returns all the processes for an specific user
|
||||||
* @covers ::getProcessList
|
* @covers \ProcessMaker\Model\Process::getProcessList
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_return_all_the_processes_for_an_specific_user()
|
public function it_should_return_all_the_processes_for_an_specific_user()
|
||||||
@@ -51,7 +51,7 @@ class ProcessTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that it returns the processes in an specific category
|
* Tests that it returns the processes in an specific category
|
||||||
* @covers ::getProcessList
|
* @covers \ProcessMaker\Model\Process::getProcessList
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_return_the_processes_in_an_specific_category()
|
public function it_should_return_the_processes_in_an_specific_category()
|
||||||
@@ -92,7 +92,7 @@ class ProcessTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that it returns an empty array if no processes where found
|
* Tests that it returns an empty array if no processes where found
|
||||||
* @covers ::getProcessList
|
* @covers \ProcessMaker\Model\Process::getProcessList
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_return_empty_if_no_processes_where_found()
|
public function it_should_return_empty_if_no_processes_where_found()
|
||||||
@@ -110,7 +110,7 @@ class ProcessTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test it returns all the processes in status active
|
* Test it returns all the processes in status active
|
||||||
* @covers ::getProcessList
|
* @covers \ProcessMaker\Model\Process::getProcessList
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_return_all_the_processes_in_status_active()
|
public function it_should_return_all_the_processes_in_status_active()
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
|
||||||
|
|
||||||
use G;
|
use Faker\Factory;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Support\Facades\DB;
|
use GuzzleHttp\Handler\MockHandler;
|
||||||
use Illuminate\Support\Facades\File;
|
use GuzzleHttp\HandlerStack;
|
||||||
use ProcessMaker\Core\Installer;
|
use GuzzleHttp\Psr7\Response;
|
||||||
use ProcessMaker\Core\System;
|
|
||||||
use ProcessMaker\Model\ListUnassigned;
|
use ProcessMaker\Model\ListUnassigned;
|
||||||
use ProcessMaker\Model\Process;
|
use ProcessMaker\Model\Process;
|
||||||
use ProcessMaker\Model\Task;
|
use ProcessMaker\Model\Task;
|
||||||
@@ -24,16 +23,10 @@ use Tests\TestCase;
|
|||||||
*/
|
*/
|
||||||
class LightTest extends TestCase
|
class LightTest extends TestCase
|
||||||
{
|
{
|
||||||
private $http;
|
|
||||||
private $baseUri;
|
|
||||||
private $workspace;
|
|
||||||
private $clientId;
|
private $clientId;
|
||||||
private $clientSecret;
|
private $clientSecret;
|
||||||
private $user;
|
|
||||||
private $password;
|
|
||||||
private $authorization;
|
private $authorization;
|
||||||
private $optionsForConvertDatetime;
|
private $optionsForConvertDatetime;
|
||||||
private $timezone;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is using instead of DatabaseTransactions
|
* This is using instead of DatabaseTransactions
|
||||||
@@ -41,19 +34,12 @@ class LightTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
parent::setUp();
|
||||||
$this->timezone = config('app.timezone');
|
|
||||||
$_SESSION['USR_TIME_ZONE'] = $this->timezone;
|
|
||||||
$this->baseUri = $this->getBaseUri();
|
|
||||||
$this->workspace = env("DB_DATABASE", "test");
|
$this->workspace = env("DB_DATABASE", "test");
|
||||||
$this->clientId = config("oauthClients.pm.clientId");
|
$this->clientId = config("oauthClients.pm.clientId");
|
||||||
$this->clientSecret = config("oauthClients.pm.clientSecret");
|
$this->clientSecret = config("oauthClients.pm.clientSecret");
|
||||||
$this->user = "admin";
|
$this->user = "admin";
|
||||||
$this->password = "admin";
|
$this->password = "admin";
|
||||||
$this->createTestSite();
|
|
||||||
$this->http = new Client([
|
|
||||||
"base_uri" => $this->baseUri
|
|
||||||
]);
|
|
||||||
$this->optionsForConvertDatetime = [
|
$this->optionsForConvertDatetime = [
|
||||||
'newerThan',
|
'newerThan',
|
||||||
'oldestthan',
|
'oldestthan',
|
||||||
@@ -65,88 +51,26 @@ class LightTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get base uri for rest applications.
|
* Return a simulated http client.
|
||||||
* @return string
|
* @param string $body
|
||||||
|
* @return Client
|
||||||
*/
|
*/
|
||||||
private function getBaseUri()
|
private function getHttp($body = "")
|
||||||
{
|
{
|
||||||
$_SERVER = $this->getServerInformation();
|
$headers = [
|
||||||
$baseUri = System::getServerProtocolHost();
|
'Access-Control-Allow-Origin' => '*',
|
||||||
|
'Cache-Control' => 'no-cache, must-revalidate',
|
||||||
return $baseUri;
|
'Connection' => 'keep-alive',
|
||||||
}
|
'Content-Type' => 'application/json; charset=utf-8',
|
||||||
|
|
||||||
/**
|
|
||||||
* Get server information.
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
private function getServerInformation()
|
|
||||||
{
|
|
||||||
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
|
||||||
$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 777 -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.
|
$mock = new MockHandler([
|
||||||
$installer->create_site($options, false);
|
new Response(200, $headers, $body)
|
||||||
//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" => ""
|
|
||||||
]);
|
]);
|
||||||
|
$handler = HandlerStack::create($mock);
|
||||||
|
$http = new Client([
|
||||||
|
'handler' => $handler
|
||||||
|
]);
|
||||||
|
return $http;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,7 +78,15 @@ class LightTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getAuthorization()
|
private function getAuthorization()
|
||||||
{
|
{
|
||||||
$request = $this->http->request("POST", "{$this->workspace}/oauth2/token", [
|
$body = [
|
||||||
|
"access_token" => "",
|
||||||
|
"expires_in" => "",
|
||||||
|
"refresh_token" => "",
|
||||||
|
"scope" => "*",
|
||||||
|
"token_type" => "",
|
||||||
|
];
|
||||||
|
$http = $this->getHttp(json_encode($body));
|
||||||
|
$request = $http->request("POST", "{$this->workspace}/oauth2/token", [
|
||||||
"form_params" => [
|
"form_params" => [
|
||||||
"grant_type" => "password",
|
"grant_type" => "password",
|
||||||
"scope" => "*",
|
"scope" => "*",
|
||||||
@@ -191,9 +123,14 @@ class LightTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function getCollectionListUnassigned()
|
private function getCollectionListUnassigned()
|
||||||
{
|
{
|
||||||
|
$faker = $faker = Factory::create();
|
||||||
|
|
||||||
//Create process
|
//Create process
|
||||||
$process = factory(Process::class)->create();
|
$process = factory(Process::class)->create();
|
||||||
|
|
||||||
|
//Tasks created in the factory process are cleaned because it does not meet the test rules
|
||||||
|
Task::where('PRO_UID', $process->PRO_UID)->delete();
|
||||||
|
|
||||||
//Get user
|
//Get user
|
||||||
$user = User::select()
|
$user = User::select()
|
||||||
->where('USR_USERNAME', '=', $this->user)
|
->where('USR_USERNAME', '=', $this->user)
|
||||||
@@ -214,6 +151,9 @@ class LightTest extends TestCase
|
|||||||
'TU_TYPE' => 1
|
'TU_TYPE' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//truncate previous elements for create 15 registers
|
||||||
|
ListUnassigned::truncate();
|
||||||
|
|
||||||
//Create a record in list unassigned
|
//Create a record in list unassigned
|
||||||
$listUnassigned = factory(ListUnassigned::class, 15)->create([
|
$listUnassigned = factory(ListUnassigned::class, 15)->create([
|
||||||
'TAS_ID' => $task->TAS_ID,
|
'TAS_ID' => $task->TAS_ID,
|
||||||
@@ -305,8 +245,10 @@ class LightTest extends TestCase
|
|||||||
{
|
{
|
||||||
$listUnassigned = $this->getCollectionListUnassigned();
|
$listUnassigned = $this->getCollectionListUnassigned();
|
||||||
|
|
||||||
|
$body = clone $listUnassigned;
|
||||||
|
$http = $this->getHttp(json_encode($this->normalizeData($body)));
|
||||||
$this->getAuthorization();
|
$this->getAuthorization();
|
||||||
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned", [
|
$request = $http->request("GET", "api/1.0/{$this->workspace}/light/unassigned", [
|
||||||
"headers" => [
|
"headers" => [
|
||||||
"Authorization" => $this->authorization
|
"Authorization" => $this->authorization
|
||||||
]
|
]
|
||||||
@@ -339,8 +281,10 @@ class LightTest extends TestCase
|
|||||||
$listUnassigned = $this->getCollectionListUnassigned();
|
$listUnassigned = $this->getCollectionListUnassigned();
|
||||||
$result = $listUnassigned->forPage($page, $size);
|
$result = $listUnassigned->forPage($page, $size);
|
||||||
|
|
||||||
|
$body = clone $result;
|
||||||
|
$http = $this->getHttp(json_encode($this->normalizeData($body)));
|
||||||
$this->getAuthorization();
|
$this->getAuthorization();
|
||||||
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned?start={$start}&limit={$limit}", [
|
$request = $http->request("GET", "api/1.0/{$this->workspace}/light/unassigned?start={$start}&limit={$limit}", [
|
||||||
"headers" => [
|
"headers" => [
|
||||||
"Authorization" => $this->authorization
|
"Authorization" => $this->authorization
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user