testSkipEmptyClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
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\Compiler;
3
4
use PHPUnit\Framework\TestCase;
5
use Psr\Container\ContainerInterface as PsrContainerInterface;
6
use Skrz\Bundle\AutowiringBundle\DependencyInjection\ClassMultiMap;
7
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\ClassMapBuildCompilerPass;
8
use Skrz\Bundle\AutowiringBundle\Tests\DependencyInjection\ClassMultipleMapSource\SomeClass;
9
use Skrz\Bundle\AutowiringBundle\Tests\DependencyInjection\ClassMultipleMapSource\SomeInterface;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
use Symfony\Component\DependencyInjection\Definition;
13
14
class ClassMapBuildCompilerPassTest extends TestCase
15
{
16
17
	const EMPTY_BUILDER_MAP = [
18
		PsrContainerInterface::class => ["service_container"],
19
		ContainerInterface::class => ["service_container"],
20
	];
21
22
	public function testProcessEmpty()
23
	{
24
		$containerBuilder = new ContainerBuilder();
25
		$map = new ClassMultiMap(new ContainerBuilder());
26
		$pass = new ClassMapBuildCompilerPass($map);
27
28
		$pass->process($containerBuilder);
29
		$container = $map->all();
30
31
		$this->assertSame(static::EMPTY_BUILDER_MAP, $container);
32
	}
33
34
	public function testProcess()
35
	{
36
		$containerBuilder = new ContainerBuilder();
37
		$map = new ClassMultiMap(new ContainerBuilder());
38
		$pass = new ClassMapBuildCompilerPass($map);
39
40
		$containerBuilder
41
			->setDefinition("someService", new Definition(SomeClass::class));
42
		$pass->process($containerBuilder);
43
		$this->assertSame(array_merge(static::EMPTY_BUILDER_MAP, [
44
			SomeInterface::class => ["someService"],
45
			SomeClass::class => ["someService"]
46
		]), $map->all());
47
	}
48
49 View Code Duplication
	public function testSkipEmptyClass()
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
		$containerBuilder = new ContainerBuilder();
52
		$map = new ClassMultiMap(new ContainerBuilder());
53
		$pass = new ClassMapBuildCompilerPass($map);
54
55
		$containerBuilder
56
			->setDefinition("someService", new Definition());
57
		$pass->process($containerBuilder);
58
		$this->assertSame(static::EMPTY_BUILDER_MAP, $map->all());
59
	}
60
61 View Code Duplication
	public function testSkipAbstract()
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...
62
	{
63
		$containerBuilder = new ContainerBuilder();
64
		$map = new ClassMultiMap(new ContainerBuilder());
65
		$pass = new ClassMapBuildCompilerPass($map);
66
67
		$containerBuilder
68
			->setDefinition("someService", new Definition(SomeClass::class))
69
			->setAbstract(true);
70
		$pass->process($containerBuilder);
71
		$this->assertSame(static::EMPTY_BUILDER_MAP, $map->all());
72
	}
73
74
}
75