Skip to content

Commit 37709f3

Browse files
committed
Refactored the DI tests to load YAML and XML files instead of arrays
1 parent c417370 commit 37709f3

20 files changed

+283
-56
lines changed

Tests/DependencyInjection/Compiler/LoggerChannelPassTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ protected function getContainer()
6161
$container->set('monolog.handler.test', new Definition('%monolog.handler.null.class%', array (100, false)));
6262
$definition->addMethodCall('pushHandler', array(new Reference('monolog.handler.test')));
6363

64-
$service = new Definition('TestClass', array('false', new Reference('logger')));
65-
$service->addTag('monolog.logger', array ('channel' => 'test'));
66-
$container->setDefinition('test', $service);
67-
6864
// Handlers
6965
$container->set('monolog.handler.a', new Definition('%monolog.handler.null.class%', array (100, false)));
7066
$container->set('monolog.handler.b', new Definition('%monolog.handler.null.class%', array (100, false)));

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
use Symfony\Bundle\MonologBundle\DependencyInjection\Configuration;
1515
use Symfony\Component\Config\Definition\Processor;
1616

17-
/**
18-
* @author Alexandre Salomé <[email protected]>
19-
*/
2017
class ConfigurationTest extends \PHPUnit_Framework_TestCase
2118
{
2219
/**
@@ -97,6 +94,7 @@ public function testArrays()
9794
$this->assertEquals('inclusive', $config['handlers']['foo']['channels']['type']);
9895
$this->assertEquals('A', $config['handlers']['foo']['channels']['elements'][0]);
9996
$this->assertEquals('B', $config['handlers']['foo']['channels']['elements'][1]);
97+
10098
// Check bar
10199
$this->assertCount(2, $config['handlers']['bar']['channels']['elements']);
102100
$this->assertEquals('exclusive', $config['handlers']['bar']['channels']['type']);
@@ -159,8 +157,8 @@ public function testWithType()
159157
*/
160158
protected function process($configs)
161159
{
162-
$configuration = new Configuration();
163160
$processor = new Processor();
164-
return $processor->process($configuration->getConfigTreeBuilder()->buildTree(), $configs);
161+
162+
return $processor->processConfiguration(new Configuration(), $configs);
165163
}
166164
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<config>
10+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="false" level="ERROR" />
11+
<handler name="main" type="fingers_crossed" action-level="ERROR" handler="nested" />
12+
<handler name="nested" type="stream" />
13+
</config>
14+
</srv:container>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<srv:imports>
10+
<srv:import resource="new_and_priority_import.xml" />
11+
</srv:imports>
12+
13+
<config>
14+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="true" level="WARNING" />
15+
<handler name="first" type="rotating_file" path="/tmp/monolog.log" bubble="true" level="ERROR" priority="3" />
16+
<handler name="last" type="stream" path="/tmp/last.log" bubble="true" level="ERROR" priority="-3" />
17+
</config>
18+
</srv:container>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<config>
10+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="true" level="ERROR" />
11+
<handler name="main" type="buffer" level="INFO" handler="nested" />
12+
<handler name="nested" type="stream" />
13+
</config>
14+
</srv:container>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<srv:imports>
10+
<srv:import resource="new_at_end_import.xml" />
11+
</srv:imports>
12+
13+
<config>
14+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="false" level="WARNING" />
15+
<handler name="new" type="stream" path="/tmp/monolog.log" bubble="true" level="ERROR" />
16+
</config>
17+
</srv:container>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<config>
10+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="true" level="ERROR" />
11+
<handler name="main" type="fingers_crossed" action-level="ERROR" handler="nested" />
12+
<handler name="nested" type="stream" />
13+
</config>
14+
</srv:container>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<srv:imports>
10+
<srv:import resource="overwriting_import.xml" />
11+
</srv:imports>
12+
13+
<config>
14+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="true" level="WARNING" />
15+
</config>
16+
</srv:container>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" ?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/monolog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/monolog http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
8+
9+
<config>
10+
<handler name="custom" type="stream" path="/tmp/symfony.log" bubble="false" level="ERROR" />
11+
<handler name="main" type="fingers_crossed" action-level="ERROR" handler="nested" />
12+
<handler name="nested" type="stream" />
13+
</config>
14+
</srv:container>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
monolog:
2+
handlers:
3+
custom:
4+
type: stream
5+
path: /tmp/symfony.log
6+
bubble: false
7+
level: ERROR
8+
main:
9+
type: fingers_crossed
10+
action_level: ERROR
11+
handler: nested
12+
nested:
13+
type: stream

0 commit comments

Comments
 (0)