PMC-1306 Add new attribute mobile_offline_tables_download_interval related to the env.ini configuration
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\BusinessModel\Light;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LightTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This verifies that the mobile_offline_tables_download_interval parameter
|
||||
* is defined in the result returned by the getConfiguration() method.
|
||||
*
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function it_should_return_mobile_offline_tables_download_interval_from_get_configuration_method()
|
||||
{
|
||||
$param = [
|
||||
'fileLimit' => true,
|
||||
'tz' => true,
|
||||
];
|
||||
$light = new Light();
|
||||
|
||||
/**
|
||||
* In the getConfiguration() method, the next section:
|
||||
*
|
||||
* $postMaxSize = $this->return_bytes(ini_get('post_max_size'));
|
||||
* $uploadMaxFileSize = $this->return_bytes(ini_get('upload_max_filesize'));
|
||||
* if ($postMaxSize < $uploadMaxFileSize) {
|
||||
* $uploadMaxFileSize = $postMaxSize;
|
||||
* }
|
||||
*
|
||||
* It can only be tested if you change the values of "post_max_size" and "upload_max_filesize"
|
||||
* in php.ini, you can't use the ini_set() function.
|
||||
* The mode change of these directives is "PHP_INI_PERDIR", where is entry can be
|
||||
* set in php.ini, .htaccess, httpd.conf or .user.ini, see here:
|
||||
* https://www.php.net/manual/es/ini.list.php
|
||||
* https://www.php.net/manual/en/configuration.changes.modes.php
|
||||
*/
|
||||
$result = $light->getConfiguration($param);
|
||||
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the value of mobile_offline_tables_download_interval
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_mobile_offline_tables_download_interval_inside_env()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$expected = 30;
|
||||
|
||||
$content = "mobile_offline_tables_download_interval = {$expected};";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$actual = $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the default value of mobile_offline_tables_download_interval.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_default_value_if_mobile_offline_tables_download_interval_inside_env_is_not_an_integer()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$alphanumeric = $faker->regexify('[A-Za-z0-9]{20}');
|
||||
$content = "mobile_offline_tables_download_interval = '{$alphanumeric}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$expected = (string) $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertTrue(ctype_digit($expected));
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,20 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Core;
|
||||
|
||||
use G;
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\Core\System;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SystemTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Define the required variables
|
||||
*/
|
||||
protected function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$config = config('database.connections.testexternal');
|
||||
define('DB_HOST', $config['host']);
|
||||
define('DB_NAME', $config['database']);
|
||||
define('DB_USER', $config['username']);
|
||||
define('DB_PASS', $config['password']);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +25,8 @@ class SystemTest extends TestCase
|
||||
*/
|
||||
public function it_should_init_laravel_configurations()
|
||||
{
|
||||
$this->markTestIncomplete("@todo: Please correct this unit test");
|
||||
|
||||
$object = new System();
|
||||
$object->initLaravel();
|
||||
|
||||
@@ -36,4 +36,112 @@ class SystemTest extends TestCase
|
||||
$this->assertEquals(DB_USER, config('database.connections.workflow.username'));
|
||||
$this->assertEquals(DB_PASS, config('database.connections.workflow.password'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters()
|
||||
{
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters without workspace.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters_without_workspace()
|
||||
{
|
||||
config(["system.workspace" => '']);
|
||||
putenv("REQUEST_URI=/sysworkflow");
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$this->assertArrayHasKey('server_hostname_requests_frontend', $result);
|
||||
$this->assertArrayHasKey('disable_php_upload_execution', $result);
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return system configuration parameters defined inside env file.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_system_configuration_parameters_defined_inside_env_file()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$expected = 30;
|
||||
|
||||
$content = "mobile_offline_tables_download_interval = {$expected};";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
$actual = $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return default system configuration parameters defined inside env file when is not integer.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_default_system_configuration_parameters_defined_inside_env_file_when_is_not_an_integer()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$alphanumeric = $faker->regexify('[A-Za-z0-9]{20}');
|
||||
$content = "mobile_offline_tables_download_interval = '{$alphanumeric}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
$expected = (string) $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertTrue(is_numeric($expected));
|
||||
}
|
||||
|
||||
/**
|
||||
* It should return proxy_pass defined inside env file.
|
||||
* @test
|
||||
* @covers \ProcessMaker\Core\System::getSystemConfiguration()
|
||||
*/
|
||||
public function it_should_return_proxy_pass_defined_inside_env_file()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$content = "proxy_pass = '{$faker->password}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$result = System::getSystemConfiguration();
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertArrayHasKey("proxy_pass", $result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user