You've already forked listmonk-api-bundle
initial commit
This commit is contained in:
52
tests/DependencyInjection/ConfigurationTest.php
Normal file
52
tests/DependencyInjection/ConfigurationTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]];
|
||||
}
|
||||
}
|
||||
49
tests/DependencyInjection/MagdevListmonkApiExtensionTest.php
Normal file
49
tests/DependencyInjection/MagdevListmonkApiExtensionTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Magdev\ListmonkApi\ListmonkClient;
|
||||
use Magdev\ListmonkApiBundle\DependencyInjection\MagdevListmonkApiExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpClient\ScopingHttpClient;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
class MagdevListmonkApiExtensionTest extends TestCase
|
||||
{
|
||||
public function testExtension(): void
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
(new MagdevListmonkApiExtension())->load([
|
||||
'magdev_listmonk' => [
|
||||
'connections' => [
|
||||
'default' => [
|
||||
'hostname' => 'https://localhost:8443',
|
||||
'username' => 'listmonk',
|
||||
'token' => 'listmonk',
|
||||
'verify_https' => false,
|
||||
'options' => [
|
||||
'logger' => [
|
||||
'filename' => 'php://stdout',
|
||||
'level' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
], $container);
|
||||
|
||||
$client = $container->get('magdev.listmonk.default');
|
||||
/** @var \Magdev\ListmonkApi\ListmonkClient $client */
|
||||
$this->assertInstanceOf(ListmonkClient::class, $client);
|
||||
|
||||
$httpClient = $client->getClient();
|
||||
/** @var \Symfony\Component\HttpClient\ScopingHttpClient $httpClient */
|
||||
$this->assertInstanceOf(HttpClientInterface::class, $httpClient);
|
||||
$this->assertInstanceOf(ScopingHttpClient::class, $httpClient);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user