|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use Illuminate\Support\Arr; |
3 | 4 | use Soap\WorkflowStorage\Models\Workflow;
|
| 5 | +use Soap\WorkflowStorage\Repositories\WorkflowRepository; |
4 | 6 |
|
5 | 7 | beforeEach(function () {
|
6 | 8 |
|
7 | 9 | $workflow = Workflow::create([
|
8 |
| - 'name' => 'Test Workflow', |
| 10 | + 'name' => 'test_workflow', |
9 | 11 | 'type' => 'workflow',
|
10 | 12 | 'description' => 'Test Workflow Description',
|
11 |
| - 'supports' => [], |
| 13 | + 'supports' => ['App\Models\Article'], |
12 | 14 | 'metadata' => [],
|
13 | 15 | ]);
|
14 | 16 |
|
|
43 | 45 | ]);
|
44 | 46 | });
|
45 | 47 |
|
46 |
| -test('data can be retrieved from the database', function () { |
| 48 | +test('workflow data can be retrieved via models from the database', function () { |
47 | 49 | $workflow = Workflow::first();
|
48 | 50 | $states = $workflow->states;
|
49 | 51 | $transitions = $workflow->transitions;
|
50 | 52 |
|
51 |
| - expect($workflow->name)->toBe('Test Workflow'); |
| 53 | + expect($workflow->name)->toBe('test_workflow'); |
52 | 54 | expect($workflow->type->value)->toBe('workflow');
|
53 | 55 | expect($workflow->description)->toBe('Test Workflow Description');
|
54 |
| - expect($workflow->supports)->toBe([]); |
| 56 | + expect($workflow->supports)->toBe(['App\Models\Article']); |
55 | 57 | expect($workflow->metadata)->toBe([]);
|
56 | 58 |
|
57 | 59 | expect($states->count())->toBe(4);
|
58 | 60 | expect($transitions->count())->toBe(1);
|
59 | 61 | });
|
| 62 | + |
| 63 | +test('workflow configuration can be retrievd via the repository', function () { |
| 64 | + $repo = app()->make(WorkflowRepository::class); |
| 65 | + $config = $repo->find(1); |
| 66 | + ray($config); |
| 67 | + expect(count($config))->toBe(1); |
| 68 | + expect(count(Arr::get($config, 'test_workflow.places')))->toBe(4); |
| 69 | + expect(count(Arr::get($config, 'test_workflow.transitions')))->toBe(1); |
| 70 | +}); |
0 commit comments