testPreferredServices()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
namespace Skrz\Bundle\AutowiringBundle\Tests\DependencyInjection;
3
4
use PHPUnit\Framework\TestCase;
5
use Skrz\Bundle\AutowiringBundle\DependencyInjection\SkrzAutowiringExtension;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
8
use Symfony\Component\Config\Definition\Processor;
9
10
class SkrzAutowiringExtensionConfigTreeTest extends TestCase
11
{
12
13
	/** @var SkrzAutowiringExtension */
14
	private $extension;
15
16
	/** @var TreeBuilder */
17
	private $configTreeBuilder;
18
19
	/** @var Processor */
20
	private $processor;
21
22
	protected function setUp()
23
	{
24
		$this->extension = new SkrzAutowiringExtension();
25
		$this->configTreeBuilder = $this->extension->getConfigTreeBuilder();
26
		$this->processor = new Processor();
27
	}
28
29
30
	public function testRootInvalid()
31
	{
32
		$this->expectException(InvalidTypeException::class);
33
		$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => false]);
34
	}
35
36 View Code Duplication
	public function testRootNull()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
	{
38
		$this->assertEquals(
39
			[
40
				"ignored_services" => [],
41
				"preferred_services" => [],
42
				"fast_annotation_checks" => [],
43
				"fast_annotation_checks_enabled" => true,
44
			],
45
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => null])
46
		);
47
	}
48
49 View Code Duplication
	public function testRootEmptyArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
	{
51
		$this->assertEquals(
52
			[
53
				"ignored_services" => [],
54
				"preferred_services" => [],
55
				"fast_annotation_checks" => [],
56
				"fast_annotation_checks_enabled" => true,
57
			],
58
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => []])
59
		);
60
	}
61
62 View Code Duplication
	public function testIgnoredServicesInvalid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
	{
64
		$this->expectException(InvalidTypeException::class);
65
		$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
66
			"ignored_services" => "",
67
		]]);
68
	}
69
70 View Code Duplication
	public function testIgnoredServices()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
	{
72
		$this->assertEquals(
73
			[
74
				"ignored_services" => ["foo"],
75
				"preferred_services" => [],
76
				"fast_annotation_checks" => [],
77
				"fast_annotation_checks_enabled" => true,
78
			],
79
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
80
				"ignored_services" => ["foo"]
81
			]])
82
		);
83
	}
84
85 View Code Duplication
	public function testPreferredServicesInvalid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
	{
87
		$this->expectException(InvalidTypeException::class);
88
		$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
89
			"preferred_services" => "",
90
		]]);
91
	}
92
93 View Code Duplication
	public function testPreferredServices()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
	{
95
		$this->assertEquals(
96
			[
97
				"ignored_services" => [],
98
				"preferred_services" => ["bar"],
99
				"fast_annotation_checks" => [],
100
				"fast_annotation_checks_enabled" => true,
101
			],
102
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
103
				"preferred_services" => ["bar"]
104
			]])
105
		);
106
	}
107
108 View Code Duplication
	public function testFastAnnotationChecksInvalid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
	{
110
		$this->expectException(InvalidTypeException::class);
111
		$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
112
			"fast_annotation_checks" => "",
113
		]]);
114
	}
115
116 View Code Duplication
	public function testFastAnnotationChecks()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
	{
118
		$this->assertEquals(
119
			[
120
				"ignored_services" => [],
121
				"preferred_services" => [],
122
				"fast_annotation_checks" => ["@Foo", "@Bar"],
123
				"fast_annotation_checks_enabled" => true,
124
			],
125
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
126
				"fast_annotation_checks" => ["@Foo", "@Bar"],
127
			]])
128
		);
129
	}
130
131 View Code Duplication
	public function testFastAnnotationChecksEnabledInvalid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
132
	{
133
		$this->expectException(InvalidTypeException::class);
134
		$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
135
			"fast_annotation_checks_enabled" => "",
136
		]]);
137
	}
138
139 View Code Duplication
	public function testFastAnnotationChecksEnabled()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
140
	{
141
		$this->assertEquals(
142
			[
143
				"ignored_services" => [],
144
				"preferred_services" => [],
145
				"fast_annotation_checks" => [],
146
				"fast_annotation_checks_enabled" => false,
147
			],
148
			$this->processor->process($this->configTreeBuilder->buildTree(), ["autowiring" => [
149
				"fast_annotation_checks_enabled" => false,
150
			]])
151
		);
152
	}
153
154
}
155