8000 minor #20268 [3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expec… · symfony/symfony@d481c50 · GitHub
[go: up one dir, main page]

Skip to content

Commit d481c50

Browse files
committed
minor #20268 [3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation (nicolas-grekas)
This PR was merged into the 3.1 branch. Discussion ---------- [3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - Needs #20255 first Commits ------- 5735255 [3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation
2 parents a01cc6d + 5735255 commit d481c50

File tree

6 files changed

+34
-51
lines changed

6 files changed

+34
-51
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

14-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1514
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1615
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1716
use Symfony\Component\Cache\Adapter\ApcuAdapter;
@@ -547,16 +546,17 @@ public function testSerializerCacheDisabled()
547546

548547
/**
549548
* @group legacy
550-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
549+
* @expectedDeprecation The "framework.serializer.cache" option is deprecated %s.
551550
*/
552551
public function testDeprecatedSerializerCacheOption()
553552
{
554-
ErrorAssert::assertDeprecationsAreTriggered('The "framework.serializer.cache" option is deprecated', function () {
555-
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));
553+
$container = $this->createContainerFromFile('serializer_legacy_cache', array('kernel.debug' => true, 'kernel.container_class' => __CLASS__));
556554

557-
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
558-
$this->assertEquals(new Reference('foo'), $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1));
559-
});
555+
$this->assertFalse($container->hasDefinition('serializer.mapping.cache_class_metadata_factory'));
556+
$this->assertTrue($container->hasDefinition('serializer.mapping.class_metadata_factory'));
557+
558+
$cache = $container->getDefinition('serializer.mapping.class_metadata_factory')->getArgument(1);
559+
$this->assertEquals(new Reference('foo'), $cache);
560560
}
561561

562562
public function testAssetHelperWhenAssetsAreEnabled()

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
1313

14-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1514
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1615
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
1716
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
@@ -86,17 +85,15 @@ public function testParseValidNameWithNotFoundBundle()
8685
/**
8786
* @group legacy
8887
* @dataProvider provideAbsolutePaths
89-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
88+
* @expectedDeprecation Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.
9089
*/
9190
public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref)
9291
{
93-
ErrorAssert::assertDeprecationsAreTriggered('Absolute template path support is deprecated since Symfony 3.1 an 628C d will be removed in 4.0.', function () use ($name, $logicalName, $path, $ref) {
94-
$template = $this->parser->parse($name);
92+
$template = $this->parser->parse($name);
9593

96-
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
97-
$this->assertSame($logicalName, $template->getLogicalName());
98-
$this->assertSame($path, $template->getPath());
99-
});
94+
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
95+
$this->assertSame($logicalName, $template->getLogicalName());
96+
$this->assertSame($path, $template->getPath());
10097
}
10198

10299
public function provideAbsolutePaths()

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
require_once __DIR__.'/Fixtures/includes/classes.php';
1515
require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
1616

17-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1817
use Symfony\Component\Config\Resource\ResourceInterface;
1918
use Symfony\Component\DependencyInjection\Alias;
2019
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -59,18 +58,18 @@ public function testDefinitions()
5958
}
6059

6160
/**
62-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
61+
* @group legacy
62+
* @expectedDeprecation The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.
6363
*/
6464
public function testCreateDeprecatedService()
6565
{
66-
ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () {
67-
$definition = new Definition('stdClass');
68-
$definition->setDeprecated(true);
66+
$definition = new Definition('stdClass');
67+
$definition->setDeprecated(true);
6968

70-
$builder = new ContainerBuilder();
71-
$builder->setDefinition('deprecated_foo', $definition);
72-
$builder->get('deprecated_foo');
73-
});
69+
$builder = new ContainerBuilder();
70+
$builder->setDefinition('deprecated_foo', $definition);
71+
$builder->compile();
72+
$builder->get('deprecated_foo');
7473
}
7574

7675
public function testRegister()

src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Tests\Loader;
1313

14-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1514
use Symfony\Component\DependencyInjection\ContainerInterface;
1615
use Symfony\Component\DependencyInjection\ContainerBuilder;
1716
use Symfony\Component\DependencyInjection\Reference;
@@ -558,23 +557,17 @@ public function testAutowire()
558557

559558
/**
560559
* @group legacy
561-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
560+
* @expectedDeprecation Using the attribute "class" is deprecated for the service "bar" which is defined as an alias %s.
561+
* @expectedDeprecation Using the element "tag" is deprecated for the service "bar" which is defined as an alias %s.
562+
* @expectedDeprecation Using the element "factory" is deprecated for the service "bar" which is defined as an alias %s.
562563
*/
563564
public function testAliasDefinitionContainsUnsupportedElements()
564565
{
565-
$deprecations = array(
566-
'Using the attribute "class" is deprecated for the service "bar" which is defined as an alias',
567-
'Using the element "tag" is deprecated for the service "bar" which is defined as an alias',
568-
'Using the element "factory" is deprecated for the service "bar" which is defined as an alias',
569-
);
570-
571-
ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {
572-
$container = new ContainerBuilder();
573-
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
566+
$container = new ContainerBuilder();
567+
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
574568

575-
$loader->load('legacy_invalid_alias_definition.xml');
569+
$loader->load('legacy_invalid_alias_definition.xml');
576570

577-
$this->assertTrue($container->has('bar'));
578-
});
571+
$this->assertTrue($container->has('bar'));
579572
}
580573
}

src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\Fragment;
1313

14-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1514
use Symfony\Component\HttpKernel\Controller\ControllerReference;
1615
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
1716
use Symfony\Component\HttpKernel\HttpCache\Esi;
@@ -28,16 +27,14 @@ public function testRenderFallbackToInlineStrategyIfEsiNotSupported()
2827

2928
/**
3029
* @group legacy
31-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
30+
* @expectedDeprecation Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated %s.
3231
*/
3332
public function testRenderFallbackWithObjectAttributesIsDeprecated()
3433
{
35-
ErrorAssert::assertDeprecationsAreTriggered('Passing non-scalar values as part of URI attributes to the ESI and SSI rendering strategies is deprecated', function () {
36-
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
37-
$request = Request::create('/');
38-
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
39-
$strategy->render($reference, $request);
40-
});
34+
$strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(true), new UriSigner('foo'));
35+
$request = Request::create('/');
36+
$reference = new ControllerReference('main_controller', array('foo' => array('a' => array(), 'b' => new \stdClass())), array());
37+
$strategy->render($reference, $request);
4138
}
4239

4340
public function testRender()

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Yaml\Tests;
1313

14-
use Symfony\Bridge\PhpUnit\ErrorAssert;
1514
use Symfony\Component\Yaml\Inline;
1615
use Symfony\Component\Yaml\Yaml;
1716

@@ -255,14 +254,12 @@ public function getScalarIndicators()
255254

256255
/**
257256
* @group legacy
258-
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
257+
* @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.
259258
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
260259
*/
261260
public function testParseUnquotedScalarStartingWithPercentCharacter()
262261
{
263-
ErrorAssert::assertDeprecationsAreTriggered('Not quoting the scalar "%foo " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () {
264-
Inline::parse('{ foo: %foo }');
265-
});
262+
Inline::parse('{ foo: %bar }');
266263
}
267264

268265
/**

0 commit comments

Comments
 (0)
0