How can I assert this:
$this->assertEquals('incoming', $payload['routerAction']);
Skipping the pipelines. I'm using phpleague/pipeline
Code:
class IncomingPipeline
{
public function __invoke(array $payload)
{
$router = $payload['router'];
$payload['routerAction'] = 'incoming';
return (new Pipeline())
->pipe(new DispatchIncomingEventStage())
->pipe(BaseRouter::route($router))
->process($payload);
}
}
I basically want to skip the Pipeline OR set andReturn($payload) on them.
You could make the pipeline a dependency to IncomingPipeline
and pass it into the constructor. That way, you could inject a pipeline without any stages in your tests.
If you want to keep it the way it is, you can use the overload
prefix ( docs ):
final class IncomingPipelineTest extends TestCase
{
public function test()
{
$pipeline = Mockery::mock('overload:' . Pipeline::class);
$pipeline->allows('pipe')->andReturnSelf();
$pipeline->allows('process')->andReturnArg(0);
$payload = (new IncomingPipeline())(...);
self::assertEquals('incoming', $payload['routerAction']);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.