Skip to content

Commit 2c08fd0

Browse files
[3.1][PhpUnitBridge] Drop ErrorAssert in favor of @expectedDeprecation
1 parent 92e9d0f commit 2c08fd0

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

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()

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
}

0 commit comments

Comments
 (0)