PMCORE-3092

This commit is contained in:
Paula Quispe
2021-07-26 13:13:26 -04:00
parent a0b9605d92
commit 6d500d78e2
19 changed files with 377 additions and 130 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppThread;
use Tests\TestCase;
/**
* Class AppThreadTest
*
* @coversDefaultClass \ProcessMaker\Model\AppThread
*/
class AppThreadTest extends TestCase
{
use DatabaseTransactions;
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
}
/**
* This test scopeAppUid
*
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
* @test
*/
public function it_return_scope_app_uid()
{
$table = factory(AppThread::class)->create();
$this->assertCount(1, $table->appUid($table->APP_UID)->get());
}
/**
* This test scopeIndex
*
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
* @test
*/
public function it_return_scope_index()
{
$table = factory(AppThread::class)->create();
$this->assertCount(1, $table->index($table->DEL_INDEX)->get());
}
/**
* This test getThread
*
* @covers \ProcessMaker\Model\AppThread::getThread()
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
* @test
*/
public function it_return_thread()
{
$table = factory(AppThread::class)->create();
$result = AppThread::getThread($table->APP_UID, $table->DEL_INDEX);
$this->assertNotEmpty($result);
}
}

View File

@@ -87,6 +87,11 @@ class ApplicationTest extends TestCase
{
$table = factory(Application::class)->states('foreign_keys')->create();
$usrId = User::getId($table->APP_INIT_USER);
factory(Delegation::class)->states('foreign_keys')->create([
'APP_UID' => $table->APP_UID,
'APP_NUMBER' => $table->APP_NUMBER,
'USR_ID' => $usrId,
]);
$this->assertCount(1, $table->joinDelegation()->userId($usrId)->get());
}
@@ -162,6 +167,20 @@ class ApplicationTest extends TestCase
$this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get());
}
/**
* This test scopeCasesOrRangeOfCases
*
* @covers \ProcessMaker\Model\Application::scopeCasesOrRangeOfCases()
* @test
*/
public function it_return_scope_cases_or_range_of_cases()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
/**
* This test scopeCasesFrom
*

View File

@@ -139,6 +139,29 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->threadOpen()->get());
}
/**
* This test scopeThreadPause
*
* @covers \ProcessMaker\Model\Delegation::scopeThreadPause()
* @test
*/
public function it_return_scope_thread_pause()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(0, $table->threadPause()->get());
}
/**
* This test scopeOpenAndPause
*
* @covers \ProcessMaker\Model\Delegation::scopeOpenAndPause()
* @test
*/
public function it_return_scope_thread_open_and_pause()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->openAndPause()->get());
}
/**
* This test scopeCaseStarted
*
@@ -661,8 +684,11 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_process_in_list()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
$process = factory(Process::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinProcess()->processInList([$table->PRO_ID])->get());
}
/**
@@ -677,6 +703,21 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->participated($table->USR_ID)->get());
}
/**
* This test scopeCategoryId
*
* @covers \ProcessMaker\Model\Delegation::scopeCategoryId()
* @test
*/
public function it_return_scope_category()
{
$process = factory(Process::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinProcess()->categoryId($process->CATEGORY_ID)->get());
}
/**
* This test scopeJoinCategoryProcess
*