44use Behat \Behat \Context \Context ;
55use Behat \Gherkin \Node \PyStringNode ;
66use Behat \Gherkin \Node \TableNode ;
7+ use DemoApp \Method \MethodB ;
8+ use DemoApp \Resolver \JsonRpcMethodResolver ;
79use PHPUnit \Framework \Assert ;
810use Prophecy \Argument ;
911use Prophecy \Prophet ;
1012use Symfony \Component \DependencyInjection \ContainerBuilder ;
1113use Symfony \Component \DependencyInjection \Definition ;
1214use Symfony \Component \HttpFoundation \Request ;
13- use Tests \Functional \BehatContext \App \CustomMethodResolver ;
14- use Tests \Functional \BehatContext \App \JsonRpcMethod ;
15+ use Yoanm \JsonRpcServer \Domain \Model \JsonRpcMethodInterface ;
1516use Yoanm \JsonRpcServer \Infra \Endpoint \JsonRpcEndpoint ;
1617use Yoanm \SymfonyJsonRpcHttpServer \Infra \Endpoint \JsonRpcHttpEndpoint ;
1718use Yoanm \SymfonyJsonRpcHttpServer \Infra \Symfony \DependencyInjection \JsonRpcHttpServerExtension ;
1819
1920/**
2021 * Defines application features from the specific context.
2122 */
22- class FeatureContext implements Context
23+ class SymfonyExtensionContext implements Context
2324{
2425 const CUSTOM_METHOD_RESOLVER_SERVICE_ID = 'custom-method-resolver-service ' ;
2526
@@ -41,14 +42,15 @@ class FeatureContext implements Context
4142 public function __construct ()
4243 {
4344 $ this ->prophet = new Prophet ();
45+ $ this ->extension = new JsonRpcHttpServerExtension ();
4446 }
4547
4648 /**
4749 * @Given I process the symfony extension
4850 */
4951 public function givenIProcessTheSymfonyExtension ()
5052 {
51- ( new JsonRpcHttpServerExtension ()) ->load ([], $ this ->getContainerBuilder ());
53+ $ this -> extension ->load ([], $ this ->getContainerBuilder ());
5254 }
5355
5456 /**
@@ -116,6 +118,7 @@ public function givenITagMyJsonRpcMethodServiceWithTagAndFollowingAttributes(
116118 */
117119 public function whenILoadEndpointFromService ($ serviceId )
118120 {
121+ $ this ->extension ->process ($ this ->getContainerBuilder ());
119122 $ this ->getContainerBuilder ()->compile ();
120123 $ this ->endpoint = $ this ->getContainerBuilder ()->get ($ serviceId );
121124 }
@@ -152,7 +155,7 @@ private function assertEndpointRespondToCalls(JsonRpcHttpEndpoint $endpoint, arr
152155 [
153156 'jsonrpc ' => '2.0 ' ,
154157 'id ' => $ requestId ,
155- 'result ' => 'OK '
158+ 'result ' => 'MethodB '
156159 ]
157160 ),
158161 $ endpoint ->index ($ request )->getContent ()
@@ -161,19 +164,19 @@ private function assertEndpointRespondToCalls(JsonRpcHttpEndpoint $endpoint, arr
161164 }
162165
163166 /**
164- * @return JsonRpcMethod
167+ * @return JsonRpcMethodInterface
165168 */
166169 private function createJsonRpcMethod ()
167170 {
168- return new JsonRpcMethod ();
171+ return new MethodB ();
169172 }
170173
171174 /**
172175 * @return Definition
173176 */
174177 private function createJsonRpcMethodDefinition ()
175178 {
176- return (new Definition (JsonRpcMethod ::class))->setPrivate (false );
179+ return (new Definition (MethodB ::class))->setPrivate (false );
177180 }
178181
179182 /**
@@ -196,8 +199,8 @@ private function injectJsonRpcMethodToDefaultResolverService($methodName, $metho
196199 }
197200
198201 /**
199- * @param string $methodName
200- * @param JsonRpcMethod |Definition $method
202+ * @param string $methodName
203+ * @param JsonRpcMethodInterface |Definition $method
201204 */
202205 private function injectJsonRpcMethodToCustomResolverService ($ methodName , $ method )
203206 {
@@ -221,7 +224,7 @@ private function getContainerBuilder()
221224 if (!$ this ->containerBuilder ) {
222225 $ this ->containerBuilder = new ContainerBuilder ();
223226 // Add definition of custom resolver (without tags)
224- $ customResolverDefinition = (new Definition (CustomMethodResolver ::class))->setPrivate ( false );
227+ $ customResolverDefinition = (new Definition (JsonRpcMethodResolver ::class))->setPublic ( true );
225228 $ this ->containerBuilder ->setDefinition (self ::CUSTOM_METHOD_RESOLVER_SERVICE_ID , $ customResolverDefinition );
226229 }
227230 return $ this ->containerBuilder ;
0 commit comments