Skip to content

Commit 679e3f8

Browse files
authored
Update WorkflowDumpCommandTest for withMetadata
1 parent 61cb436 commit 679e3f8

File tree

1 file changed

+28
-45
lines changed

1 file changed

+28
-45
lines changed

tests/WorkflowDumpCommandTest.php

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,30 @@
44

55
use Mockery;
66
use Illuminate\Support\Facades\Storage;
7+
use Mockery\MockInterface;
78
use ZeroDaHero\LaravelWorkflow\Commands\WorkflowDumpCommand;
89

910
class WorkflowDumpCommandTest extends BaseWorkflowTestCase
1011
{
1112
public function testShouldThrowExceptionForUndefinedWorkflow()
1213
{
13-
$command = Mockery::mock(WorkflowDumpCommand::class)
14-
->makePartial()
15-
->shouldReceive('argument')
16-
->with('workflow')
17-
->andReturn('fake')
18-
->shouldReceive('option')
19-
->with('format')
20-
->andReturn('png')
21-
->shouldReceive('option')
22-
->with('class')
23-
->andReturn('Tests\Fixtures\TestObject')
24-
->shouldReceive('option')
25-
->with('disk')
26-
->andReturn('local')
27-
->shouldReceive('option')
28-
->with('path')
29-
->andReturn('/')
30-
->getMock();
14+
$command = $this->getMock(workflow: 'fake');
3115

3216
$this->expectException(\Exception::class);
3317
$this->expectExceptionMessage('Workflow fake is not configured.');
18+
3419
$command->handle();
3520
}
3621

3722
public function testShouldThrowExceptionForUndefinedClass()
3823
{
39-
$command = Mockery::mock(WorkflowDumpCommand::class)
40-
->makePartial()
41-
->shouldReceive('argument')
42-
->with('workflow')
43-
->andReturn('straight')
44-
->shouldReceive('option')
45-
->with('format')
46-
->andReturn('png')
47-
->shouldReceive('option')
48-
->with('class')
49-
->andReturn('Tests\Fixtures\FakeObject')
50-
->shouldReceive('option')
51-
->with('disk')
52-
->andReturn('local')
53-
->shouldReceive('option')
54-
->with('path')
55-
->andReturn('/')
56-
->getMock();
24+
$command = $this->getMock(class: 'Tests\Fixtures\FakeObject');
5725

5826
$this->expectException(\Exception::class);
5927
$this->expectExceptionMessage('Workflow straight has no support for' .
6028
' class Tests\Fixtures\FakeObject. Please specify a valid support' .
6129
' class with the --class option.');
30+
6231
$command->handle();
6332
}
6433

@@ -73,28 +42,42 @@ public function testWorkflowCommand()
7342
Storage::disk($disk)->delete($optionalPath . '/straight.png');
7443
}
7544

76-
$command = Mockery::mock(WorkflowDumpCommand::class)
45+
$command = $this->getMock(disk: $disk, path: $optionalPath);
46+
$command->handle();
47+
48+
Storage::disk($disk)->assertExists($optionalPath . '/straight.png');
49+
}
50+
51+
private function getMock(
52+
string $workflow = 'straight',
53+
string $format = 'png',
54+
string $class = 'Tests\Fixtures\TestObject',
55+
string $disk = 'local',
56+
string $path = '/',
57+
bool $withMetadata = false,
58+
): MockInterface
59+
{
60+
return Mockery::mock(WorkflowDumpCommand::class)
7761
->makePartial()
7862
->shouldReceive('argument')
7963
->with('workflow')
80-
->andReturn('straight')
64+
->andReturn($workflow)
8165
->shouldReceive('option')
8266
->with('format')
83-
->andReturn('png')
67+
->andReturn($format)
8468
->shouldReceive('option')
8569
->with('class')
86-
->andReturn('Tests\Fixtures\TestObject')
70+
->andReturn($class)
8771
->shouldReceive('option')
8872
->with('disk')
8973
->andReturn($disk)
9074
->shouldReceive('option')
9175
->with('path')
92-
->andReturn($optionalPath)
76+
->andReturn($path)
77+
->shouldReceive('option')
78+
->with('with-metadata')
79+
->andReturn($withMetadata)
9380
->getMock();
94-
95-
$command->handle();
96-
97-
Storage::disk($disk)->assertExists($optionalPath . '/straight.png');
9881
}
9982

10083
protected function getEnvironmentSetUp($app)

0 commit comments

Comments
 (0)