Passed
Push — master ( 657bc4...b4fb65 )
by Marcel
02:26
created

SaasProviderExtensionTest::getEmptyConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the SaasProviderBundle package.
5
 * (c) Fluxter <http://fluxter.net/>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Fluxter\SaasProviderBundle\Tests\DependencyInjection;
11
12
use Fluxter\SaasProviderBundle\DependencyInjection\SaasProviderExtension;
13
use PHPUnit\Framework\TestCase;
14
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\Yaml\Parser;
17
18
class SaasProviderExtensionTest extends TestCase
19
{
20
    /** @var ContainerBuilder */
21
    protected $configuration;
22
23
    protected function tearDown(): void
24
    {
25
        $this->configuration = null;
26
    }
27
28
    public function testUserLoadUnlessClientEntitySet()
29
    {
30
        $loader = new SaasProviderExtension();
31
        $config = $this->getEmptyConfig();
32
        unset($config['client_entity']);
33
34
        $this->expectException(InvalidConfigurationException::class);
35
        $loader->load(array($config), new ContainerBuilder());
36
    }
37
38
    /**
39
     * getEmptyConfig.
40
     *
41
     * @return array
42
     */
43
    protected function getEmptyConfig()
44
    {
45
        $yaml = <<<EOF
46
client_entity: Acme\MyBundle\Entity\User
47
EOF;
48
        $parser = new Parser();
49
50
        return $parser->parse($yaml);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $parser->parse($yaml) also could return the type Symfony\Component\Yaml\Tag\TaggedValue|string which is incompatible with the documented return type array.
Loading history...
51
    }
52
}
53