Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46fc0b9

Browse filesBrowse files
Merge branch '3.2'
* 3.2: add changelog for the DUMP_OBJECT_AS_MAP flag Relax some mocks
2 parents 6fe7b61 + 3d9ad54 commit 46fc0b9
Copy full SHA for 46fc0b9

File tree

8 files changed

+122
-173
lines changed
Filter options

8 files changed

+122
-173
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php
+13-27Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,30 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Reference;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheWarmerPass;
1718

1819
class AddCacheWarmerPassTest extends TestCase
1920
{
2021
public function testThatCacheWarmersAreProcessedInPriorityOrder()
2122
{
22-
$services = array(
23-
'my_cache_warmer_service1' => array(0 => array('priority' => 100)),
24-
'my_cache_warmer_service2' => array(0 => array('priority' => 200)),
25-
'my_cache_warmer_service3' => array(0 => array()),
26-
);
27-
28-
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
29-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
30-
31-
$container->expects($this->atLeastOnce())
32-
->method('findTaggedServiceIds')
33-
->will($this->returnValue($services));
34-
$container->expects($this->atLeastOnce())
35-
->method('getDefinition')
36-
->with('cache_warmer')
37-
->will($this->returnValue($definition));
38-
$container->expects($this->atLeastOnce())
39-
->method('hasDefinition')
40-
->with('cache_warmer')
41-
->will($this->returnValue(true));
23+
$container = new ContainerBuilder();
4224

43-
$definition->expects($this->once())
44-
->method('replaceArgument')
45-
->with(0, array(
46-
new Reference('my_cache_warmer_service2'),
47-
new Reference('my_cache_warmer_service1'),
48-
new Reference('my_cache_warmer_service3'),
49-
));
25+
$definition = $container->register('cache_warmer')->addArgument(null);
26+
$container->register('my_cache_warmer_service1')->addTag('kernel.cache_warmer', array('priority' => 100));
27+
$container->register('my_cache_warmer_service2')->addTag('kernel.cache_warmer', array('priority' => 200));
28+
$container->register('my_cache_warmer_service3')->addTag('kernel.cache_warmer');
5029

5130
$addCacheWarmerPass = new AddCacheWarmerPass();
5231
$addCacheWarmerPass->process($container);
32+
33+
$expected = array(
34+
new Reference('my_cache_warmer_service2'),
35+
new Reference('my_cache_warmer_service1'),
36+
new Reference('my_cache_warmer_service3'),
37+
);
38+
$this->assertEquals($expected, $definition->getArgument(0));
5339
}
5440

5541
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php
+13-23Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConfigCachePass;
1819

@@ -23,33 +24,22 @@ class ConfigCachePassTest extends TestCase
2324
{
2425
public function testThatCheckersAreProcessedInPriorityOrder()
2526
{
26-
$services = array(
27-
'checker_2' => array(0 => array('priority' => 100)),
28-
'checker_1' => array(0 => array('priority' => 200)),
29-
'checker_3' => array(0 => array()),
30-
);
27+
$container = new ContainerBuilder();
3128

32-
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
33-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
34-
35-
$container->expects($this->atLeastOnce())
36-
->method('findTaggedServiceIds')
37-
->will($this->returnValue($services));
38-
$container->expects($this->atLeastOnce())
39-
->method('getDefinition')
40-
->with('config_cache_factory')
41-
->will($this->returnValue($definition));
42-
43-
$definition->expects($this->once())
44-
->method('replaceArgument')
45-
->with(0, new IteratorArgument(array(
46-
new Reference('checker_1'),
47-
new Reference('checker_2'),
48-
new Reference('checker_3'),
49-
)));
29+
$definition = $container->register('config_cache_factory')->addArgument(null);
30+
$container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100));
31+
$container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200));
32+
$container->register('checker_3')->addTag('config_cache.resource_checker');
5033

5134
$pass = new ConfigCachePass();
5235
$pass->process($container);
36+
37+
$expected = new IteratorArgument(array(
38+
new Reference('checker_1'),
39+
new Reference('checker_2'),
40+
new Reference('checker_3'),
41+
));
42+
$this->assertEquals($expected, $definition->getArgument(0));
5343
}
5444

5545
public function testThatCheckersCanBeMissing()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php
+26-25Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,46 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass;
16+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1618
use Symfony\Component\DependencyInjection\Reference;
1719

