2019-09-03 13:35:27 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
|
|
|
|
|
|
|
|
|
use G;
|
|
|
|
|
use ProcessMaker\BusinessModel\WebEntry as BmWebEntry;
|
|
|
|
|
use ProcessMaker\Model\WebEntry;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class WebEntryTest
|
|
|
|
|
*
|
|
|
|
|
* @coversDefaultClass \ProcessMaker\BusinessModel\WebEntry
|
|
|
|
|
*/
|
|
|
|
|
class WebEntryTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Test if exist a Web Entry that uses a Uid like filename
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\BusinessModel\WebEntry::isWebEntry()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_exist_web_entry_that_uses_uid_like_filename() {
|
|
|
|
|
// Initializing variables
|
|
|
|
|
$phpExtension = '.php';
|
|
|
|
|
$postFileExtension = 'Post.php';
|
|
|
|
|
$infoFileExtension = 'Info.php';
|
|
|
|
|
$webEntryFilename = G::generateUniqueID();
|
|
|
|
|
|
|
|
|
|
// Create a Web Entry
|
2022-07-21 00:04:21 -04:00
|
|
|
$webEntry = WebEntry::factory()->create(['WE_DATA' => $webEntryFilename . $phpExtension]);
|
2019-09-03 13:35:27 -04:00
|
|
|
|
|
|
|
|
// Post file is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $postFileExtension);
|
|
|
|
|
$this->assertTrue($isWebEntry);
|
|
|
|
|
|
|
|
|
|
// Information file is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $infoFileExtension);
|
|
|
|
|
$this->assertTrue($isWebEntry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if exist a Web Entry that uses a custom name like filename
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\BusinessModel\WebEntry::isWebEntry()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_exist_web_entry_that_uses_custom_name_like_filename() {
|
|
|
|
|
// Initializing variables
|
|
|
|
|
$phpExtension = '.php';
|
|
|
|
|
$postFileExtension = 'Post.php';
|
|
|
|
|
$infoFileExtension = 'Info.php';
|
|
|
|
|
$webEntryFilename = 'My_Custom_Form';
|
|
|
|
|
|
|
|
|
|
// Create a Web Entry
|
2022-07-21 00:04:21 -04:00
|
|
|
$webEntry = WebEntry::factory()->create(['WE_DATA' => $webEntryFilename . $phpExtension]);
|
2019-09-03 13:35:27 -04:00
|
|
|
|
|
|
|
|
// Post file is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $postFileExtension);
|
|
|
|
|
$this->assertTrue($isWebEntry);
|
|
|
|
|
|
|
|
|
|
// Information file is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $infoFileExtension);
|
|
|
|
|
$this->assertTrue($isWebEntry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if not exist a Web Entry
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\BusinessModel\WebEntry::isWebEntry()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_not_exist_web_entry() {
|
|
|
|
|
// Initializing variables
|
|
|
|
|
$processThatNotExists = G::generateUniqueID();
|
|
|
|
|
$webEntryThatNotExists = G::generateUniqueID() . '.php';
|
|
|
|
|
|
|
|
|
|
// File is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($processThatNotExists, $webEntryThatNotExists);
|
|
|
|
|
$this->assertFalse($isWebEntry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if is sent empty parameters to the method
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
*
|
|
|
|
|
* @covers \ProcessMaker\BusinessModel\WebEntry::isWebEntry()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_false_with_empty_parameters() {
|
|
|
|
|
// Initializing variables
|
|
|
|
|
$emptyProcess = '';
|
|
|
|
|
$emptyFilePath = '';
|
|
|
|
|
|
|
|
|
|
// File is from a valid Web Entry?
|
|
|
|
|
$isWebEntry = BmWebEntry::isWebEntry($emptyProcess, $emptyFilePath);
|
|
|
|
|
$this->assertFalse($isWebEntry);
|
|
|
|
|
}
|
2022-08-11 19:00:12 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test the method verifyHideActiveSessionWarningOption()
|
|
|
|
|
* @test
|
|
|
|
|
* @covers \ProcessMaker\BusinessModel\WebEntry::verifyHideActiveSessionWarningOption()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_verifyHideActiveSessionWarningOption_method()
|
|
|
|
|
{
|
|
|
|
|
// Initializing variables
|
|
|
|
|
$phpExtension = '.php';
|
|
|
|
|
$postFileExtension = 'Post.php';
|
|
|
|
|
$infoFileExtension = 'Info.php';
|
|
|
|
|
$webEntryFilename = 'My_Custom_Form';
|
|
|
|
|
|
|
|
|
|
//assert true result
|
2022-09-14 12:08:21 -04:00
|
|
|
$webEntry = WebEntry::factory()->create([
|
2022-08-11 19:00:12 -04:00
|
|
|
'WE_DATA' => $webEntryFilename . $phpExtension,
|
2022-09-14 12:08:21 -04:00
|
|
|
'WE_HIDE_ACTIVE_SESSION_WARNING' => '0',
|
|
|
|
|
'WE_AUTHENTICATION' => 'LOGIN_REQUIRED'
|
2022-08-11 19:00:12 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$weUid = $webEntry->WE_UID;
|
|
|
|
|
$webEntry = new BmWebEntry();
|
|
|
|
|
$result = $webEntry->verifyHideActiveSessionWarningOption($weUid);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($result, true);
|
|
|
|
|
|
|
|
|
|
//assert false result
|
2022-09-14 12:08:21 -04:00
|
|
|
$webEntry = WebEntry::factory()->create([
|
2022-08-11 19:00:12 -04:00
|
|
|
'WE_DATA' => $webEntryFilename . $phpExtension,
|
2022-09-14 12:08:21 -04:00
|
|
|
'WE_HIDE_ACTIVE_SESSION_WARNING' => '1',
|
|
|
|
|
'WE_AUTHENTICATION' => 'LOGIN_REQUIRED'
|
2022-08-11 19:00:12 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$weUid = $webEntry->WE_UID;
|
|
|
|
|
$webEntry = new BmWebEntry();
|
|
|
|
|
$result = $webEntry->verifyHideActiveSessionWarningOption($weUid);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($result, false);
|
|
|
|
|
}
|
2019-09-03 13:35:27 -04:00
|
|
|
}
|