|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Symplify\DefaultAutowire\Tests\DependencyInjection\Definition; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
8
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
9
|
|
|
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionAnalyzer; |
|
10
|
|
|
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionValidator; |
|
11
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\ |
|
12
|
|
|
MissingArgumentsTypehintsFactory; |
|
13
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\ |
|
14
|
|
|
NotMissingArgumentsTypehintsFactory; |
|
15
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\EmptyConstructor; |
|
16
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\EmptyConstructorFactory; |
|
17
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\MissingArgumentsTypehints; |
|
18
|
|
|
use Symplify\DefaultAutowire\Tests\DependencyInjection\Definition\DefinitionAnalyzerSource\NotMissingArgumentsTypehints; |
|
19
|
|
|
|
|
20
|
|
|
final class DefinitionAnalyzerTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var DefinitionAnalyzer |
|
24
|
|
|
*/ |
|
25
|
|
|
private $definitionAnalyzer; |
|
26
|
|
|
|
|
27
|
|
|
protected function setUp() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->definitionAnalyzer = new DefinitionAnalyzer(new DefinitionValidator()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testClassHasConstructorArguments() |
|
33
|
|
|
{ |
|
34
|
|
|
$definition = new Definition(EmptyConstructor::class); |
|
35
|
|
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired(new ContainerBuilder(), $definition)); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testClassHaveMissingArgumentsTypehints() |
|
39
|
|
|
{ |
|
40
|
|
|
$definition = new Definition(MissingArgumentsTypehints::class); |
|
41
|
|
|
$definition->setArguments(['@someService']); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertFalse($this->definitionAnalyzer->shouldDefinitionBeAutowired(new ContainerBuilder(), $definition)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testClassHaveNotMissingArgumentsTypehints() |
|
47
|
|
|
{ |
|
48
|
|
|
$definition = new Definition(NotMissingArgumentsTypehints::class); |
|
49
|
|
|
$definition->setArguments(['@someService']); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertTrue($this->definitionAnalyzer->shouldDefinitionBeAutowired(new ContainerBuilder(), $definition)); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|