DefinitionFinderTest::testAutowired()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zenify\DoctrineFilters\Tests\DI;
6
7
use Nette\DI\ContainerBuilder;
8
use PHPUnit\Framework\TestCase;
9
use stdClass;
10
use Zenify\DoctrineFilters\DI\DefinitionFinder;
11
use Zenify\DoctrineFilters\Exception\DefinitionForTypeNotFoundException;
12
13
14
final class DefinitionFinderTest extends TestCase
15
{
16
17
	/**
18
	 * @var ContainerBuilder
19
	 */
20
	private $containerBuilder;
21
22
	/**
23
	 * @var DefinitionFinder
24
	 */
25
	private $definitionFinder;
26
27
28
	protected function setUp()
29
	{
30
		$this->containerBuilder = new ContainerBuilder;
31
		$this->definitionFinder = new DefinitionFinder($this->containerBuilder);
32
	}
33
34
35 View Code Duplication
	public function testAutowired()
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...
36
	{
37
		$definition = $this->containerBuilder->addDefinition('some')
38
			->setClass(stdClass::class);
39
40
		$this->assertSame($definition, $this->definitionFinder->getDefinitionByType(stdClass::class));
41
	}
42
43
44 View Code Duplication
	public function testNonAutowired()
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...
45
	{
46
		$definition = $this->containerBuilder->addDefinition('some')
47
			->setClass(stdClass::class)
48
			->setAutowired(FALSE);
49
50
		$this->assertSame($definition, $this->definitionFinder->getDefinitionByType(stdClass::class));
51
	}
52
53
54
	/**
55
	 * @expectedException \Zenify\DoctrineFilters\Exception\DefinitionForTypeNotFoundException
56
	 */
57
	public function testMissing()
58
	{
59
		$this->definitionFinder->getDefinitionByType(stdClass::class);
60
	}
61
62
}
63