Merged in feature/PMCORE-2539 (pull request #7609)

PMCORE-2539

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2020-12-14 13:00:10 +00:00
3 changed files with 121 additions and 0 deletions

View File

@@ -341,4 +341,43 @@ class ProcessTest extends TestCase
$total = Process::getCounter($process->PRO_CREATE_USER);
$this->assertEquals(1, $total);
}
/**
* It test get processes for the new home view
*
* @covers \ProcessMaker\Model\Process::getProcessesForHome()
* @test
*/
public function it_should_test_get_processes_for_home()
{
// Create a process category
$processCategory = factory(ProcessCategory::class)->create();
// Create five processes (4 active, 1 inactive)
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 1',
'PRO_CATEGORY' => $processCategory->CATEGORY_UID
]);
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 2',
'PRO_CATEGORY' => $processCategory->CATEGORY_UID
]);
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 3',
]);
factory(Process::class)->create([
'PRO_TITLE' => 'Another Process',
]);
factory(Process::class)->create([
'PRO_TITLE' => 'Inactive Process',
'PRO_STATUS' => 'INACTIVE'
]);
// Assertions
$this->assertCount(4, Process::getProcessesForHome());
$this->assertCount(3, Process::getProcessesForHome('My Process'));
$this->assertCount(2, Process::getProcessesForHome(null, $processCategory->CATEGORY_UID));
$this->assertCount(4, Process::getProcessesForHome(null, null, null, 2));
$this->assertCount(1, Process::getProcessesForHome(null, null, 2, 1));
}
}