Skip to content

Commit 2da3b24

Browse files
authored
Add additional metadata tests
1 parent 679e3f8 commit 2da3b24

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

tests/WorkflowDumpCommandTest.php

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testShouldThrowExceptionForUndefinedClass()
3434
public function testWorkflowCommand()
3535
{
3636
$optionalPath = '/my/path';
37-
$disk = 'public';
37+
$disk = 'public';
3838

3939
Storage::fake($disk);
4040

@@ -48,15 +48,54 @@ public function testWorkflowCommand()
4848
Storage::disk($disk)->assertExists($optionalPath . '/straight.png');
4949
}
5050

51+
public function testWorkflowCommandWithMetadata()
52+
{
53+
$disk = 'public';
54+
55+
Storage::fake($disk);
56+
57+
$command = $this->getMock(
58+
disk: $disk,
59+
format: 'svg',
60+
withMetadata: true,
61+
);
62+
63+
$command->handle();
64+
65+
Storage::disk($disk)->assertExists('straight.svg');
66+
$svg_file = Storage::disk($disk)->get('straight.svg');
67+
$this->assertStringContainsString('metadata_place', $svg_file);
68+
$this->assertStringContainsString('metadata_exists', $svg_file);
69+
}
70+
71+
public function testWorkflowCommandWithoutMetadata()
72+
{
73+
$disk = 'public';
74+
75+
Storage::fake($disk);
76+
77+
$command = $this->getMock(
78+
disk: $disk,
79+
format: 'svg',
80+
withMetadata: false,
81+
);
82+
83+
$command->handle();
84+
85+
Storage::disk($disk)->assertExists('straight.svg');
86+
$svg_file = Storage::disk($disk)->get('straight.svg');
87+
$this->assertStringContainsString('metadata_place', $svg_file);
88+
$this->assertStringNotContainsString('metadata_exists', $svg_file);
89+
}
90+
5191
private function getMock(
5292
string $workflow = 'straight',
5393
string $format = 'png',
5494
string $class = 'Tests\Fixtures\TestObject',
5595
string $disk = 'local',
5696
string $path = '/',
5797
bool $withMetadata = false,
58-
): MockInterface
59-
{
98+
): MockInterface {
6099
return Mockery::mock(WorkflowDumpCommand::class)
61100
->makePartial()
62101
->shouldReceive('argument')
@@ -85,15 +124,24 @@ protected function getEnvironmentSetUp($app)
85124
$app['config']['workflow'] = [
86125
'straight' => [
87126
'supports' => ['Tests\Fixtures\TestObject'],
88-
'places' => ['a', 'b', 'c'],
127+
'places' => [
128+
'a',
129+
'b',
130+
'c',
131+
'metadata_place' => [
132+
'metadata' => [
133+
'metadata_exists' => true,
134+
],
135+
],
136+
],
89137
'transitions' => [
90138
't1' => [
91139
'from' => 'a',
92-
'to' => 'b',
140+
'to' => 'b',
93141
],
94142
't2' => [
95143
'from' => 'b',
96-
'to' => 'c',
144+
'to' => 'c',
97145
],
98146
],
99147
],

0 commit comments

Comments
 (0)