Skip to content

Commit

Permalink
Fix: Multiple recipes were not properly stacked (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolaszek authored Dec 11, 2023
1 parent fff38db commit 7ca7124
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Internal/EtlBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ public function withOptions(EtlConfiguration $configuration): self

public function withRecipe(Recipe|callable $recipe, Recipe|callable ...$recipes): self
{
$executor = $this;
foreach ([$recipe, ...$recipes] as $_recipe) {
if (!$_recipe instanceof Recipe) {
$_recipe = Recipe::fromCallable($_recipe);
}
$executor = $_recipe->decorate($this);
$executor = $_recipe->decorate($executor);
}

return $executor;
Expand Down
7 changes: 5 additions & 2 deletions tests/Unit/Recipe/RecipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ function (EtlExecutor $executor) use (&$hasReceivedInitEvent, &$hasReceivedEndEv
$hasReceivedEndEvent = true;
});
},
fn (EtlExecutor $executor) => $executor->withContext(['foo' => 'bar'])
);

// When
$executor->process([]);
$report = $executor->process([]);

// Then
expect($hasReceivedInitEvent)->toBeTrue()
->and($hasReceivedEndEvent)->toBeTrue();
->and($hasReceivedEndEvent)->toBeTrue()
->and($report->context)->toBe(['foo' => 'bar'])
;
});

0 comments on commit 7ca7124

Please sign in to comment.