Files
listmonk-api-bundle/tests/DependencyInjection/ConfigurationTest.php
2025-07-17 12:59:14 +02:00

53 lines
2.0 KiB
PHP

<?php declare(strict_types=1);
namespace Magdev\ListmonkApiBundle\Tests\DependencyInjection;
use Magdev\ListmonkApiBundle\DependencyInjection\Configuration;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Processor;
/**
* @author Marco Grätsch <magdev3.0@gmail.com>
*/
class ConfigurationTest extends TestCase
{
#[DataProvider('configsProvider')]
public function testConfig(array $configs): void
{
$config = (new Processor())->processConfiguration(new Configuration(), $configs);
$this->assertSame('https://localhost:8443', $config['connections']['default']['hostname']);
$this->assertSame('listmonk', $config['connections']['default']['username']);
$this->assertSame('listmonk', $config['connections']['default']['token']);
$this->assertTrue($config['connections']['default']['verify_https']);
$this->assertIsArray($config['connections']['default']['options']);
$this->assertIsArray($config['connections']['default']['options']['logger']);
$this->assertSame('php://stdout', $config['connections']['default']['options']['logger']['filename']);
$this->assertSame(100, $config['connections']['default']['options']['logger']['level']);
}
public static function configsProvider(): iterable
{
yield [[
'magdev_listmonk' => [
'connections' => [
'default' => [
'hostname' => 'https://localhost:8443',
'username' => 'listmonk',
'token' => 'listmonk',
'verify_https' => true,
'options' => [
'logger' => [
'filename' => 'php://stdout',
'level' => 100,
],
],
],
],
],
]];
}
}