Completed
Push — symfony-4-upgrade-fix ( 457156...b0c4a6 )
by Jo
01:16
created

MyBuilderCronosExtensionTest::test_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace MyBuilder\Bundle\CronosBundle\Tests\DependencyInjection;
4
5
use MyBuilder\Bundle\CronosBundle\DependencyInjection\MyBuilderCronosExtension;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Config\FileLocator;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\Yaml\Yaml;
10
11
class MyBuilderCronosExtensionTest extends TestCase
12
{
13
    /** @var MyBuilderCronosExtension */
14
    private $loader;
15
16
    /** @var ContainerBuilder */
17
    private $container;
18
19
    protected function setUp(): void
20
    {
21
        $this->container = new ContainerBuilder();
22
        $this->loader = new MyBuilderCronosExtension();
23
    }
24
25
    /**
26
     * @dataProvider providerTestConfig
27
     */
28
    public function test_config(array $expected, string $file): void
29
    {
30
        $this->loader->load($this->getConfig($file), $this->container);
31
32
        static::assertEquals($expected, $this->container->getParameter('mybuilder.cronos_bundle.exporter_config'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MyBuilder\Bundle\...derCronosExtensionTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
    }
34
35
    public function providerTestConfig(): array
36
    {
37
        return [
38
            [
39
                [
40
                    'executor' => 'php',
41
                    'console' => '%kernel.root_dir%/../bin/console',
42
                ],
43
                'empty.yml',
44
            ],
45
            [
46
                [
47
                    'key' => 'test',
48
                    'mailto' => '[email protected]',
49
                    'path' => '/bin:/usr/local/bin',
50
                    'executor' => 'php',
51
                    'console' => 'bin/console',
52
                    'shell' => '/bin/bash',
53
                ],
54
                'full.yml',
55
            ],
56
        ];
57
    }
58
59
    /**
60
     * Load the specified yaml config file.
61
     */
62
    private function getConfig(string $fileName): array
63
    {
64
        $locator = new FileLocator(__DIR__ . '/config');
65
        $file = $locator->locate($fileName, null, true);
66
67
        $config = Yaml::parse(file_get_contents($file));
68
69
        if (null === $config) {
70
            return [];
71
        }
72
73
        return $config;
74
    }
75
}
76