Completed
Push — master ( 4c1af7...741b75 )
by Ruud
21:53
created

ValidConfigEntity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 22
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultAdminType() 0 4 1
A getInternalName() 0 4 1
A getLabel() 0 4 1
A getRoles() 0 4 1
1
<?php
2
3
namespace Kunstmaan\ConfigBundle\Tests\DependencyInjection;
4
5
use Kunstmaan\ConfigBundle\DependencyInjection\Configuration;
6
use Kunstmaan\ConfigBundle\Entity\ConfigurationInterface;
7
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class ConfigurationTest
12
 */
13
class ConfigurationTest extends TestCase
14
{
15
    use ConfigurationTestCaseTrait;
16
17
    /**
18
     * @return \Symfony\Component\Config\Definition\ConfigurationInterface
19
     */
20
    protected function getConfiguration()
21
    {
22
        return new Configuration();
23
    }
24
25
    public function testConfigGeneratesAsExpected()
26
    {
27
        $array = [
28
            'entities' => [],
29
        ];
30
31
        $this->assertProcessedConfigurationEquals([$array], $array);
32
    }
33
34
    public function testConfigDoesntGenerateAsExpected()
35
    {
36
        $this->assertPartialConfigurationIsInvalid([['fail']], 'entities');
37
    }
38
39
    /**
40
     * @expectedException \InvalidArgumentException
41
     * @expectedExceptionMessage Entity "App\UndefinedEntity" does not exist
42
     */
43
    public function testConfigUndefinedEntity()
44
    {
45
        $array = [
46
            'entities' => [
47
                'App\\UndefinedEntity',
48
            ],
49
        ];
50
51
        $this->assertProcessedConfigurationEquals([$array], $array);
52
    }
53
54
    /**
55
     * @expectedException \RuntimeException
56
     * @expectedExceptionMessage The entity class "Kunstmaan\ConfigBundle\Tests\DependencyInjection\InvalidConfigEntity" needs to implement the Kunstmaan\ConfigBundle\Entity\ConfigurationInterface
57
     */
58
    public function testConfigInvalidEntity()
59
    {
60
        $array = [
61
            'entities' => [
62
                InvalidConfigEntity::class,
63
            ],
64
        ];
65
66
        $this->assertProcessedConfigurationEquals([$array], $array);
67
    }
68
69
    public function testConfigValidEntity()
70
    {
71
        $array = [
72
            'entities' => [
73
                ValidConfigEntity::class,
74
            ],
75
        ];
76
77
        $this->assertProcessedConfigurationEquals([$array], $array);
78
    }
79
}
80
81
class ValidConfigEntity implements ConfigurationInterface
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
82
{
83
    public function getDefaultAdminType()
84
    {
85
        return 'whatever';
86
    }
87
88
    public function getInternalName()
89
    {
90
        return 'whatever';
91
    }
92
93
    public function getLabel()
94
    {
95
        return 'whatever';
96
    }
97
98
    public function getRoles()
99
    {
100
        return [];
101
    }
102
}
103
104
class InvalidConfigEntity
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
105
{
106
}
107