Skip to content

Commit 3f23fba

Browse files
Remove calls to TestCase::iniSet() and calls to deprecated methods of MockBuilder
1 parent 1384448 commit 3f23fba

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Tests/Extension/HttpKernelExtensionTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ class HttpKernelExtensionTest extends TestCase
3131
public function testFragmentWithError()
3232
{
3333
$this->expectException(\Twig\Error\RuntimeError::class);
34-
$renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo')));
34+
$renderer = $this->getFragmentHandler(new \Exception('foo'));
3535

3636
$this->renderTemplate($renderer);
3737
}
3838

3939
public function testRenderFragment()
4040
{
41-
$renderer = $this->getFragmentHandler($this->returnValue(new Response('html')));
41+
$renderer = $this->getFragmentHandler(new Response('html'));
4242

4343
$response = $this->renderTemplate($renderer);
4444

@@ -87,11 +87,17 @@ public function testGenerateFragmentUri()
8787
$this->assertSame('/_fragment?_hash=PP8%2FeEbn1pr27I9wmag%2FM6jYGVwUZ0l2h0vhh2OJ6CI%3D&_path=template%3Dfoo.html.twig%26_format%3Dhtml%26_locale%3Den%26_controller%3DSymfonyBundleFrameworkBundleControllerTemplateController%253A%253AtemplateAction', $twig->render('index'));
8888
}
8989

90-
protected function getFragmentHandler($return)
90+
protected function getFragmentHandler($returnOrException): FragmentHandler
9191
{
9292
$strategy = $this->createMock(FragmentRendererInterface::class);
9393
$strategy->expects($this->once())->method('getName')->willReturn('inline');
94-
$strategy->expects($this->once())->method('render')->will($return);
94+
95+
$mocker = $strategy->expects($this->once())->method('render');
96+
if ($returnOrException instanceof \Exception) {
97+
$mocker->willThrowException($returnOrException);
98+
} else {
99+
$mocker->willReturn($returnOrException);
100+
}
95101

96102
$context = $this->createMock(RequestStack::class);
97103

Tests/Extension/RuntimeLoaderProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ trait RuntimeLoaderProvider
2020
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
2121
{
2222
$loader = $this->createMock(RuntimeLoaderInterface::class);
23-
$loader->expects($this->any())->method('load')->will($this->returnValueMap([
23+
$loader->expects($this->any())->method('load')->willReturnMap([
2424
['Symfony\Component\Form\FormRenderer', $renderer],
25-
]));
25+
]);
2626
$environment->addRuntimeLoader($loader);
2727
}
2828
}

0 commit comments

Comments
 (0)