Completed
Push — master ( 3bca0f...4b95a7 )
by Tomáš
05:03 queued 02:28
created

DefinitionAnalyzerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 34
rs 10
c 3
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testHaveNotMissingArgumentsTypehints() 0 7 1
A testHasConstructorArguments() 0 5 1
A testHaveMissingArgumentsTypehints() 0 7 1
1
<?php
2
3
namespace Symplify\DefaultAutowire\Tests\DependencyInjection\Definition;
4
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Component\DependencyInjection\Definition;
7
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionAnalyzer;
8
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionValidator;
9
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\EmptyConstructor;
10
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\MissingArgumentsTypehints;
11
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\NotMissingArgumentsTypehints;
12
13
final class DefinitionAnalyzerTest extends TestCase
14
{
15
    /**
16
     * @var DefinitionAnalyzer
17
     */
18
    private $definitionAnalyzer;
19
20
    protected function setUp()
21
    {
22
        $this->definitionAnalyzer = new DefinitionAnalyzer(new DefinitionValidator());
23
    }
24
25
    public function testHasConstructorArguments()
26
    {
27
        $definition = new Definition(EmptyConstructor::class);
28
        $this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired($definition));
29
    }
30
31
    public function testHaveMissingArgumentsTypehints()
32
    {
33
        $definition = new Definition(MissingArgumentsTypehints::class);
34
        $definition->setArguments(['@someService']);
35
36
        $this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired($definition));
37
    }
38
39
    public function testHaveNotMissingArgumentsTypehints()
40
    {
41
        $definition = new Definition(NotMissingArgumentsTypehints::class);
42
        $definition->setArguments(['@someService']);
43
44
        $this->assertTrue($this->definitionAnalyzer->shouldDefinitionBeAutowired($definition));
45
    }
46
}
47