Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"illuminate/database": "^10.0||^11.0||^12.0||^13.0",
"illuminate/events": "^10.0||^11.0||^12.0||^13.0",
"illuminate/support": "^10.0||^11.0||^12.0||^13.0",
"solution-forest/workflow-engine-core": "^1.0"
"solution-forest/workflow-engine-core": "^2.0"
},
"conflict": {
"laravel/framework": "<11.0.0"
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/AdvancedFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

test('email action configuration matches documentation examples', function () {
$workflow = WorkflowBuilder::create('email-test')
->email(
->fakeEmail(
'welcome-email',
'{{ user.email }}',
'Welcome to {{ app.name }}!',
Expand Down Expand Up @@ -101,7 +101,7 @@
->version('1.5')
->startWith(CreateUserProfileAction::class, ['profile_type' => 'basic'])
->then(SendWelcomeEmailAction::class)
->email('tips-email', '{{ user.email }}', 'Getting Started Tips')
->fakeEmail('tips-email', '{{ user.email }}', 'Getting Started Tips')
->delay(minutes: 5)
->when('user.premium = true', function ($builder) {
$builder->then(VerifyIdentityAction::class);
Expand All @@ -116,7 +116,7 @@
$stepClasses = array_map(fn ($step) => $step->getActionClass(), $workflow->getSteps());
expect($stepClasses)->toContain(CreateUserProfileAction::class);
expect($stepClasses)->toContain(SendWelcomeEmailAction::class);
expect($stepClasses)->toContain('SolutionForest\\WorkflowEngine\\Actions\\EmailAction');
expect($stepClasses)->toContain('SolutionForest\\WorkflowEngine\\Actions\\FakeEmailAction');
expect($stepClasses)->toContain('SolutionForest\\WorkflowEngine\\Actions\\DelayAction');
expect($stepClasses)->toContain(VerifyIdentityAction::class);
expect($stepClasses)->toContain('SolutionForest\\WorkflowEngine\\Actions\\HttpAction');
Expand Down Expand Up @@ -149,7 +149,7 @@
test('complex workflow execution with all features', function () {
$workflow = WorkflowBuilder::create('integration-test')
->startWith(CreateUserProfileAction::class, ['profile_type' => 'premium'])
->email('welcome-email', '{{ user.email }}', 'Welcome Premium User!')
->fakeEmail('welcome-email', '{{ user.email }}', 'Welcome Premium User!')
->delay(seconds: 1) // Short delay for testing
->when('user.age >= 21', function ($builder) {
$builder->addStep('age_verification', VerifyIdentityAction::class, [], '30s', 2);
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/DocumentationExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
test('getting started - basic workflow creation works', function () {
$registrationWorkflow = WorkflowBuilder::create('user-registration')
->addStep('create-profile', CreateUserProfileAction::class)
->email('welcome-email', '{{ user.email }}', 'Welcome!')
->fakeEmail('welcome-email', '{{ user.email }}', 'Welcome!')
->delay(hours: 24)
->email('tips-email', '{{ user.email }}', 'Getting Started Tips')
->fakeEmail('tips-email', '{{ user.email }}', 'Getting Started Tips')
->build();

expect($registrationWorkflow)->not->toBeNull();
Expand Down Expand Up @@ -129,14 +129,14 @@

test('api reference - email method works', function () {
$workflow = WorkflowBuilder::create('email-workflow')
->email('welcome-email', '{{ user.email }}', 'Welcome {{ user.name }}!', ['welcome_bonus' => 100])
->fakeEmail('welcome-email', '{{ user.email }}', 'Welcome {{ user.name }}!', ['welcome_bonus' => 100])
->build();

expect($workflow->getSteps())->toHaveCount(1);

$steps = $workflow->getSteps();
$step = $steps['email_1'];
expect($step->getActionClass())->toBe('SolutionForest\\WorkflowEngine\\Actions\\EmailAction');
expect($step->getActionClass())->toBe('SolutionForest\\WorkflowEngine\\Actions\\FakeEmailAction');
expect($step->getConfig()['template'])->toBe('welcome-email');
expect($step->getConfig()['to'])->toBe('{{ user.email }}');
expect($step->getConfig()['subject'])->toBe('Welcome {{ user.name }}!');
Expand Down Expand Up @@ -235,7 +235,7 @@
->description('A complex workflow showcasing all features')
->version('2.0')
->startWith(CreateUserProfileAction::class, ['profile_type' => 'premium'])
->email('welcome-email', '{{ user.email }}', 'Welcome to Premium!')
->fakeEmail('welcome-email', '{{ user.email }}', 'Welcome to Premium!')
->when('user.age >= 21', function ($builder) {
$builder->addStep('age-verification', VerifyIdentityAction::class, [], '60s', 2);
})
Expand All @@ -258,7 +258,7 @@
->description('A complex workflow showcasing all features')
->version('2.0')
->startWith(CreateUserProfileAction::class, ['profile_type' => 'premium'])
->email('welcome-email', '{{ user.email }}', 'Welcome to Premium!')
->fakeEmail('welcome-email', '{{ user.email }}', 'Welcome to Premium!')
->when('user.age >= 21', function ($builder) {
$builder->addStep('age-verification', VerifyIdentityAction::class, [], '60s', 2);
})
Expand Down
12 changes: 7 additions & 5 deletions tests/Unit/PHP83FeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
->version('2.0')
->startWith(LogAction::class, ['message' => 'Starting workflow'])
->then(DelayAction::class, ['seconds' => 1])
->email(
->fakeEmail(
template: 'test',
to: '{{ user.email }}',
subject: 'Test Email'
Expand Down Expand Up @@ -66,7 +66,9 @@

// Test invalid transitions
expect(WorkflowState::COMPLETED->canTransitionTo(WorkflowState::RUNNING))->toBeFalse();
expect(WorkflowState::FAILED->canTransitionTo(WorkflowState::RUNNING))->toBeFalse();
// Core 2.0 allows a failed workflow to be retried, so this is a valid
// transition now; completed and cancelled remain terminal.
expect(WorkflowState::FAILED->canTransitionTo(WorkflowState::RUNNING))->toBeTrue();
expect(WorkflowState::CANCELLED->canTransitionTo(WorkflowState::RUNNING))->toBeFalse();
});

Expand All @@ -91,7 +93,7 @@

it('can create workflow with common patterns using helper methods', function () {
$workflow = WorkflowBuilder::create('helper-test')
->email(
->fakeEmail(
template: 'welcome',
to: 'user@example.com',
subject: 'Welcome!'
Expand All @@ -109,7 +111,7 @@
expect($steps)->toHaveCount(4);

// Check email step
expect($steps[0]->getActionClass())->toBe('SolutionForest\\WorkflowEngine\\Actions\\EmailAction');
expect($steps[0]->getActionClass())->toBe('SolutionForest\\WorkflowEngine\\Actions\\FakeEmailAction');
expect($steps[0]->getConfig()['template'])->toBe('welcome');

// Check delay step
Expand Down Expand Up @@ -140,7 +142,7 @@
$workflow = WorkflowBuilder::create(name: 'named-args-test')
->description(description: 'Testing named arguments')
->version(version: '1.0')
->email(
->fakeEmail(
template: 'test',
to: 'test@example.com',
subject: 'Test Subject',
Expand Down
Loading