22namespace Tests \Functional \BehatContext ;
33
44use Behat \Gherkin \Node \PyStringNode ;
5+ use DemoApp \AbstractKernel ;
6+ use DemoApp \DefaultKernel ;
7+ use DemoApp \KernelWithMappingCollectorListener ;
58use PHPUnit \Framework \Assert ;
69use Symfony \Component \HttpFoundation \Response ;
710use Yoanm \JsonRpcServer \Domain \JsonRpcMethodInterface ;
@@ -13,6 +16,16 @@ class DemoAppContext extends AbstractContext
1316{
1417 /** @var Response|null */
1518 private $ lastResponse ;
19+ /** @var bool */
20+ private $ useKernelWithMappingCollectorListener = false ;
21+
22+ /**
23+ * @Given I will use kernel with MappingCollector listener
24+ */
25+ public function givenIWillUseServerDocCreatedListener ()
26+ {
27+ $ this ->useKernelWithMappingCollectorListener = true ;
28+ }
1629
1730 /**
1831 * @When I send following :httpMethod input on :uri demoApp kernel endpoint:
@@ -69,4 +82,20 @@ public function thenCollectorShouldHaveAMethodWithName($methodClass, $methodName
6982 sprintf ('Method "%s" is not an instance of "%s" ' , $ methodName , $ methodClass )
7083 );
7184 }
85+ /**
86+ * @return AbstractKernel
87+ */
88+ public function getDemoAppKernel ()
89+ {
90+ $ env = 'prod ' ;
91+ $ debug = true ;
92+
93+ if (true === $ this ->useKernelWithMappingCollectorListener ) {
94+ $ kernelClass = KernelWithMappingCollectorListener::class;
95+ } else {
96+ $ kernelClass = DefaultKernel::class;
97+ }
98+
99+ return new $ kernelClass ($ env , $ debug );
100+ }
72101}
0 commit comments