forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenConsolidatorTest.php
More file actions
52 lines (39 loc) · 1.91 KB
/
ScreenConsolidatorTest.php
File metadata and controls
52 lines (39 loc) · 1.91 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
<?php
namespace Tests;
use ProcessMaker\Models\User;
use ProcessMaker\Models\Screen;
use ProcessMaker\Jobs\ImportProcess;
use ProcessMaker\ScreenConsolidator;
class ScreenConsolidatorTest extends TestCase
{
public function test()
{
$this->be(factory(User::class)->create());
$content = file_get_contents(
__DIR__ . '/Fixtures/nested_screen_process.json'
);
ImportProcess::dispatchNow($content);
$screen = Screen::where('title', 'parent')->firstOrFail();
$consolidator = new ScreenConsolidator($screen);
$result = $consolidator->call();
$this->assertCount(2, $result['config']);
$this->assertCount(6, $result['config'][0]['items']);
$parent = $result['config'][0]['items'];
$this->assertEquals('FormMultiColumn', $parent[1]['component']);
$multiColumn = $parent[1]['items'];
$this->assertEquals('FormInput', $multiColumn[0][0]['component']);
$this->assertEquals('<p>Child</p>', $multiColumn[1][0]['config']['content']);
$this->assertEquals('FormHtmlViewer', $parent[2]['component']);
$this->assertEquals('<p>Child 2</p>', $parent[2]['config']['content']);
$this->assertEquals('FormMultiColumn', $parent[3]['component']);
$this->assertCount(0, $parent[3]['items'][0]);
$this->assertCount(0, $parent[3]['items'][1]);
$this->assertEquals('FormHtmlViewer', $parent[4]['component']);
$this->assertEquals('<p>Child 3</p>', $parent[4]['config']['content']);
$this->assertEquals('parent watcher test', $result['watchers'][0]['name']);
$this->assertEquals('child watcher', $result['watchers'][1]['name']);
$this->assertEquals(1, $result['computed'][0]['id']);
$this->assertEquals(2, $result['computed'][1]['id']);
$this->assertEquals("* { color: blue }\n* { color: red }", $result['custom_css']);
}
}