PMC-1153
This commit is contained in:
33
database/factories/WebEntryFactory.php
Normal file
33
database/factories/WebEntryFactory.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Model factory for web entries
|
||||||
|
*/
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\WebEntry::class, function(Faker $faker) {
|
||||||
|
return [
|
||||||
|
'WE_UID' => G::generateUniqueID(),
|
||||||
|
'PRO_UID' => G::generateUniqueID(),
|
||||||
|
'TAS_UID' => G::generateUniqueID(),
|
||||||
|
'DYN_UID' => G::generateUniqueID(),
|
||||||
|
'USR_UID' => G::generateUniqueID(),
|
||||||
|
'WE_METHOD' => $faker->randomElement(['WS', 'HTML']),
|
||||||
|
'WE_INPUT_DOCUMENT_ACCESS' => $faker->randomElement([0, 1]),
|
||||||
|
'WE_DATA' => G::generateUniqueID() . '.php',
|
||||||
|
'WE_CREATE_USR_UID' => G::generateUniqueID(),
|
||||||
|
'WE_UPDATE_USR_UID' => G::generateUniqueID(),
|
||||||
|
'WE_CREATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'),
|
||||||
|
'WE_UPDATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'),
|
||||||
|
'WE_TYPE' => $faker->randomElement(['SINGLE', 'MULTIPLE']),
|
||||||
|
'WE_CUSTOM_TITLE' => $faker->words(5, true),
|
||||||
|
'WE_AUTHENTICATION' => $faker->randomElement(['LOGIN_REQUIRED', 'ANONYMOUS']),
|
||||||
|
'WE_HIDE_INFORMATION_BAR' => $faker->randomElement(['0', '1']),
|
||||||
|
'WE_CALLBACK' => $faker->randomElement(['PROCESSMAKER', 'CUSTOM', 'CUSTOM_CLEAR']),
|
||||||
|
'WE_CALLBACK_URL' => $faker->url,
|
||||||
|
'WE_LINK_GENERATION' => $faker->randomElement(['DEFAULT', 'ADVANCED']),
|
||||||
|
'WE_LINK_SKIN' => 'classic',
|
||||||
|
'WE_LINK_LANGUAGE' => 'en',
|
||||||
|
'WE_LINK_DOMAIN' => $faker->domainName,
|
||||||
|
'WE_SHOW_IN_NEW_CASE' => $faker->randomElement(['0', '1'])
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?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
|
||||||
|
$webEntry = factory(WebEntry::class)->create(['WE_DATA' => $webEntryFilename . $phpExtension]);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
$webEntry = factory(WebEntry::class)->create(['WE_DATA' => $webEntryFilename . $phpExtension]);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
workflow/engine/src/ProcessMaker/Model/WebEntry.php
Normal file
15
workflow/engine/src/ProcessMaker/Model/WebEntry.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class WebEntry extends Model
|
||||||
|
{
|
||||||
|
// Set our table name
|
||||||
|
protected $table = 'WEB_ENTRY';
|
||||||
|
protected $primaryKey = 'WE_UID';
|
||||||
|
|
||||||
|
// We do not have create/update timestamps for this table
|
||||||
|
public $timestamps = false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user