From 7cf1e1ea5200738b4071aef72c7c090ad1eaf0d8 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Tue, 9 May 2023 00:12:45 +0200 Subject: [PATCH 1/6] update for Nutgram 4.x --- composer.json | 4 ++-- src/Console/LogoutCommand.php | 2 +- src/Console/WebhookRemoveCommand.php | 4 +--- src/Console/WebhookSetCommand.php | 2 +- src/DependencyInjection/Factory/NutgramFactory.php | 14 +++++++++----- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 0b801df..1f4dc6d 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,8 @@ "description": "Nutgram for Symfony", "type": "symfony-bundle", "require": { - "php": "^8.0", - "nutgram/nutgram": "^3.0", + "php": "^8.2", + "nutgram/nutgram": "4.x-dev", "symfony/cache": "^6.0", "symfony/config": "^6.0", "symfony/http-kernel": "^6.0", diff --git a/src/Console/LogoutCommand.php b/src/Console/LogoutCommand.php index cc7b999..7c645ee 100644 --- a/src/Console/LogoutCommand.php +++ b/src/Console/LogoutCommand.php @@ -36,7 +36,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dropPendingUpdates = (bool)$input->getOption('drop-pending-updates'); try { - $this->bot->deleteWebhook(['drop_pending_updates' => $dropPendingUpdates]); + $this->bot->deleteWebhook($dropPendingUpdates); } finally { $io->info('Webhook deleted.'); } diff --git a/src/Console/WebhookRemoveCommand.php b/src/Console/WebhookRemoveCommand.php index 55b49e6..2d55f5d 100644 --- a/src/Console/WebhookRemoveCommand.php +++ b/src/Console/WebhookRemoveCommand.php @@ -35,9 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dropPendingUpdates = (bool)$input->getOption('drop-pending-updates'); - $this->bot->deleteWebhook([ - 'drop_pending_updates' => $dropPendingUpdates, - ]); + $this->bot->deleteWebhook($dropPendingUpdates); if ($dropPendingUpdates) { $io->info('Pending updates dropped.'); diff --git a/src/Console/WebhookSetCommand.php b/src/Console/WebhookSetCommand.php index a3846bc..f2d9974 100644 --- a/src/Console/WebhookSetCommand.php +++ b/src/Console/WebhookSetCommand.php @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $max_connections = (int)$max_connections; } - $this->bot->setWebhook($url, array_filter(compact('ip_address', 'max_connections'))); + $this->bot->setWebhook($url, ip_address: $ip_address, max_connections: $max_connections); $io->info("Bot webhook set with url: $url"); diff --git a/src/DependencyInjection/Factory/NutgramFactory.php b/src/DependencyInjection/Factory/NutgramFactory.php index b90a9d2..aa321f3 100644 --- a/src/DependencyInjection/Factory/NutgramFactory.php +++ b/src/DependencyInjection/Factory/NutgramFactory.php @@ -5,6 +5,7 @@ use Psr\Cache\CacheItemPoolInterface; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; +use SergiX44\Nutgram\Configuration; use SergiX44\Nutgram\Nutgram; use SergiX44\Nutgram\RunningMode\Polling; use SergiX44\Nutgram\RunningMode\Webhook; @@ -30,11 +31,14 @@ public function createNutgram( $isCli = \PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg'; - $bot = new Nutgram($config['token'], array_merge([ - 'container' => $container, - 'cache' => new Psr16Cache($nutgramCache), - 'logger' => $isCli ? $nutgramConsoleLogger : $nutgramLogger, - ], $config['config'] ?? [])); + $configuration = new Configuration( + clientOptions: $config['client_options'] ?? [], + container: $container, + cache: new Psr16Cache($nutgramCache), + logger: $isCli ? $nutgramConsoleLogger : $nutgramLogger + ); + + $bot = new Nutgram($config['token'], $configuration); if ($isCli) { $bot->setRunningMode(Polling::class); From 953a60b449fff09c99eeab6559d0aa5af242d7a7 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Sun, 14 May 2023 17:48:12 +0200 Subject: [PATCH 2/6] add test framework --- composer.json | 18 ++++++++++++-- phpunit.xml | 17 +++++++++++++ tests/Feature/ExampleTest.php | 5 ++++ tests/Pest.php | 47 +++++++++++++++++++++++++++++++++++ tests/TestCase.php | 10 ++++++++ tests/Unit/ExampleTest.php | 5 ++++ 6 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 phpunit.xml create mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/Pest.php create mode 100644 tests/TestCase.php create mode 100644 tests/Unit/ExampleTest.php diff --git a/composer.json b/composer.json index 1f4dc6d..509f6c9 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "symfony-bundle", "require": { "php": "^8.2", - "nutgram/nutgram": "4.x-dev", + "nutgram/nutgram": "^4", "symfony/cache": "^6.0", "symfony/config": "^6.0", "symfony/http-kernel": "^6.0", @@ -17,6 +17,11 @@ "SergiX44\\NutgramBundle\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "SergiX44\\NutgramBundle\\Tests\\": "tests/" + } + }, "authors": [ { "name": "Sergio Brighenti", @@ -24,5 +29,14 @@ } ], "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "require-dev": { + "symfony/framework-bundle": "^6.2", + "pestphp/pest": "^2.6" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..ad75643 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,17 @@ + + + + + ./tests + + + + > + ./src + + + diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php new file mode 100644 index 0000000..61cd84c --- /dev/null +++ b/tests/Feature/ExampleTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..83c533c --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,47 @@ +in('Feature'); + +/* +|-------------------------------------------------------------------------- +| Expectations +|-------------------------------------------------------------------------- +| +| When you're writing tests, you often need to check that values meet certain conditions. The +| "expect()" function gives you access to a set of "expectations" methods that you can use +| to assert different things. Of course, you may extend the Expectation API at any time. +| +*/ + +expect()->extend('toBeOne', function () { + return $this->toBe(1); +}); + +/* +|-------------------------------------------------------------------------- +| Functions +|-------------------------------------------------------------------------- +| +| While Pest is very powerful out-of-the-box, you may have some testing code specific to your +| project that you don't want to repeat in every file. Here you can also expose helpers as +| global functions to help you to reduce the number of lines of code in your test files. +| +*/ + +function something() +{ + // .. +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..093b202 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,10 @@ +toBeTrue(); +}); From 015c7b448ecaefc38ead15a8827aaeb48270674e Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 15 May 2023 19:14:47 +0200 Subject: [PATCH 3/6] working test suite --- .github/workflows/php.yml | 80 +++++++++++++++++++++++++++++++++ composer.json | 17 ++++--- config/services.yaml | 3 ++ phpunit.xml | 7 ++- src/NutgramConfigurator.php | 2 +- tests/Feature/ExampleTest.php | 5 --- tests/Fixtures/AppKernel.php | 22 +++++++++ tests/Fixtures/test_config.yaml | 3 ++ tests/Functional/BundleTest.php | 17 +++++++ tests/Pest.php | 11 +---- tests/Unit/ExampleTest.php | 5 --- 11 files changed, 144 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/php.yml delete mode 100644 tests/Feature/ExampleTest.php create mode 100644 tests/Fixtures/AppKernel.php create mode 100644 tests/Fixtures/test_config.yaml create mode 100644 tests/Functional/BundleTest.php delete mode 100644 tests/Unit/ExampleTest.php diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..2e1519a --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,80 @@ +name: Test Suite + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ 8.2 ] + + name: PHP ${{ matrix.php }} + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }} + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: | + composer update --prefer-dist --no-interaction --no-suggest + + - name: Run test suite + run: composer run-script test + coverage: + name: Coverage + needs: [ tests ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: xdebug + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-8.2-${{ hashFiles('**/composer.json') }} + restore-keys: | + ${{ runner.os }}-php-8.2 + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-interaction --no-suggest + + - name: Run test suite + uses: paambaati/codeclimate-action@v3.2.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_REPORTER_ID }} + with: + coverageCommand: composer run-script test-coverage + coverageLocations: ${{github.workspace}}/coverage.xml:clover diff --git a/composer.json b/composer.json index 509f6c9..632dd23 100644 --- a/composer.json +++ b/composer.json @@ -2,16 +2,21 @@ "name": "nutgram/symfony-bundle", "description": "Nutgram for Symfony", "type": "symfony-bundle", + "license": "MIT", "require": { "php": "^8.2", - "nutgram/nutgram": "^4", + "nutgram/nutgram": "^4.0", "symfony/cache": "^6.0", "symfony/config": "^6.0", "symfony/http-kernel": "^6.0", "symfony/dependency-injection": "^6.0", "symfony/console": "^6.0" }, - "license": "MIT", + "require-dev": { + "symfony/framework-bundle": "^6.0", + "symfony/yaml": "^6.0", + "pestphp/pest": "^2.6" + }, "autoload": { "psr-4": { "SergiX44\\NutgramBundle\\": "src/" @@ -28,12 +33,12 @@ "email": "sergio@brighenti.me" } ], + "scripts": { + "test": "@php vendor/bin/pest --fail-on-warning", + "test-coverage": "@php vendor/bin/pest --coverage --coverage-clover=coverage.xml --fail-on-warning" + }, "minimum-stability": "dev", "prefer-stable": true, - "require-dev": { - "symfony/framework-bundle": "^6.2", - "pestphp/pest": "^2.6" - }, "config": { "allow-plugins": { "pestphp/pest-plugin": true diff --git a/config/services.yaml b/config/services.yaml index 8d207df..30dbff4 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -13,6 +13,9 @@ services: arguments: [ '%nutgram.config%', '@service_container' ] configurator: [ '@SergiX44\NutgramBundle\NutgramConfigurator', 'configure' ] + nutgram: + alias: 'SergiX44\Nutgram\Nutgram' + SergiX44\NutgramBundle\Console\: resource: '../src/Console/' autowire: true diff --git a/phpunit.xml b/phpunit.xml index ad75643..9112919 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,8 +10,13 @@ - > + ./src + + + + + diff --git a/src/NutgramConfigurator.php b/src/NutgramConfigurator.php index ce03961..e50680f 100644 --- a/src/NutgramConfigurator.php +++ b/src/NutgramConfigurator.php @@ -22,7 +22,7 @@ public function __construct(array $config, Nutgram $bot, KernelInterface $kernel public function configure() { - if (!$this->config['routes']) { + if (!($this->config['routes'] ?? false)) { return; } diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 61cd84c..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); diff --git a/tests/Fixtures/AppKernel.php b/tests/Fixtures/AppKernel.php new file mode 100644 index 0000000..9a34d64 --- /dev/null +++ b/tests/Fixtures/AppKernel.php @@ -0,0 +1,22 @@ +load(__DIR__.'/test_config.yaml'); + } +} \ No newline at end of file diff --git a/tests/Fixtures/test_config.yaml b/tests/Fixtures/test_config.yaml new file mode 100644 index 0000000..70abc08 --- /dev/null +++ b/tests/Fixtures/test_config.yaml @@ -0,0 +1,3 @@ +framework: + secret: "Three can keep a secret, if two of them are dead." + test: ~ \ No newline at end of file diff --git a/tests/Functional/BundleTest.php b/tests/Functional/BundleTest.php new file mode 100644 index 0000000..c94cb87 --- /dev/null +++ b/tests/Functional/BundleTest.php @@ -0,0 +1,17 @@ +get(Nutgram::class); + + expect($instance)->toBeInstanceOf(Nutgram::class); +}); + +it('returns an instance with the alias', function () { + /** @var Nutgram $instance */ + $instance = static::getContainer()->get('nutgram'); + + expect($instance)->toBeInstanceOf(Nutgram::class); +}); diff --git a/tests/Pest.php b/tests/Pest.php index 83c533c..02747ca 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -13,7 +13,7 @@ use SergiX44\NutgramBundle\Tests\TestCase; -uses(TestCase::class)->in('Feature'); +uses(TestCase::class)->in('Functional'); /* |-------------------------------------------------------------------------- @@ -26,10 +26,6 @@ | */ -expect()->extend('toBeOne', function () { - return $this->toBe(1); -}); - /* |-------------------------------------------------------------------------- | Functions @@ -40,8 +36,3 @@ | global functions to help you to reduce the number of lines of code in your test files. | */ - -function something() -{ - // .. -} diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 61cd84c..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); From 8ee3c76bd0c1297cb0c023abe10567fae455d5d4 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 15 May 2023 19:58:08 +0200 Subject: [PATCH 4/6] add some basic tests --- tests/Fixtures/test_config.yaml | 8 +++- tests/Functional/CommandTest.php | 81 ++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 tests/Functional/CommandTest.php diff --git a/tests/Fixtures/test_config.yaml b/tests/Fixtures/test_config.yaml index 70abc08..ed2f1f5 100644 --- a/tests/Fixtures/test_config.yaml +++ b/tests/Fixtures/test_config.yaml @@ -1,3 +1,9 @@ framework: secret: "Three can keep a secret, if two of them are dead." - test: ~ \ No newline at end of file + test: ~ + +nutgram: + token: '%env(string:TELEGRAM_TOKEN)%' + safe_mode: false + config: [ ] + routes: true \ No newline at end of file diff --git a/tests/Functional/CommandTest.php b/tests/Functional/CommandTest.php new file mode 100644 index 0000000..260dfdb --- /dev/null +++ b/tests/Functional/CommandTest.php @@ -0,0 +1,81 @@ +get(Nutgram::class); + + $commandTester = new CommandTester(new LogoutCommand($instance)); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $instance->assertCalled('deleteWebhook'); + $instance->assertCalled('close'); + $instance->assertCalled('logOut'); +}); + +it('register the commands', function () { + /** @var \SergiX44\Nutgram\Testing\FakeNutgram $instance */ + $instance = static::getContainer()->get(Nutgram::class); + + $commandTester = new CommandTester(new RegisterCommandsCommand($instance)); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $instance->assertCalled('setMyCommands'); +}); + +it('calls the run method', function () { + $mock = $this->getMockBuilder(Nutgram::class) + ->disableOriginalConstructor() + ->onlyMethods(['run']) + ->getMock(); + + $mock->expects($this->once()) + ->method('run'); + + $commandTester = new CommandTester(new RunCommand($mock)); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); +}); + +it('gets webhook infos', function () { + /** @var \SergiX44\Nutgram\Testing\FakeNutgram $instance */ + $instance = static::getContainer()->get(Nutgram::class); + + $commandTester = new CommandTester(new WebhookInfoCommand($instance)); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $instance->assertCalled('getWebhookInfo'); +}); + +it('call the remove webhook', function () { + /** @var \SergiX44\Nutgram\Testing\FakeNutgram $instance */ + $instance = static::getContainer()->get(Nutgram::class); + + $commandTester = new CommandTester(new WebhookRemoveCommand($instance)); + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); + + $instance->assertCalled('deleteWebhook'); +}); + +it('calls the set webhook', function () { + /** @var \SergiX44\Nutgram\Testing\FakeNutgram $instance */ + $instance = static::getContainer()->get(Nutgram::class); + + $commandTester = new CommandTester(new WebhookSetCommand($instance)); + $commandTester->execute(['url' => 'http://foo.bar']); + $commandTester->assertCommandIsSuccessful(); + + $instance->assertCalled('setWebhook'); +}); \ No newline at end of file From 4956e6a052039779fcebe4906ef92dfa4cd2bf54 Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 15 May 2023 23:03:54 +0200 Subject: [PATCH 5/6] new configuration mapping --- config/nutgram.yaml | 8 +++---- phpunit.xml | 2 +- src/DependencyInjection/Configuration.php | 21 ++++++++++++++----- .../Factory/NutgramFactory.php | 9 ++++---- tests/Fixtures/test_config.yaml | 12 ++++++++--- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/config/nutgram.yaml b/config/nutgram.yaml index db16ea2..e6d5340 100644 --- a/config/nutgram.yaml +++ b/config/nutgram.yaml @@ -3,10 +3,10 @@ nutgram: token: '%env(string:TELEGRAM_TOKEN)%' # If true, the webhook mode validates the incoming IP range is from a Telegram server - safe_mode: false - - # Extra or specific configuration - config: [ ] + safeMode: false # If the nutgram bundle should automatically load the routes from config/telegram.php routes: true + + # Extra or specific configuration + config: [ ] diff --git a/phpunit.xml b/phpunit.xml index 9112919..bdfd382 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,6 +17,6 @@ - + diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 39a34fc..f8e61d3 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -13,11 +13,22 @@ public function getConfigTreeBuilder(): TreeBuilder $treeBuilder->getRootNode() ->children() - ->scalarNode('token')->end() - ->booleanNode('safe_mode')->end() - ->arrayNode('config')->end() - ->booleanNode('routes')->end() - ->end() + ->scalarNode('token')->end() + ->booleanNode('safeMode')->end() + ->booleanNode('routes')->end() + ->arrayNode('config') + ->children() + ->scalarNode('apiUrl')->defaultValue(\SergiX44\Nutgram\Configuration::DEFAULT_API_URL)->end() + ->scalarNode('botId')->defaultNull()->end() + ->scalarNode('botName')->defaultNull()->end() + ->booleanNode('testEnv')->defaultFalse()->end() + ->scalarNode('clientTimeout')->defaultValue(\SergiX44\Nutgram\Configuration::DEFAULT_CLIENT_TIMEOUT)->end() + ->arrayNode('clientOptions')->end() + ->scalarNode('localPathTransformer')->defaultNull()->end() + ->scalarNode('pollingTimeout')->defaultValue(\SergiX44\Nutgram\Configuration::DEFAULT_POLLING_TIMEOUT)->end() + ->scalarNode('pollingLimit')->defaultValue(\SergiX44\Nutgram\Configuration::DEFAULT_POLLING_LIMIT)->end() + ->arrayNode('pollingAllowedUpdates')->end() + ->end() ->end(); return $treeBuilder; diff --git a/src/DependencyInjection/Factory/NutgramFactory.php b/src/DependencyInjection/Factory/NutgramFactory.php index aa321f3..8ce2ade 100644 --- a/src/DependencyInjection/Factory/NutgramFactory.php +++ b/src/DependencyInjection/Factory/NutgramFactory.php @@ -24,11 +24,6 @@ public function createNutgram( ?LoggerInterface $nutgramLogger, ?LoggerInterface $nutgramConsoleLogger ): Nutgram { - - if ($kernel->getEnvironment() === 'test') { - return Nutgram::fake(); - } - $isCli = \PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg'; $configuration = new Configuration( @@ -38,6 +33,10 @@ public function createNutgram( logger: $isCli ? $nutgramConsoleLogger : $nutgramLogger ); + if ($kernel->getEnvironment() === 'test') { + return Nutgram::fake(config: $configuration); + } + $bot = new Nutgram($config['token'], $configuration); if ($isCli) { diff --git a/tests/Fixtures/test_config.yaml b/tests/Fixtures/test_config.yaml index ed2f1f5..a49fcf1 100644 --- a/tests/Fixtures/test_config.yaml +++ b/tests/Fixtures/test_config.yaml @@ -4,6 +4,12 @@ framework: nutgram: token: '%env(string:TELEGRAM_TOKEN)%' - safe_mode: false - config: [ ] - routes: true \ No newline at end of file + safeMode: false + routes: true + config: + botId: 123 + apiUrl: 'BlaBla' + botName: 'EEE' + testEnv: true + pollingTimeout: 123 + pollingLimit: 456 \ No newline at end of file From ea0e8f68ee100b1c7acf929842211d90b746b93c Mon Sep 17 00:00:00 2001 From: Sergio Brighenti Date: Mon, 15 May 2023 23:09:36 +0200 Subject: [PATCH 6/6] set parameters --- src/DependencyInjection/Factory/NutgramFactory.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Factory/NutgramFactory.php b/src/DependencyInjection/Factory/NutgramFactory.php index 8ce2ade..c3a5bd2 100644 --- a/src/DependencyInjection/Factory/NutgramFactory.php +++ b/src/DependencyInjection/Factory/NutgramFactory.php @@ -27,10 +27,18 @@ public function createNutgram( $isCli = \PHP_SAPI === 'cli' || \PHP_SAPI === 'phpdbg'; $configuration = new Configuration( - clientOptions: $config['client_options'] ?? [], + apiUrl: $config['config']['apiUrl'], + botId: $config['config']['botId'], + botName: $config['config']['botName'], + testEnv: $config['config']['testEnv'], + clientTimeout: $config['config']['clientTimeout'], + clientOptions: $config['config']['clientOptions'] ?? [], container: $container, cache: new Psr16Cache($nutgramCache), - logger: $isCli ? $nutgramConsoleLogger : $nutgramLogger + logger: $isCli ? $nutgramConsoleLogger : $nutgramLogger, + localPathTransformer: $config['config']['localPathTransformer'], + pollingTimeout: $config['config']['pollingTimeout'], + pollingLimit: $config['config']['pollingLimit'], ); if ($kernel->getEnvironment() === 'test') {