Skip to content

Commit a44bfd8

Browse files
Add a test for pipeline through method overwriting previously set and appended pipes (#56100)
1 parent 1d18684 commit a44bfd8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Pipeline/PipelineTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ function ($piped) {
124124
$this->assertEquals(2, $object->value);
125125
}
126126

127+
public function testPipelineThroughMethodOverwritesPreviouslySetAndAppendedPipes()
128+
{
129+
$object = new stdClass();
130+
131+
$object->value = 0;
132+
133+
$function = function ($object, $next) {
134+
$object->value++;
135+
136+
return $next($object);
137+
};
138+
139+
$result = (new Pipeline(new Container))
140+
->send($object)
141+
->through([$function])
142+
->pipe([$function])
143+
->through([$function])
144+
->then(fn ($piped) => $piped);
145+
146+
$this->assertSame($object, $result);
147+
$this->assertEquals(1, $object->value);
148+
}
149+
127150
public function testPipelineUsageWithInvokableClass()
128151
{
129152
$result = (new Pipeline(new Container))

0 commit comments

Comments
 (0)