Skip to content

Commit e01f3e6

Browse files
committed
support for fake nutgram
1 parent 21c5aea commit e01f3e6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/DependencyInjection/Factory/NutgramFactory.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@
1010
use SergiX44\Nutgram\RunningMode\Webhook;
1111
use Symfony\Component\Cache\Psr16Cache;
1212
use Symfony\Component\HttpFoundation\RequestStack;
13+
use Symfony\Component\HttpKernel\KernelInterface;
1314

1415
class NutgramFactory
1516
{
1617
public function createNutgram(
1718
array $config,
1819
ContainerInterface $container,
1920
RequestStack $requestStack,
21+
KernelInterface $kernel,
2022
?CacheItemPoolInterface $nutgramCache,
2123
?LoggerInterface $nutgramLogger,
2224
?LoggerInterface $nutgramConsoleLogger
2325
): Nutgram {
26+
27+
if ($kernel->getEnvironment() === 'test') {
28+
return Nutgram::fake();
29+
}
30+
2431
$isCli = \PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg';
2532

2633
$bot = new Nutgram($config['token'], array_merge([

0 commit comments

Comments
 (0)