-
Notifications
You must be signed in to change notification settings - Fork 244
Expand file tree
/
Copy pathConditionalStartEventTest.php
More file actions
57 lines (46 loc) · 1.76 KB
/
Copy pathConditionalStartEventTest.php
File metadata and controls
57 lines (46 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Tests\Feature\Api;
use Illuminate\Support\Facades\Bus;
use ProcessMaker\Jobs\ImportProcess;
use ProcessMaker\Jobs\RefreshArtisanCaches;
use ProcessMaker\Jobs\StartEventConditional;
use ProcessMaker\Managers\TaskSchedulerManager;
use ProcessMaker\Models\Process;
use Tests\TestCase;
class ConditionalStartEventTest extends TestCase
{
public function testConditionalEventMustTriggeredWhenActive()
{
Bus::fake([
StartEventConditional::class,
RefreshArtisanCaches::class,
]);
//Create a conditional process with ACTIVE status by default
ImportProcess::dispatchSync(
file_get_contents(__DIR__ . '/../../Fixtures/conditional_event_process.json')
);
$manager = new TaskSchedulerManager();
$manager->evaluateConditionals();
//Evaluates that StartEventConditional is triggering
Bus::assertDispatched(StartEventConditional::class);
}
public function testConditionalEventMustNotTriggeredWhenInactive()
{
Bus::fake([
StartEventConditional::class,
RefreshArtisanCaches::class,
]);
//Create a conditional process with ACTIVE status by default
ImportProcess::dispatchSync(
file_get_contents(__DIR__ . '/../../Fixtures/conditional_event_process.json')
);
//Get created process and set status to INACTIVE
$process = Process::orderBy('id', 'desc')->first();
$process->status = 'INACTIVE';
$process->save();
$manager = new TaskSchedulerManager();
$manager->evaluateConditionals();
//Evaluates that StartEventConditional is NOT triggering because process is INACTIVE
Bus::assertNotDispatched(StartEventConditional::class);
}
}