Skip to content

Commit b65a386

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: fixed obsolete getMock() usage [WebProfilerBundle] Display multiple HTTP headers in WDT
2 parents 1fe6baf + 6ea81a8 commit b65a386

24 files changed

+88
-118
lines changed

Tests/Command/RouterDebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private function getContainer()
6363
{
6464
$routeCollection = new RouteCollection();
6565
$routeCollection->add('foo', new Route('foo'));
66-
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
66+
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
6767
$router
6868
->expects($this->any())
6969
->method('getRouteCollection')
@@ -74,7 +74,7 @@ private function getContainer()
7474
->disableOriginalConstructor()
7575
->getMock();
7676

77-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
77+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
7878
$container
7979
->expects($this->once())
8080
->method('has')

Tests/Command/RouterMatchCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function getContainer()
6262
$routeCollection = new RouteCollection();
6363
$routeCollection->add('foo', new Route('foo'));
6464
$requestContext = new RequestContext();
65-
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
65+
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
6666
$router
6767
->expects($this->any())
6868
->method('getRouteCollection')
@@ -78,7 +78,7 @@ private function getContainer()
7878
->disableOriginalConstructor()
7979
->getMock();
8080

81-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
81+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
8282
$container
8383
->expects($this->once())
8484
->method('has')

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testDebugDefaultDirectory()
6464

6565
public function testDebugCustomDirectory()
6666
{
67-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
67+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
6868
$kernel->expects($this->once())
6969
->method('getBundle')
7070
->with($this->equalTo($this->translationDir))
@@ -82,7 +82,7 @@ public function testDebugCustomDirectory()
8282
*/
8383
public function testDebugInvalidDirectory()
8484
{
85-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
85+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
8686
$kernel->expects($this->once())
8787
->method('getBundle')
8888
->with($this->equalTo('dir'))
@@ -130,7 +130,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
130130
->method('getFallbackLocales')
131131
->will($this->returnValue(array('en')));
132132

133-
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
133+
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
134134
$extractor
135135
->expects($this->any())
136136
->method('extract')
@@ -140,7 +140,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
140140
})
141141
);
142142

143-
$loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
143+
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
144144
$loader
145145
->expects($this->any())
146146
->method('loadMessages')
@@ -151,7 +151,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
151151
);
152152

153153
if (null === $kernel) {
154-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
154+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
155155
$kernel
156156
->expects($this->any())
157157
->method('getBundle')
@@ -166,7 +166,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
166166
->method('getRootDir')
167167
->will($this->returnValue($this->translationDir));
168168

169-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
169+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
170170
$container
171171
->expects($this->any())
172172
->method('get')
@@ -182,7 +182,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
182182

183183
private function getBundle($path)
184184
{
185-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
185+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
186186
$bundle
187187
->expects($this->any())
188188
->method('getPath')

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
8585
->method('getFallbackLocales')
8686
->will($this->returnValue(array('en')));
8787

88-
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
88+
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
8989
$extractor
9090
->expects($this->any())
9191
->method('extract')
@@ -95,7 +95,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
9595
})
9696
);
9797

98-
$loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
98+
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
9999
$loader
100100
->expects($this->any())
101101
->method('loadMessages')
@@ -105,7 +105,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
105105
})
106106
);
107107

108-
$writer = $this->getMock('Symfony\Component\Translation\Writer\TranslationWriter');
108+
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
109109
$writer
110110
->expects($this->any())
111111
->method('getFormats')
@@ -114,7 +114,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
114114
);
115115

