Files
luos/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupwfTest.php

92 lines
2.1 KiB
PHP
Raw Normal View History

2021-03-17 12:25:11 -04:00
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
2021-12-14 17:37:04 -04:00
use ProcessMaker\Model\GroupUser;
2021-03-17 12:25:11 -04:00
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
2021-12-14 17:37:04 -04:00
* Class GroupwfTest
2021-03-17 12:25:11 -04:00
*
* @coversDefaultClass \ProcessMaker\Model\Groupwf
*/
class GroupwfTest extends TestCase
{
/**
* This method is called before the first test of this test class is run.
* @return void
*/
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::truncateNonInitialModels();
}
2021-12-14 17:37:04 -04:00
/**
* Method set up.
*/
2022-06-09 11:43:56 -04:00
public function setUp(): void
2021-12-14 17:37:04 -04:00
{
parent::setUp();
}
/**
* Test belongs to GRP_ID
*
* @covers \ProcessMaker\Model\Groupwf::groupUsers()
* @test
*/
public function it_belong_group()
{
$table = Groupwf::factory()->create([
2021-12-14 17:37:04 -04:00
'GRP_ID' => function () {
return GroupUser::factory()->create()->GRP_ID;
2021-12-14 17:37:04 -04:00
}
]);
$this->assertInstanceOf(GroupUser::class, $table->groupUsers);
}
/**
* This test scopeActive
*
* @covers \ProcessMaker\Model\Groupwf::scopeActive()
* @test
*/
public function it_return_scope_active()
{
$table = Groupwf::factory()->create();
2021-12-14 17:37:04 -04:00
$this->assertNotEmpty($table->active()->get());
}
2021-03-17 12:25:11 -04:00
/**
* It tests the verifyGroupExists() method
*
* @test
*/
public function it_should_test_the_verify_group_exists_method()
{
$groupWf = Groupwf::factory()->create();
2021-03-17 12:25:11 -04:00
$res = Groupwf::verifyGroupExists($groupWf['GRP_UID']);
$this->assertTrue($res);
$res = Groupwf::verifyGroupExists('12345');
$this->assertFalse($res);
}
/**
* It tests the getGroupId() method
*
* @test
*/
public function it_should_test_the_get_group_id_method()
{
$groupWf = Groupwf::factory()->create();
2021-03-17 12:25:11 -04:00
$res = Groupwf::getGroupId($groupWf['GRP_UID']);
$this->assertNotEmpty($res);
$this->assertEquals($res['GRP_ID'], $groupWf['GRP_ID']);
}
}