forked from shlinkio/shlink-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigOptionsManagerFactoryTest.php
More file actions
56 lines (47 loc) · 2.02 KB
/
ConfigOptionsManagerFactoryTest.php
File metadata and controls
56 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Installer\Config;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Shlinkio\Shlink\Installer\Config\ConfigOptionsManagerFactory;
use Shlinkio\Shlink\Installer\Config\Option\ConfigOptionInterface;
class ConfigOptionsManagerFactoryTest extends TestCase
{
private ConfigOptionsManagerFactory $factory;
private MockObject & ContainerInterface $container;
public function setUp(): void
{
$this->container = $this->createMock(ContainerInterface::class);
$this->factory = new ConfigOptionsManagerFactory();
}
#[Test, DataProvider('provideConfigs')]
public function createsServiceWithExpectedPlugins(callable $configCreator, bool $servicesExist): void
{
$config = $configCreator($this);
$this->container->expects($this->once())->method('get')->with('config')->willReturn($config);
$manager = ($this->factory)($this->container);
self::assertEquals($servicesExist, $manager->has('a'));
self::assertEquals($servicesExist, $manager->has('b'));
self::assertEquals($servicesExist, $manager->has('c'));
}
public static function provideConfigs(): iterable
{
yield 'config_options not defined' => [static fn (TestCase $test) => [], false];
yield 'config_options empty' => [static fn (TestCase $test) => ['config_options' => []], false];
yield 'config_options with values' => [
static fn (TestCase $test) => [
'config_options' => [
'services' => [
'a' => $test->createStub(ConfigOptionInterface::class),
'b' => $test->createStub(ConfigOptionInterface::class),
'c' => $test->createStub(ConfigOptionInterface::class),
],
],
],
true,
];
}
}