@@ -52,32 +52,71 @@ public function testBuildConfigurableProcessor(): void
5252 $ this ->assertSame ($ processor , $ result );
5353 }
5454
55- public function testBuildPipeline (): void
55+ public function testBuildConfigurableProcessorWithEmptyConfig (): void
56+ {
57+ $ processor = $ this ->createMock (ConfigurableProcessor::class);
58+ $ this ->registry ->expects ($ this ->once ())
59+ ->method ('get ' )
60+ ->with ('context ' , 'name ' )
61+ ->willReturn ($ processor );
62+
63+ $ processor ->expects ($ this ->never ())
64+ ->method ('configure ' );
65+
66+ $ result = $ this ->builder ->build ('context ' , 'name ' , []);
67+ $ this ->assertSame ($ processor , $ result );
68+ }
69+
70+ public function testBuildPipelineWithVariousProcessorTypes (): void
5671 {
5772 $ processor1 = $ this ->createMock (Processor::class);
5873 $ processor2 = $ this ->createMock (ConfigurableProcessor::class);
74+ $ processor3 = $ this ->createMock (Processor::class);
5975
60- $ this ->registry ->expects ($ this ->exactly (2 ))
76+ $ this ->registry ->expects ($ this ->exactly (3 ))
6177 ->method ('get ' )
62- ->willReturnCallback (function ($ context , $ name ) use ($ processor1 , $ processor2 ) {
63- if ('context ' === $ context && 'processor1 ' === $ name ) {
64- return $ processor1 ;
65- }
66- if ('context ' === $ context && 'processor2 ' === $ name ) {
67- return $ processor2 ;
68- }
69- $ this ->fail ('Unexpected get() call ' );
70- });
78+ ->willReturnMap ([
79+ ['context ' , 'processor1 ' , $ processor1 ],
80+ ['context ' , 'processor2 ' , $ processor2 ],
81+ ['context ' , 'processor3 ' , $ processor3 ],
82+ ]);
7183
7284 $ processor2 ->expects ($ this ->once ())
7385 ->method ('configure ' )
7486 ->with (['option ' => 'value ' ]);
7587
7688 $ result = $ this ->builder ->buildPipeline ('context ' , [
77- 'processor1 ' ,
89+ 'processor1 ' => true ,
7890 'processor2 ' => ['option ' => 'value ' ],
91+ 'processor3 ' => [],
92+ ]);
93+
94+ $ this ->assertInstanceOf (Pipeline::class, $ result );
95+ $ this ->assertInstanceOf (ProcessorPipeline::class, $ result );
96+ }
97+
98+ public function testBuildPipelineWithInvalidProcessorSpec (): void
99+ {
100+ $ processor = $ this ->createMock (Processor::class);
101+
102+ $ this ->registry ->expects ($ this ->once ())
103+ ->method ('get ' )
104+ ->with ('context ' , 'validProcessor ' )
105+ ->willReturn ($ processor );
106+
107+ $ result = $ this ->builder ->buildPipeline ('context ' , [
108+ 'validProcessor ' => true ,
109+ 'invalidProcessor ' => false ,
110+ 'anotherInvalidProcessor ' => null ,
79111 ]);
80112
113+ $ this ->assertInstanceOf (Pipeline::class, $ result );
114+ }
115+
116+ public function testBuildPipelineWithEmptySpecs (): void
117+ {
118+ $ result = $ this ->builder ->buildPipeline ('context ' , []);
119+
81120 $ this ->assertInstanceOf (Pipeline::class, $ result );
82121 $ this ->assertInstanceOf (ProcessorPipeline::class, $ result );
83122 }
0 commit comments