1820
/**
1921
* @group legacy
2022
*/
2123
class PropertyInfoPassTest extends TestCase
2224
{
23-
public function testServicesAreOrderedAccordingToPriority()
25+
/**
26+
* @dataProvider provideTags
27+
*/
28+
public function testServicesAreOrderedAccordingToPriority($index, $tag)
2429
{
25-
$services = array(
26-
'n3' => array(array()),
27-
'n1' => array(array('priority' => 200)),
28-
'n2' => array(array('priority' => 100)),
29-
);
30+
$container = new ContainerBuilder();
31+
32+
$definition = $container->register('property_info')->setArguments(array(null, null, null, null));
33+
$container->register('n2')->addTag($tag, array('priority' => 100));
34+
$container->register('n1')->addTag($tag, array('priority' => 200));
35+
$container->register('n3')->addTag($tag);
36+
37+
$propertyInfoPass = new PropertyInfoPass();
38+
$propertyInfoPass->process($container);
3039

31-
$expected = array(
40+
$expected = new IteratorArgument(array(
3241
new Reference('n1'),
3342
new Reference('n2'),
3443
new Reference('n3'),
35-
);
36-
37-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
38-
39-
$container
40-
->expects($this->any())
41-
->method('findTaggedServiceIds')
42-
->will($this->returnValue($services));
43-
44-
$propertyInfoPass = new PropertyInfoPass();
44+
));
45+
$this->assertEquals($expected, $definition->getArgument($index));
46+
}
4547

46-
$method = new \ReflectionMethod(
47-
'Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass',
48-
'findAndSortTaggedServices'
48+
public function provideTags()
49+
{
50+
return array(
51+
array(0, 'property_info.list_extractor'),
52+
array(1, 'property_info.type_extractor'),
53+
array(2, 'property_info.description_extractor'),
54+
array(3, 'property_info.access_extractor'),
4955
);
50-
$method->setAccessible(true);
51-
52-
$actual = $method->invoke($propertyInfoPass, 'tag', $container);
53-
54-
$this->assertEquals($expected, $actual);
5556
}
5657

5758
public function testReturningEmptyArrayWhenNoService()

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php
+14-25Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Reference;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass;
1718

@@ -61,7 +62,7 @@ public function testThrowExceptionWhenNoEncoders()
6162
array()
6263
));
6364

64-
$container->expects($this->once())
65+
$container->expects($this->any())
6566
->method('getDefinition')
6667
->will($this->returnValue($definition));
6768

@@ -73,34 +74,22 @@ public function testThrowExceptionWhenNoEncoders()
7374

7475
public function testServicesAreOrderedAccordingToPriority()
7576
{
76-
$services = array(
77-
'n3' => array(array()),
78-
'n1' => array(array('priority' => 200)),
79-
'n2' => array(array('priority' => 100)),
80-
);
81-
82-
$expected = array(
83-
new Reference('n1'),
84-
new Reference('n2'),
85-
new Reference('n3'),
86-
);
87-
88-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
77+
$container = new ContainerBuilder();
8978

90-
$container->expects($this->any())
91-
->method('findTaggedServiceIds')
92-
->will($this->returnValue($services));
79+
$definition = $container->register('serializer')->setArguments(array(null, null));
80+
$container->register('n2')->addTag('serializer.normalizer', array('priority' => 100))->addTag('serializer.encoder', array('priority' => 100));
81+
$container->register('n1')->addTag('serializer.normalizer', array('priority' => 200))->addTag('serializer.encoder', array('priority' => 200));
82+
$container->register('n3')->addTag('serializer.normalizer')->addTag('serializer.encoder');
9383

9484
$serializerPass = new SerializerPass();
85+
$serializerPass->process($container);
9586

96-
$method = new \ReflectionMethod(
97-
'Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass',
98-
'findAndSortTaggedServices'
87+
$expected = array(
88+
new Reference('n1'),
89+
new Reference('n2'),
90+
new Reference('n3'),
9991
);
100-
$method->setAccessible(true);
101-
102-
$actual = $method->invoke($serializerPass, 'tag', $container);
103-
104-
$this->assertEquals($expected, $actual);
92+
$this->assertEquals($expected, $definition->getArgument(0));
93+
$this->assertEquals($expected, $definition->getArgument(1));
10594
}
10695
}

