30
30
use PHPUnit \Framework \Attributes \UsesClass ;
31
31
use Psr \Log \LoggerInterface ;
32
32
use Psr \Log \NullLogger ;
33
+ use ReflectionClass ;
33
34
34
35
#[CoversClass(MaxBotServiceProvider::class)]
35
36
#[UsesClass(Api::class)]
@@ -104,7 +105,6 @@ public function itThrowsExceptionWhenGuzzleIsMissing(): void
104
105
$ this ->app ->make (ClientApiInterface::class);
105
106
}
106
107
107
-
108
108
/**
109
109
* @return array<string, array{0: string, 1: class-string}>
110
110
*/
@@ -166,7 +166,7 @@ public function clientIsConfiguredCorrectlyFromConfig(): void
166
166
$ client = $ this ->app ->make (ClientApiInterface::class);
167
167
$ this ->assertInstanceOf (Client::class, $ client );
168
168
169
- $ reflection = new \ ReflectionClass ($ client );
169
+ $ reflection = new ReflectionClass ($ client );
170
170
171
171
$ accessTokenProp = $ reflection ->getProperty ('accessToken ' );
172
172
$ baseUrlProp = $ reflection ->getProperty ('baseUrl ' );
@@ -188,7 +188,7 @@ public function clientIsConfiguredWithApplicationLoggerWhenLoggingIsEnabled(): v
188
188
/** @var Client $client */
189
189
$ client = $ this ->app ->make (ClientApiInterface::class);
190
190
191
- $ reflection = new \ ReflectionClass ($ client );
191
+ $ reflection = new ReflectionClass ($ client );
192
192
$ loggerProp = $ reflection ->getProperty ('logger ' );
193
193
$ actualLogger = $ loggerProp ->getValue ($ client );
194
194
@@ -203,7 +203,7 @@ public function clientIsConfiguredWithNullLoggerWhenLoggingIsDisabled(): void
203
203
/** @var Client $client */
204
204
$ client = $ this ->app ->make (ClientApiInterface::class);
205
205
206
- $ reflection = new \ ReflectionClass ($ client );
206
+ $ reflection = new ReflectionClass ($ client );
207
207
$ loggerProp = $ reflection ->getProperty ('logger ' );
208
208
$ actualLogger = $ loggerProp ->getValue ($ client );
209
209
@@ -217,7 +217,7 @@ public function webhookHandlerIsConfiguredWithSecretFromConfig(): void
217
217
$ handler = $ this ->app ->make (WebhookHandler::class);
218
218
$ this ->assertInstanceOf (WebhookHandler::class, $ handler );
219
219
220
- $ reflection = new \ ReflectionClass ($ handler );
220
+ $ reflection = new ReflectionClass ($ handler );
221
221
$ secretProp = $ reflection ->getProperty ('secret ' );
222
222
223
223
$ this ->assertSame ('test-secret ' , $ secretProp ->getValue ($ handler ));
@@ -229,7 +229,7 @@ public function apiIsCreatedWithAllDependenciesFromContainer(): void
229
229
/** @var Api $api */
230
230
$ api = $ this ->app ->make (Api::class);
231
231
232
- $ reflection = new \ ReflectionClass ($ api );
232
+ $ reflection = new ReflectionClass ($ api );
233
233
234
234
$ clientProp = $ reflection ->getProperty ('client ' );
235
235
$ factoryProp = $ reflection ->getProperty ('modelFactory ' );
@@ -263,4 +263,27 @@ public function bootMethodRegistersCommandsInConsole(string $class, string $sign
263
263
$ this ->assertArrayHasKey ($ signature , $ commands );
264
264
$ this ->assertInstanceOf ($ class , $ commands [$ signature ]);
265
265
}
266
+
267
+ #[Test]
268
+ public function providesMethod (): void
269
+ {
270
+ $ provides = [
271
+ Api::class,
272
+ ClientApiInterface::class,
273
+ ModelFactory::class,
274
+ UpdateDispatcher::class,
275
+ WebhookHandler::class,
276
+ LongPollingHandler::class,
277
+ MaxBotManager::class,
278
+ 'maxbot ' ,
279
+ 'maxbot.api ' ,
280
+ 'maxbot.client ' ,
281
+ 'maxbot.dispatcher ' ,
282
+ 'maxbot.webhook ' ,
283
+ 'maxbot.polling ' ,
284
+ 'maxbot.manager ' ,
285
+ ];
286
+
287
+ $ this ->assertSame ($ this ->app ->getProvider (MaxBotServiceProvider::class)->provides (), $ provides );
288
+ }
266
289
}
0 commit comments