|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Tests\Leogout\Bundle\SeoBundle\DependencyInjection\Compiler; |
|
4
|
|
|
|
|
5
|
|
|
use Leogout\Bundle\SeoBundle\DependencyInjection\Compiler\SeoGeneratorPass; |
|
6
|
|
|
use Leogout\Bundle\SeoBundle\Tests\TestCase; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Description of SeoGeneratorPassTest. |
|
11
|
|
|
* |
|
12
|
|
|
* @author: leogout |
|
13
|
|
|
*/ |
|
14
|
|
|
class SeoGeneratorPassTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
private $containerBuilder; |
|
17
|
|
|
private $definition; |
|
18
|
|
|
private $builderDefinition; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var MenuBuilderPass |
|
22
|
|
|
*/ |
|
23
|
|
|
private $pass; |
|
24
|
|
|
protected function setUp() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->containerBuilder = $this->prophesize('Symfony\Component\DependencyInjection\ContainerBuilder'); |
|
27
|
|
|
$this->definition = $this->prophesize('Symfony\Component\DependencyInjection\Definition'); |
|
28
|
|
|
$this->builderDefinition = $this->prophesize('Symfony\Component\DependencyInjection\Definition'); |
|
29
|
|
|
$this->pass = new SeoGeneratorPass(); |
|
|
|
|
|
|
30
|
|
|
$this->containerBuilder->getDefinition('leogout_seo.provider.generator')->willReturn($this->definition); |
|
31
|
|
|
$this->containerBuilder->getDefinition('id')->willReturn($this->builderDefinition); |
|
32
|
|
|
$this->builderDefinition->isPublic()->willReturn(true); |
|
33
|
|
|
$this->builderDefinition->isAbstract()->willReturn(false); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @expectedException \InvalidArgumentException |
|
38
|
|
|
* @expectedExceptionMessage Seo generator services cannot be abstract but "id" is. |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testFailsWhenServiceIsAbstract() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->builderDefinition->isAbstract()->willReturn(true); |
|
43
|
|
|
$this->containerBuilder->findTaggedServiceIds('leogout_seo.generator')->willReturn(['id' => [['alias' => 'foo']]]); |
|
44
|
|
|
$this->pass->process($this->containerBuilder->reveal()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @expectedException \InvalidArgumentException |
|
49
|
|
|
* @expectedExceptionMessage Seo generator services must be public, but "id" is not. |
|
50
|
|
|
*/ |
|
51
|
|
|
public function testFailsWhenServiceIsPrivate() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->builderDefinition->isPublic()->willReturn(false); |
|
54
|
|
|
$this->containerBuilder->findTaggedServiceIds('leogout_seo.generator')->willReturn(['id' => [['alias' => 'foo']]]); |
|
55
|
|
|
$this->pass->process($this->containerBuilder->reveal()); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @expectedException \InvalidArgumentException |
|
60
|
|
|
* @expectedExceptionMessage Tag "leogout_seo.generator" requires an "alias" field in "id" definition. |
|
61
|
|
|
*/ |
|
62
|
|
|
public function testFailsWhenAliasIsMissing() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->containerBuilder->findTaggedServiceIds('leogout_seo.generator')->willReturn(['id' => [['alias' => '']]]); |
|
65
|
|
|
$this->pass->process($this->containerBuilder->reveal()); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..