mercureact/tests/ConfigurationTest.php

48 lines
1.2 KiB
PHP

<?php
namespace NoccyLabs\Mercureact;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(Configuration::class)]
class ConfigurationTest extends \PHPUnit\Framework\TestCase
{
public function testCreatingDefaultConfiguration()
{
$config = Configuration::createDefault();
$this->assertInstanceOf(Configuration::class, $config);
}
public function testGettingSingleValues()
{
$config = new Configuration([
'foo.bar' => 'baz',
'foo.baz' => true,
'foo.bin' => 42,
]);
$this->assertEquals('baz', $config->get("foo.bar"));
$this->assertEquals(true, $config->get("foo.baz"));
$this->assertEquals(42, $config->get("foo.bin"));
}
public function testGettingMultipleValues()
{
$config = new Configuration([
'foo.bar' => 'baz',
'foo.baz' => true,
'foo.bin' => 42,
'bar' => false,
]);
$this->assertEquals([
'foo.bar' => 'baz',
'foo.baz' => true,
'foo.bin' => 42,
], $config->get("foo."));
$this->assertEquals(false, $config->get("bar"));
$this->assertEquals([], $config->get("bar."));
}
}