|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher Updater Bundle. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2015 Sourcefabric z.u. and contributors. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please see the |
|
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright 2015 Sourcefabric z.ú. |
|
12
|
|
|
* @license http://www.superdesk.org/license |
|
13
|
|
|
*/ |
|
14
|
|
|
namespace SWP\UpdaterBundle\Tests\DependencyInjection; |
|
15
|
|
|
|
|
16
|
|
|
use SWP\UpdaterBundle\DependencyInjection\Compiler\MonologCompilerPass; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
18
|
|
|
|
|
19
|
|
|
class MonologCompilerPassTest extends \PHPUnit_Framework_TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
private $container; |
|
22
|
|
|
private $definition; |
|
23
|
|
|
private $pass; |
|
24
|
|
|
|
|
25
|
|
|
public function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); |
|
28
|
|
|
$this->definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); |
|
29
|
|
|
$this->pass = new MonologCompilerPass(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @covers SWP\UpdaterBundle\DependencyInjection\Compiler\MonologCompilerPass::process |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testProcess() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->container->expects($this->once()) |
|
38
|
|
|
->method('hasParameter') |
|
39
|
|
|
->with('swp_updater.monolog_channel') |
|
40
|
|
|
->will($this->returnValue(true)); |
|
41
|
|
|
|
|
42
|
|
|
$this->container->expects($this->once()) |
|
43
|
|
|
->method('getParameter') |
|
44
|
|
|
->with('kernel.bundles') |
|
45
|
|
|
->will($this->returnValue(array( |
|
46
|
|
|
'MonologBundle' => true, |
|
47
|
|
|
))); |
|
48
|
|
|
|
|
49
|
|
|
$this->container->expects($this->once()) |
|
50
|
|
|
->method('getDefinition') |
|
51
|
|
|
->with('swp_updater.manager') |
|
52
|
|
|
->will($this->returnValue($this->definition)); |
|
53
|
|
|
|
|
54
|
|
|
$this->definition->expects($this->once()) |
|
55
|
|
|
->method('addArgument') |
|
56
|
|
|
->with(new Reference('monolog.logger.updater')); |
|
57
|
|
|
|
|
58
|
|
|
$this->pass->process($this->container); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @covers SWP\UpdaterBundle\DependencyInjection\Compiler\MonologCompilerPass::process |
|
63
|
|
|
*/ |
|
64
|
|
|
public function testNoConfig() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->container->expects($this->once()) |
|
67
|
|
|
->method('hasParameter') |
|
68
|
|
|
->with('swp_updater.monolog_channel') |
|
69
|
|
|
->will($this->returnValue(false)); |
|
70
|
|
|
|
|
71
|
|
|
$this->pass->process($this->container); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException |
|
76
|
|
|
*/ |
|
77
|
|
|
public function testNoBundle() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->container->expects($this->once()) |
|
80
|
|
|
->method('hasParameter') |
|
81
|
|
|
->with('swp_updater.monolog_channel') |
|
82
|
|
|
->will($this->returnValue(true)); |
|
83
|
|
|
|
|
84
|
|
|
$this->container->expects($this->once()) |
|
85
|
|
|
->method('getParameter') |
|
86
|
|
|
->with('kernel.bundles') |
|
87
|
|
|
->will($this->returnValue(array())); |
|
88
|
|
|
|
|
89
|
|
|
$this->pass->process($this->container); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|