Skip to content

Commit bfbd67b

Browse files
lam0819github-actions[bot]
authored andcommitted
Fix styling
1 parent 228db0f commit bfbd67b

File tree

6 files changed

+51
-56
lines changed

6 files changed

+51
-56
lines changed

config/workflow-engine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
*/
1515
'storage' => [
1616
'driver' => env('WORKFLOW_STORAGE_DRIVER', 'database'),
17-
17+
1818
'database' => [
1919
'connection' => env('WORKFLOW_DB_CONNECTION', config('database.default')),
2020
'table' => env('WORKFLOW_DB_TABLE', 'workflow_instances'),
2121
],
22-
22+
2323
'file' => [
2424
'path' => env('WORKFLOW_FILE_PATH', storage_path('app/workflows')),
2525
],

src/Core/WorkflowDefinition.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace SolutionForest\WorkflowMastery\Core;
44

5-
use Illuminate\Support\Facades\Log;
6-
75
class WorkflowDefinition
86
{
97
private string $name;
@@ -127,7 +125,7 @@ private function processSteps(array $stepsData): array
127125
foreach ($stepsData as $index => $stepData) {
128126
// Use the 'id' field from step data, or fall back to array index
129127
$stepId = $stepData['id'] ?? $index;
130-
128+
131129
$actionClass = null;
132130
if (isset($stepData['action'])) {
133131
$actionClass = ActionResolver::resolve($stepData['action']);

src/Core/WorkflowEngine.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace SolutionForest\WorkflowMastery\Core;
44

55
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
6-
use Illuminate\Support\Facades\Log;
76
use SolutionForest\WorkflowMastery\Contracts\StorageAdapter;
87
use SolutionForest\WorkflowMastery\Events\WorkflowCancelled;
98
use SolutionForest\WorkflowMastery\Events\WorkflowStarted;

src/Facades/LaravelWorkflowEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Solutionforest\LaravelWorkflowEngine\Facades;
44

5-
use Solutionforest\LaravelWorkflowEngine\Core\WorkflowEngine;
65
use Illuminate\Support\Facades\Facade;
6+
use Solutionforest\LaravelWorkflowEngine\Core\WorkflowEngine;
77

88
/**
99
* @see \Solutionforest\LaravelWorkflowEngine\Core\WorkflowEngine

tests/Integration/WorkflowIntegrationTest.php

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,56 @@ public function it_can_execute_a_complete_workflow(): void
2121
'action' => 'log',
2222
'parameters' => [
2323
'message' => 'Welcome {{name}} to our platform!',
24-
'level' => 'info'
25-
]
24+
'level' => 'info',
25+
],
2626
],
2727
[
28-
'id' => 'setup_profile',
28+
'id' => 'setup_profile',
2929
'name' => 'Setup User Profile',
3030
'action' => 'log',
3131
'parameters' => [
3232
'message' => 'Setting up profile for {{name}} with email {{email}}',
33-
'level' => 'info'
34-
]
33+
'level' => 'info',
34+
],
3535
],
3636
[
3737
'id' => 'send_confirmation',
3838
'name' => 'Send Confirmation',
3939
'action' => 'log',
4040
'parameters' => [
4141
'message' => 'Sending confirmation email to {{email}}',
42-
'level' => 'info'
43-
]
44-
]
42+
'level' => 'info',
43+
],
44+
],
4545
],
4646
'transitions' => [
4747
[
4848
'from' => 'welcome',
49-
'to' => 'setup_profile'
49+
'to' => 'setup_profile',
5050
],
5151
[
5252
'from' => 'setup_profile',
53-
'to' => 'send_confirmation'
54-
]
55-
]
53+
'to' => 'send_confirmation',
54+
],
55+
],
5656
];
5757

5858
$context = [
5959
'name' => 'John Doe',
6060
'email' => 'john@example.com',
61-
'userId' => 123
61+
'userId' => 123,
6262
];
6363

6464
// Start the workflow using helper function
6565
$workflowId = start_workflow('user-onboarding-123', $definition, $context);
66-
66+
6767
// Verify workflow was created and completed
6868
$this->assertNotEmpty($workflowId);
6969
$this->assertEquals('user-onboarding-123', $workflowId);
7070

7171
// Get workflow instance using helper
7272
$instance = get_workflow($workflowId);
73-
73+
7474
// Verify the workflow completed successfully
7575
$this->assertEquals(WorkflowState::COMPLETED, $instance->getState());
7676
$this->assertEquals('User Onboarding Workflow', $instance->getName());
@@ -80,13 +80,13 @@ public function it_can_execute_a_complete_workflow(): void
8080
$this->assertEquals('John Doe', $workflowData['name']);
8181
$this->assertEquals('john@example.com', $workflowData['email']);
8282
$this->assertEquals(123, $workflowData['userId']);
83-
83+
8484
// Verify that all steps completed successfully
8585
$this->assertCount(3, $instance->getCompletedSteps());
8686
$this->assertContains('welcome', $instance->getCompletedSteps());
8787
$this->assertContains('setup_profile', $instance->getCompletedSteps());
8888
$this->assertContains('send_confirmation', $instance->getCompletedSteps());
89-
89+
9090
// Verify no failed steps
9191
$this->assertEmpty($instance->getFailedSteps());
9292

@@ -107,17 +107,17 @@ public function it_can_handle_workflow_cancellation(): void
107107
'id' => 'step1',
108108
'name' => 'First Step',
109109
'action' => 'log',
110-
'parameters' => ['message' => 'Starting process']
111-
]
112-
]
110+
'parameters' => ['message' => 'Starting process'],
111+
],
112+
],
113113
];
114114

115115
// Start workflow
116116
$workflowId = start_workflow('cancellable-workflow', $definition);
117-
117+
118118
// Cancel workflow
119119
cancel_workflow($workflowId, 'User requested cancellation');
120-
120+
121121
// Verify cancellation
122122
$instance = get_workflow($workflowId);
123123
$this->assertEquals(WorkflowState::CANCELLED, $instance->getState());
@@ -129,21 +129,21 @@ public function it_can_list_and_filter_workflows(): void
129129
$definition1 = [
130130
'name' => 'Workflow 1',
131131
'steps' => [
132-
['id' => 'step1', 'action' => 'log', 'parameters' => ['message' => 'Test']]
133-
]
132+
['id' => 'step1', 'action' => 'log', 'parameters' => ['message' => 'Test']],
133+
],
134134
];
135135

136136
$definition2 = [
137137
'name' => 'Workflow 2',
138138
'steps' => [
139-
['id' => 'step1', 'action' => 'log', 'parameters' => ['message' => 'Test']]
140-
]
139+
['id' => 'step1', 'action' => 'log', 'parameters' => ['message' => 'Test']],
140+
],
141141
];
142142

143143
// Start two workflows
144144
$workflow1Id = start_workflow('list-test-1', $definition1);
145145
$workflow2Id = start_workflow('list-test-2', $definition2);
146-
146+
147147
// Cancel one
148148
cancel_workflow($workflow2Id);
149149

@@ -157,11 +157,11 @@ public function it_can_list_and_filter_workflows(): void
157157

158158
$this->assertGreaterThanOrEqual(1, count($completedWorkflows));
159159
$this->assertGreaterThanOrEqual(1, count($cancelledWorkflows));
160-
160+
161161
// Verify specific workflows exist in filtered results
162162
$completedIds = array_column($completedWorkflows, 'workflow_id');
163163
$cancelledIds = array_column($cancelledWorkflows, 'workflow_id');
164-
164+
165165
$this->assertContains($workflow1Id, $completedIds);
166166
$this->assertContains($workflow2Id, $cancelledIds);
167167
}
@@ -179,64 +179,64 @@ public function it_can_execute_conditional_workflows(): void
179179
'action' => 'log',
180180
'parameters' => [
181181
'message' => 'Validating request from {{user}}',
182-
'level' => 'info'
183-
]
182+
'level' => 'info',
183+
],
184184
],
185185
[
186186
'id' => 'auto_approve',
187187
'name' => 'Auto Approve',
188188
'action' => 'log',
189189
'parameters' => [
190190
'message' => 'Auto-approving request for premium user {{user}}',
191-
'level' => 'info'
192-
]
191+
'level' => 'info',
192+
],
193193
],
194194
[
195195
'id' => 'manual_review',
196196
'name' => 'Manual Review Required',
197197
'action' => 'log',
198198
'parameters' => [
199199
'message' => 'Manual review required for user {{user}}',
200-
'level' => 'warning'
201-
]
200+
'level' => 'warning',
201+
],
202202
],
203203
[
204204
'id' => 'notify_completion',
205205
'name' => 'Notify Completion',
206206
'action' => 'log',
207207
'parameters' => [
208208
'message' => 'Process completed for {{user}}',
209-
'level' => 'info'
210-
]
211-
]
209+
'level' => 'info',
210+
],
211+
],
212212
],
213213
'transitions' => [
214214
[
215215
'from' => 'validate_request',
216216
'to' => 'auto_approve',
217-
'condition' => 'tier === premium'
217+
'condition' => 'tier === premium',
218218
],
219219
[
220220
'from' => 'validate_request',
221221
'to' => 'manual_review',
222-
'condition' => 'tier !== premium'
222+
'condition' => 'tier !== premium',
223223
],
224224
[
225225
'from' => 'auto_approve',
226-
'to' => 'notify_completion'
226+
'to' => 'notify_completion',
227227
],
228228
[
229229
'from' => 'manual_review',
230-
'to' => 'notify_completion'
231-
]
232-
]
230+
'to' => 'notify_completion',
231+
],
232+
],
233233
];
234234

235235
// Test premium user path (should auto-approve)
236236
$premiumContext = [
237237
'user' => 'Alice Premium',
238238
'tier' => 'premium',
239-
'amount' => 1000
239+
'amount' => 1000,
240240
];
241241

242242
$premiumWorkflowId = start_workflow('premium-approval-123', $definition, $premiumContext);
@@ -253,7 +253,7 @@ public function it_can_execute_conditional_workflows(): void
253253
$regularContext = [
254254
'user' => 'Bob Regular',
255255
'tier' => 'basic',
256-
'amount' => 5000
256+
'amount' => 5000,
257257
];
258258

259259
$regularWorkflowId = start_workflow('regular-approval-456', $definition, $regularContext);

tests/Unit/WorkflowEngineTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use SolutionForest\WorkflowMastery\Core\WorkflowEngine;
88
use SolutionForest\WorkflowMastery\Core\WorkflowInstance;
99
use SolutionForest\WorkflowMastery\Core\WorkflowState;
10-
use SolutionForest\WorkflowMastery\Events\WorkflowCancelled;
11-
use SolutionForest\WorkflowMastery\Events\WorkflowStarted;
1210
use SolutionForest\WorkflowMastery\Tests\TestCase;
1311

1412
class WorkflowEngineTest extends TestCase
@@ -69,7 +67,7 @@ public function it_can_start_a_workflow_with_context(): void
6967

7068
$instance = $this->engine->getWorkflow($workflowId);
7169
$workflowData = $instance->getContext()->getData();
72-
70+
7371
// Should contain original context plus any data added by actions
7472
$this->assertEquals('John', $workflowData['name']);
7573
$this->assertArrayHasKey('logged_message', $workflowData); // Added by LogAction

0 commit comments

Comments
 (0)