Skip to content

Commit 5d0400a

Browse files
Merge branch '2.8' into 3.0
* 2.8: update tests to use the new error assertion helper [ci] Upgrade to symfony/phpunit-bridge >=3.2@dev Conflicts: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php src/Symfony/Component/Yaml/Tests/ParserTest.php
2 parents 7dd8e60 + 427cdb4 commit 5d0400a

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Tests/ContainerBuilderTest.php

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

17+
use Symfony\Bridge\PhpUnit\ErrorAssert;
1718
use Symfony\Component\Config\Resource\ResourceInterface;
1819
use Symfony\Component\DependencyInjection\Alias;
1920
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -60,28 +61,14 @@ public function testDefinitions()
6061

6162
public function testCreateDeprecatedService()
6263
{
63-
$deprecations = array();
64-
set_error_handler(function ($type, $msg) use (&$deprecations) {
65-
if (E_USER_DEPRECATED !== $type) {
66-
restore_error_handler();
64+
ErrorAssert::assertDeprecationsAreTriggered('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', function () {
65+
$definition = new Definition('stdClass');
66+
$definition->setDeprecated(true);
6767

68-
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
69-
}
70-
71-
$deprecations[] = $msg;
68+
$builder = new ContainerBuilder();
69+
$builder->setDefinition('deprecated_foo', $definition);
70+
$builder->get('deprecated_foo');
7271
});
73-
74-
$definition = new Definition('stdClass');
75-
$definition->setDeprecated(true);
76-
77-
$builder = new ContainerBuilder();
78-
$builder->setDefinition('deprecated_foo', $definition);
79-
$builder->get('deprecated_foo');
80-
81-
restore_error_handler();
82-
83-
$this->assertCount(1, $deprecations);
84-
$this->assertContains('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed.', $deprecations[0]);
8572
}
8673

8774
public function testRegister()

0 commit comments

Comments
 (0)