Skip to content

Commit 76857ce

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent 8f2a045 commit 76857ce

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

Tests/Compiler/AutowireExceptionPassTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public function testThrowsException()
3131
$autowireException = new AutowiringFailedException('foo_service_id', 'An autowiring exception message');
3232
$autowirePass->expects($this->any())
3333
->method('getAutowiringExceptions')
34-
->will($this->returnValue([$autowireException]));
34+
->willReturn([$autowireException]);
3535

3636
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
3737
->getMock();
3838
$inlinePass->expects($this->any())
3939
->method('getInlinedServiceIds')
40-
->will($this->returnValue([]));
40+
->willReturn([]);
4141

4242
$container = new ContainerBuilder();
4343
$container->register('foo_service_id');
@@ -60,18 +60,18 @@ public function testThrowExceptionIfServiceInlined()
6060
$autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message');
6161
$autowirePass->expects($this->any())
6262
->method('getAutowiringExceptions')
63-
->will($this->returnValue([$autowireException]));
63+
->willReturn([$autowireException]);
6464

6565
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
6666
->getMock();
6767
$inlinePass->expects($this->any())
6868
->method('getInlinedServiceIds')
69-
->will($this->returnValue([
69+
->willReturn([
7070
// a_service inlined into b_service
7171
'a_service' => ['b_service'],
7272
// b_service inlined into c_service
7373
'b_service' => ['c_service'],
74-
]));
74+
]);
7575

7676
$container = new ContainerBuilder();
7777
// ONLY register c_service in the final container
@@ -95,18 +95,18 @@ public function testDoNotThrowExceptionIfServiceInlinedButRemoved()
9595
$autowireException = new AutowiringFailedException('a_service', 'An autowiring exception message');
9696
$autowirePass->expects($this->any())
9797
->method('getAutowiringExceptions')
98-
->will($this->returnValue([$autowireException]));
98+
->willReturn([$autowireException]);
9999

100100
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
101101
->getMock();
102102
$inlinePass->expects($this->any())
103103
->method('getInlinedServiceIds')
104-
->will($this->returnValue([
104+
->willReturn([
105105
// a_service inlined into b_service
106106
'a_service' => ['b_service'],
107107
// b_service inlined into c_service
108108
'b_service' => ['c_service'],
109-
]));
109+
]);
110110

111111
// do NOT register c_service in the container
112112
$container = new ContainerBuilder();
@@ -126,13 +126,13 @@ public function testNoExceptionIfServiceRemoved()
126126
$autowireException = new AutowiringFailedException('non_existent_service');
127127
$autowirePass->expects($this->any())
128128
->method('getAutowiringExceptions')
129-
->will($this->returnValue([$autowireException]));
129+
->willReturn([$autowireException]);
130130

131131
$inlinePass = $this->getMockBuilder(InlineServiceDefinitionsPass::class)
132132
->getMock();
133133
$inlinePass->expects($this->any())
134134
->method('getInlinedServiceIds')
135-
->will($this->returnValue([]));
135+
->willReturn([]);
136136

137137
$container = new ContainerBuilder();
138138

Tests/Compiler/MergeExtensionConfigurationPassTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ public function testExpressionLanguageProviderForwarding()
3030
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
3131
$extension->expects($this->any())
3232
->method('getXsdValidationBasePath')
33-
->will($this->returnValue(false));
33+
->willReturn(false);
3434
$extension->expects($this->any())
3535
->method('getNamespace')
36-
->will($this->returnValue('http://example.org/schema/dic/foo'));
36+
->willReturn('http://example.org/schema/dic/foo');
3737
$extension->expects($this->any())
3838
->method('getAlias')
39-
->will($this->returnValue('foo'));
39+
->willReturn('foo');
4040
$extension->expects($this->once())
4141
->method('load')
42-
->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
42+
->willReturnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
4343
$tmpProviders = $container->getExpressionLanguageProviders();
44-
}));
44+
});
4545

4646
$provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
4747
$container = new ContainerBuilder(new ParameterBag());
@@ -76,7 +76,7 @@ public function testExtensionConfigurationIsTrackedByDefault()
7676
$extension = $this->getMockBuilder(FooExtension::class)->setMethods(['getConfiguration'])->getMock();
7777
$extension->expects($this->exactly(2))
7878
->method('getConfiguration')
79-
->will($this->returnValue(new FooConfiguration()));
79+
->willReturn(new FooConfiguration());
8080

8181
$container = new ContainerBuilder(new ParameterBag());
8282
$container->registerExtension($extension);

Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function isFreshProvider()
6767
[$this->equalTo('locales')],
6868
[$this->equalTo('default_locale')]
6969
)
70-
->will($this->returnValueMap([
70+
->willReturnMap([
7171
['locales', ['fr', 'en']],
7272
['default_locale', 'fr'],
73-
]))
73+
])
7474
;
7575
}, true];
7676
}

Tests/ContainerBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ public function testExtension()
10591059
public function testRegisteredButNotLoadedExtension()
10601060
{
10611061
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
1062-
$extension->expects($this->once())->method('getAlias')->will($this->returnValue('project'));
1062+
$extension->expects($this->once())->method('getAlias')->willReturn('project');
10631063
$extension->expects($this->never())->method('load');
10641064

10651065
$container = new ContainerBuilder();
@@ -1071,7 +1071,7 @@ public function testRegisteredButNotLoadedExtension()
10711071
public function testRegisteredAndLoadedExtension()
10721072
{
10731073
$extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
1074-
$extension->expects($this->exactly(2))->method('getAlias')->will($this->returnValue('project'));
1074+
$extension->expects($this->exactly(2))->method('getAlias')->willReturn('project');
10751075
$extension->expects($this->once())->method('load')->with([['foo' => 'bar']]);
10761076

10771077
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)