1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Cerbero\Workflow\Console\Drawing; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Prophecy\Argument; |
7
|
|
|
use Cerbero\Workflow\Repositories\PipelineRepositoryInterface; |
8
|
|
|
use Cerbero\Workflow\Console\Drawing\Geometry; |
9
|
|
|
|
10
|
|
|
class DrawerSpec extends ObjectBehavior |
11
|
|
|
{ |
12
|
|
|
function let(PipelineRepositoryInterface $pipelines) |
13
|
|
|
{ |
14
|
|
|
$geometry = new Geometry; |
15
|
|
|
|
16
|
|
|
$this->beConstructedWith($pipelines, $geometry); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
function it_is_initializable() |
20
|
|
|
{ |
21
|
|
|
$this->shouldHaveType('Cerbero\Workflow\Console\Drawing\Drawer'); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @testdox It draws a workflow with zero pipes. |
26
|
|
|
* |
27
|
|
|
* @author Andrea Marco Sartori |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
public function it_draws_a_workflow_with_zero_pipes($pipelines) |
31
|
|
|
{ |
32
|
|
|
$pipelines->getPipesByPipeline('RegisterUser')->willReturn([]); |
33
|
|
|
|
34
|
|
|
$drawing = file_get_contents(__DIR__ . '/stubs/zero.stub'); |
35
|
|
|
|
36
|
|
|
$this->draw('RegisterUser')->shouldReturn($drawing); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @testdox It draws a workflow with one pipe. |
41
|
|
|
* |
42
|
|
|
* @author Andrea Marco Sartori |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function it_draws_a_workflow_with_one_pipe($pipelines) |
46
|
|
|
{ |
47
|
|
|
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Notifier']); |
48
|
|
|
|
49
|
|
|
$drawing = file_get_contents(__DIR__ . '/stubs/one.stub'); |
50
|
|
|
|
51
|
|
|
$this->draw('RegisterUser')->shouldReturn($drawing); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @testdox It draws a workflow with two pipe. |
56
|
|
|
* |
57
|
|
|
* @author Andrea Marco Sartori |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function it_draws_a_workflow_with_two_pipe($pipelines) |
61
|
|
|
{ |
62
|
|
|
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Logger', 'App\Workflows\RegisterUser\Notifier']); |
63
|
|
|
|
64
|
|
|
$drawing = file_get_contents(__DIR__ . '/stubs/two.stub'); |
65
|
|
|
|
66
|
|
|
$this->draw('RegisterUser')->shouldReturn($drawing); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @testdox It draws a workflow with many pipes. |
71
|
|
|
* |
72
|
|
|
* @author Andrea Marco Sartori |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
|
|
public function it_draws_a_workflow_with_many_pipes($pipelines) |
76
|
|
|
{ |
77
|
|
|
$pipelines->getPipesByPipeline('LoginUser')->willReturn(['LongName', 'TheLongestNameEver', 'LongerName', 'Name', 'VeryLongName']); |
78
|
|
|
|
79
|
|
|
$drawing = file_get_contents(__DIR__ . '/stubs/many.stub'); |
80
|
|
|
|
81
|
|
|
$this->draw('LoginUser')->shouldReturn($drawing); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|