‎src/Symfony/Component/Config/Tests/DependencyInjection/ConfigCachePassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/DependencyInjection/ConfigCachePassTest.php
+13-23Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,30 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\Config\DependencyInjection\ConfigCachePass;
1819

1920
class ConfigCachePassTest extends TestCase
2021
{
2122
public function testThatCheckersAreProcessedInPriorityOrder()
2223
{
23-
$services = array(
24-
'checker_2' => array(0 => array('priority' => 100)),
25-
'checker_1' => array(0 => array('priority' => 200)),
26-
'checker_3' => array(0 => array()),
27-
);
24+
$container = new ContainerBuilder();
2825

29-
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
30-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
31-
32-
$container->expects($this->atLeastOnce())
33-
->method('findTaggedServiceIds')
34-
->will($this->returnValue($services));
35-
$container->expects($this->atLeastOnce())
36-
->method('getDefinition')
37-
->with('config_cache_factory')
38-
->will($this->returnValue($definition));
39-
40-
$definition->expects($this->once())
41-
->method('replaceArgument')
42-
->with(0, new IteratorArgument(array(
43-
new Reference('checker_1'),
44-
new Reference('checker_2'),
45-
new Reference('checker_3'),
46-
)));
26+
$definition = $container->register('config_cache_factory')->addArgument(null);
27+
$container->register('checker_2')->addTag('config_cache.resource_checker', array('priority' => 100));
28+
$container->register('checker_1')->addTag('config_cache.resource_checker', array('priority' => 200));
29+
$container->register('checker_3')->addTag('config_cache.resource_checker');
4730

4831
$pass = new ConfigCachePass();
4932
$pass->process($container);
33+
34+
$expected = new IteratorArgument(array(
35+
new Reference('checker_1'),
36+
new Reference('checker_2'),
37+
new Reference('checker_3'),
38+
));
39+
$this->assertEquals($expected, $definition->getArgument(0));
5040
}
5141

5242
public function testThatCheckersCanBeMissing()

‎src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/DependencyInjection/PropertyInfoPassTest.php
+26-25Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,44 @@
1212
namespace Symfony\Component\PropertyInfo\Tests\DependencyInjection;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1517
use Symfony\Component\DependencyInjection\Reference;
1618
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
1719

1820
class PropertyInfoPassTest extends TestCase
1921
{
20-
public function testServicesAreOrderedAccordingToPriority()
22+
/**
23+
* @dataProvider provideTags
24+
*/
25+
public function testServicesAreOrderedAccordingToPriority($index, $tag)
2126
{
22-
$services = array(
23-
'n3' => array(array()),
24-
'n1' => array(array('priority' => 200)),
25-
'n2' => array(array('priority' => 100)),
26-
);
27+
$container = new ContainerBuilder();
28+
29+
$definition = $container->register('property_info')->setArguments(array(null, null, null, null));
30+
$container->register('n2')->addTag($tag, array('priority' => 100));
31+
$container->register('n1')->addTag($tag, array('priority' => 200));
32+
$container->register('n3')->addTag($tag);
33+
34+
$propertyInfoPass = new PropertyInfoPass();
35+
$propertyInfoPass->process($container);
2736

28-
$expected = array(
37+
$expected = new IteratorArgument(array(
2938
new Reference('n1'),
3039
new Reference('n2'),
3140
new Reference('n3'),
32-
);
33-
34-
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
35-
36-
$container
37-
->expects($this->any())
38-
->method('findTaggedServiceIds')
39-
->will($this->returnValue($services));
40-
41-
$propertyInfoPass = new PropertyInfoPass();
41+
));
42+
$this->assertEquals($expected, $definition->getArgument($index));
43+
}
4244

43-
$method = new \ReflectionMethod(
44-
'Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass',
45-
'findAndSortTaggedServices'
45+
public function provideTags()
46+
{
47+
return array(
48+
array(0, 'property_info.list_extractor'),
49+
array(1, 'property_info.type_extractor'),
50+
array(2, 'property_info.description_extractor'),
51+
array(3, 'property_info.access_extractor'),
4652
);
47-
$method->setAccessible(true);
48-
49-
$actual = $method->invoke($propertyInfoPass, 'tag', $container);
50-
51-
$this->assertEquals($expected, $actual);
5253
}
5354

5455
public function testReturningEmptyArrayWhenNoService()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.