PMCORE-2835

This commit is contained in:
Paula Quispe
2021-03-30 10:03:46 -04:00
parent d66c567259
commit 7d27947b39
20 changed files with 1060 additions and 204 deletions

View File

@@ -5,6 +5,7 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
use Tests\TestCase;
@@ -24,7 +25,7 @@ class ApplicationTest extends TestCase
public function setUp()
{
parent::setUp();
Application::query()->delete();
Application::truncate();
}
/**
@@ -43,6 +44,22 @@ class ApplicationTest extends TestCase
$this->assertInstanceOf(User::class, $application->currentUser);
}
/**
* Test belongs to APP_INIT_USER
*
* @covers \ProcessMaker\Model\Application::creatorUser()
* @test
*/
public function it_has_a_creator_user()
{
$application = factory(Application::class)->create([
'APP_INIT_USER' => function () {
return factory(User::class)->create()->USR_UID;
}
]);
$this->assertInstanceOf(User::class, $application->creatorUser);
}
/**
* Test belongs to APP_INIT_USER
*
@@ -59,6 +76,116 @@ class ApplicationTest extends TestCase
$this->assertInstanceOf(User::class, $application->creatoruser);
}
/**
* This test scopeUserId
*
* @covers \ProcessMaker\Model\Application::scopeUserId()
* @covers \ProcessMaker\Model\Application::scopeJoinDelegation()
* @test
*/
public function it_return_scope_user_id()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$usrId = User::getId($table->APP_INIT_USER);
$this->assertCount(1, $table->joinDelegation()->userId($usrId)->get());
}
/**
* This test scopeCreator
*
* @covers \ProcessMaker\Model\Application::scopeCreator()
* @test
*/
public function it_return_scope_creator()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->creator($table->APP_INIT_USER)->get());
}
/**
* This test scopeSpecificCasesByUid
*
* @covers \ProcessMaker\Model\Application::scopeSpecificCasesByUid()
* @test
*/
public function it_return_scope_case_uids()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->specificCasesByUid([$table->APP_UID])->get());
}
/**
* This test scopeCase
*
* @covers \ProcessMaker\Model\Application::scopeCase()
* @test
*/
public function it_return_scope_case()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->case($table->APP_NUMBER)->get());
}
/**
* This test scopePositiveCases
*
* @covers \ProcessMaker\Model\Application::scopePositiveCases()
* @test
*/
public function it_return_scope_positive_cases()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->positiveCases()->get());
}
/**
* This test scopeSpecificCases
*
* @covers \ProcessMaker\Model\Application::scopeSpecificCases()
* @test
*/
public function it_return_scope_specific_case_numbers()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->specificCases([$table->APP_NUMBER])->get());
}
/**
* This test scopeRangeOfCases
*
* @covers \ProcessMaker\Model\Application::scopeRangeOfCases()
* @test
*/
public function it_return_scope_range_of_cases()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get());
}
/**
* This test scopeCasesFrom
*
* @covers \ProcessMaker\Model\Application::scopeCasesFrom()
* @test
*/
public function it_return_scope_case_from()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->casesFrom($table->APP_NUMBER)->get());
}
/**
* This test scopeCasesTo
*
* @covers \ProcessMaker\Model\Application::scopeCasesTo()
* @test
*/
public function it_return_scope_case_to()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->casesTo($table->APP_NUMBER)->get());
}
/**
* This checks if return the columns used
*
@@ -71,6 +198,96 @@ class ApplicationTest extends TestCase
$this->assertCount(1, $table->statusId($table->APP_STATUS_ID)->get());
}
/**
* This test scopeStatusIds
*
* @covers \ProcessMaker\Model\Application::scopeStatusIds()
* @test
*/
public function it_return_cases_by_status_ids()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->statusIds([$table->APP_STATUS_ID])->get());
}
/**
* This test scopeStartDateFrom
*
* @covers \ProcessMaker\Model\Application::scopeStartDateFrom()
* @test
*/
public function it_return_start_date_from()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->startDateFrom($table->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeStartDateTo
*
* @covers \ProcessMaker\Model\Application::scopeStartDateTo()
* @test
*/
public function it_return_start_date_to()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->startDateTo($table->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeFinishCaseFrom
*
* @covers \ProcessMaker\Model\Application::scopeFinishCaseFrom()
* @test
*/
public function it_return_finish_date_from()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->finishCaseFrom($table->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeFinishCaseTo
*
* @covers \ProcessMaker\Model\Application::scopeFinishCaseTo()
* @test
*/
public function it_return_finish_date_to()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->finishCaseTo($table->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeTask
*
* @covers \ProcessMaker\Model\Application::scopeTask()
* @covers \ProcessMaker\Model\Application::scopeJoinDelegation()
* @test
*/
public function it_return_scope_task()
{
$table = factory(Application::class)->create();
$tableJoin = factory(Delegation::class)->states('foreign_keys')->create([
'APP_UID' => $table->APP_UID,
'APP_NUMBER' => $table->APP_NUMBER,
]);
$this->assertCount(1, $table->joinDelegation()->task($tableJoin->TAS_ID)->get());
}
/**
* This test scopeJoinProcess
*
* @covers \ProcessMaker\Model\Application::scopeJoinProcess()
* @test
*/
public function it_return_scope_join_process()
{
$table = factory(Application::class)->create();
$this->assertCount(1, $table->joinProcess()->get());
}
/**
* This checks if return the columns used
*
@@ -156,7 +373,7 @@ class ApplicationTest extends TestCase
* @covers \ProcessMaker\Model\Application::getCountByProUid()
* @covers \ProcessMaker\Model\Application::scopeProUid()
* @covers \ProcessMaker\Model\Application::scopeStatusId()
* @covers \ProcessMaker\Model\Application::scopePositivesCases()
* @covers \ProcessMaker\Model\Application::scopePositiveCases()
* @test
*/
public function it_count_cases_by_process()