116116
if (null === $kernel) {
117-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
117+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
118118
$kernel
119119
->expects($this->any())
120120
->method('getBundle')
@@ -129,7 +129,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
129129
->method('getRootDir')
130130
->will($this->returnValue($this->translationDir));
131131

132-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
132+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
133133
$container
134134
->expects($this->any())
135135
->method('get')
@@ -146,7 +146,7 @@ private function getContainer($extractedMessages = array(), $loadedMessages = ar
146146

147147
private function getBundle($path)
148148
{
149-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
149+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
150150
$bundle
151151
->expects($this->any())
152152
->method('getPath')

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ApplicationTest extends TestCase
2222
{
2323
public function testBundleInterfaceImplementation()
2424
{
25-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
25+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
2626

2727
$kernel = $this->getKernel(array($bundle), true);
2828

@@ -117,10 +117,10 @@ public function testBundleCommandsHaveRightContainer()
117117

118118
private function getKernel(array $bundles, $useDispatcher = false)
119119
{
120-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
120+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
121121

122122
if ($useDispatcher) {
123-
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
123+
$dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
124124
$dispatcher
125125
->expects($this->atLeastOnce())
126126
->method('dispatch')
@@ -145,7 +145,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
145145
->will($this->returnValue(array()))
146146
;
147147

148-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
148+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
149149
$kernel
150150
->expects($this->any())
151151
->method('getBundles')
@@ -162,7 +162,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
162162

163163
private function createBundleMock(array $commands)
164164
{
165-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle');
165+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle')->getMock();
166166
$bundle
167167
->expects($this->once())
168168
->method('registerCommands')

Tests/Controller/ControllerNameParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function createParser()
147147
'FabpotFooBundle' => array($this->getBundle('TestBundle\Fabpot\FooBundle', 'FabpotFooBundle'), $this->getBundle('TestBundle\Sensio\FooBundle', 'SensioFooBundle')),
148148
);
149149

150-
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
150+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
151151
$kernel
152152
->expects($this->any())
153153
->method('getBundle')
@@ -178,7 +178,7 @@ private function createParser()
178178

179179
private function getBundle($namespace, $name)
180180
{
181-
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
181+
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
182182
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
183183
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
184184

Tests/Controller/ControllerResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ protected function createControllerResolver(LoggerInterface $logger = null, Cont
175175

176176
protected function createMockParser()
177177
{
178-
return $this->getMock('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser', array(), array(), '', false);
178+
return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser')->disableOriginalConstructor()->getMock();
179179
}
180180

181181
protected function createMockContainer()
182182
{
183-
return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
183+
return $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
184184
}
185185
}
186186

Tests/Controller/RedirectControllerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte
6666

6767
$request->attributes = new ParameterBag($attributes);
6868

69-
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
69+
$router = $this->getMockBuilder('Symfony\Component\Routing\RouterInterface')->getMock();
7070
$router
7171
->expects($this->once())
7272
->method('generate')
7373
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
7474
->will($this->returnValue($url));
7575

76-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
76+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
7777

7878
$container
7979
->expects($this->once())
@@ -230,7 +230,7 @@ public function testPathQueryParams($expectedUrl, $path, $queryString)
230230

231231
private function createRequestObject($scheme, $host, $port, $baseUrl, $queryString = '')
232232
{
233-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
233+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
234234
$request
235235
->expects($this->any())
236236
->method('getScheme')
@@ -257,7 +257,7 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri
257257

258258
private function createRedirectController($httpPort = null, $httpsPort = null)
259259
{
260-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
260+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
261261

262262
if (null !== $httpPort) {
263263
$container

Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
2424
'my_cache_warmer_service3' => array(),
2525
);
2626

27-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
28-
$container = $this->getMock(
29-
'Symfony\Component\DependencyInjection\ContainerBuilder',
30-
array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
31-
);
27+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
28+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
3229

3330
$container->expects($this->atLeastOnce())
3431
->method('findTaggedServiceIds')
@@ -56,11 +53,8 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
5653

5754
public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
5855
{
59-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
60-
$container = $this->getMock(
61-
'Symfony\Component\DependencyInjection\ContainerBuilder',
62-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
63-
);
56+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
57+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
6458

6559
$container->expects($this->never())->method('findTaggedServiceIds');
6660
$container->expects($this->never())->method('getDefinition');
@@ -76,11 +70,8 @@ public function testThatCompilerPassIsIgnoredIfThereIsNoCacheWarmerDefinition()
7670

7771
public function testThatCacheWarmersMightBeNotDefined()
7872
{
79-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
80-
$container = $this->getMock(
81-
'Symfony\Component\DependencyInjection\ContainerBuilder',
82-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
83-
);
73+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
74+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
8475

8576
$container->expects($this->atLeastOnce())
8677
->method('findTaggedServiceIds')

Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ public function testThatConstraintValidatorServicesAreProcessed()
2020
'my_constraint_validator_service2' => array(),
2121
);
2222

23-
$validatorFactoryDefinition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
24-
$container = $this->getMock(
25-
'Symfony\Component\DependencyInjection\ContainerBuilder',
26-
array('findTaggedServiceIds', 'getDefinition', 'hasDefinition')
27-
);
23+
$validatorFactoryDefinition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
24+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
2825

29-
$validatorDefinition1 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
30-
$validatorDefinition2 = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('getClass'));
26+
$validatorDefinition1 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
27+
$validatorDefinition2 = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->setMethods(array('getClass'))->getMock();
3128

3229
$validatorDefinition1->expects($this->atLeastOnce())
3330
->method('getClass')
@@ -67,11 +64,8 @@ public function testThatConstraintValidatorServicesAreProcessed()
6764

6865
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
6966
{
70-
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition');
71-
$container = $this->getMock(
72-
'Symfony\Component\DependencyInjection\ContainerBuilder',
73-
array('hasDefinition', 'findTaggedServiceIds', 'getDefinition')
74-
);
67+
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
68+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('hasDefinition', 'findTaggedServiceIds', 'getDefinition'))->getMock();
7569

7670
$container->expects($this->never())->method('findTaggedServiceIds');
7771
$container->expects($this->never())->method('getDefinition');

0 commit comments

Comments
 (0)