File tree Expand file tree Collapse file tree
src/Grphp/Client/Interceptors
tests/Unit/Grphp/Client/Interceptors Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ public function setRequest(&$request)
7373 }
7474
7575 /**
76- * Gets the fully qualified method name, e.g. grphp.catalog.products/GetProduct
76+ * Gets the fully qualified method name, e.g. grphp.test.Things/GetThing
7777 *
7878 * @return string
7979 * @throws StubNotFoundException
@@ -89,6 +89,24 @@ public function getFullyQualifiedMethodName(): string
8989 return $ stub ->getServiceName () . '/ ' . ucfirst ($ methodName );
9090 }
9191
92+ /**
93+ * Gets the fully qualified service name, e.g. grphp.test.Things
94+ *
95+ * @return string
96+ * @throws StubNotFoundException
97+ */
98+ public function getServiceName (): string
99+ {
100+ $ stub = $ this ->getStub ();
101+
102+ if (empty ($ stub )) {
103+ $ method = $ this ->getMethod ();
104+ throw new StubNotFoundException ("Stub not found for $ method " );
105+ }
106+
107+ return $ stub ->getServiceName ();
108+ }
109+
92110 /**
93111 * Get the expected response protobuf message class
94112 *
Original file line number Diff line number Diff line change @@ -102,6 +102,19 @@ public function testGetFullyQualifiedMethodName(): void
102102 $ this ->assertEquals ('grphp.test.Things/GetThing ' , $ interceptor ->getFullyQualifiedMethodName ());
103103 }
104104
105+ public function testGetServiceName (): void
106+ {
107+ $ requestMessage = new GetThingReq ();
108+ $ requestMessage ->setId (1 );
109+ $ client = new ThingsClient ('127.0.0.1:9000 ' , [ 'credentials ' => null ]);
110+ $ method = 'getThing ' ;
111+
112+ $ interceptor = new TestInterceptor ();
113+ $ interceptor ->setMethod ($ method );
114+ $ interceptor ->setStub ($ client );
115+ $ this ->assertEquals ('grphp.test.Things ' , $ interceptor ->getServiceName ());
116+ }
117+
105118 // When then stub is not set for some wild reason
106119 public function testGetFullyQualifiedMethodNameWhenNoStub (): void
107120 {
You can’t perform that action at this time.
0 commit comments